resource_tracker.sentinel_api
#
HTTP client for the Spare Cores Sentinel metrics ingestion API.
Classes:
| Name | Description |
|---|---|
SentinelAPIError |
Raised when the Sentinel API returns a non-2xx response. |
Functions:
| Name | Description |
|---|---|
register_run |
Register the start of a new Run with the Sentinel API. |
refresh_credentials |
Refresh the temporary upload credentials for an existing run. |
finish_run |
Signal that a run has finished and submit final data. |
SentinelAPIError
#
Bases: Exception
Raised when the Sentinel API returns a non-2xx response.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
The HTTP status code. |
|
body |
The decoded response body (best-effort). |
Source code in resource_tracker/sentinel_api.py
register_run
#
Register the start of a new Run with the Sentinel API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
Bearer token for authentication. |
required |
metadata
|
Optional[Dict[str, Any]]
|
Optional run metadata. Recognised keys include
|
None
|
host_info
|
Optional[Dict[str, Any]]
|
Optional dict of |
None
|
cloud_info
|
Optional[Dict[str, Any]]
|
Optional dict of |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
A dict containing at least: |
dict
|
|
dict
|
|
dict
|
|
Raises:
| Type | Description |
|---|---|
SentinelAPIError
|
On non-2xx responses. |
Source code in resource_tracker/sentinel_api.py
refresh_credentials
#
Refresh the temporary upload credentials for an existing run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
Bearer token for authentication. |
required |
run_id
|
str
|
The run identifier returned by :func: |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dict with refreshed |
dict
|
func: |
Raises:
| Type | Description |
|---|---|
SentinelAPIError
|
On non-2xx responses. |
Source code in resource_tracker/sentinel_api.py
finish_run
#
finish_run(token, run_id, *, exit_code=0, run_status=finished, data_source=s3, data_uris=None, data_csv=None)
Signal that a run has finished and submit final data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
Bearer token for authentication. |
required |
run_id
|
str
|
The run identifier returned by :func: |
required |
exit_code
|
int
|
The exit code of the monitored process. |
0
|
run_status
|
RunStatus
|
Run outcome, either |
finished
|
data_source
|
DataSource
|
Either |
s3
|
data_uris
|
Optional[List[str]]
|
List of S3 URIs of uploaded gzipped CSV files.
Required when |
None
|
data_csv
|
Optional[str]
|
Plain CSV string to submit inline.
Required when |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
A dict with backend-computed statistics for the run. |
Raises:
| Type | Description |
|---|---|
SentinelAPIError
|
On non-2xx responses. |