Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resource accessor function #29

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions xdmod_data/warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,40 @@ def __describe_metrics_or_dimensions(self, realm, m_or_d):
('id', 'label', 'description'),
'id',
)

def __compliance(self, timeframe):
response = self.__http_requester._request_json(
'/controllers/compliance.php',
{'timeframe_mode': timeframe},
)
return response

def resources(self):
"""Get a data series describing the resources that are configured in
XDMoD and the type of each resource (High-performance computing, Disk storage,
etc).

Returns
-------
pandas.core.series.Series

Raises
------
RuntimeError
If this method is called outside the runtime context or if
there is an error requesting data from the warehouse.
"""
_validator._assert_runtime_context(self.__in_runtime_context)
names = []
types = []
resource_ids = []
cdata = self.__compliance('to_date')
for resource in cdata['metaData']['fields']:
if resource['name'] == 'requirement':
continue
names.append(
resource['header'][:-7].split('>')[1].replace('-', ' ')
)
types.append(resource['status'].split('|')[0].strip())
resource_ids.append(resource['resource_id'])
return pd.Series(data=types, index=names)
Loading