Jobs Client Methods#
This page lists all relevant methods for Dioptra Jobs that are available via the Python Client.
Contents
Requirements#
Install Dioptra - an installation and deployment of Dioptra must be available
Set Up the Python Client - the Python client must be configured and initialized
Jobs - CRUD methods#
After importing and initializing the client,these methods for creating, reading, updating, and deleting (CRUD) jobs can be executed via client.jobs.METHOD_NAME().
Get Jobs#
- JobsCollectionClient.get(group_id: int | None = None, index: int = 0, page_length: int = 10, sort_by: str | None = None, descending: bool | None = None, search: str | None = None) dioptra.client.jobs.T[source]#
Get a list of jobs.
- Parameters
group_id – The group id the jobs belong to. If None, return jobs from all groups that the user has access to. Optional, defaults to None.
index – The paging index. Optional, defaults to 0.
page_length – The maximum number of jobs to return in the paged response. Optional, defaults to 10.
sort_by – The field to use to sort the returned list. Optional, defaults to None.
descending – Sort the returned list in descending order. Optional, defaults to None.
search – Search for jobs using the Dioptra API’s query language. Optional, defaults to None.
- Returns
The response from the Dioptra API.
Get Job by ID#
Delete Job by ID#
Jobs - Other Methods#
Get Job Status#
Get Job Parameters#
Get Artifact Parameters#
Get Latest Metrics for Job#
- JobsCollectionClient.get_metrics_by_id(job_id: str | int) dioptra.client.jobs.T[source]#
Gets all the latest metrics for a job.
The returned metric value is either a float or a string representing the special values of NaN, Infinity, or -Infinity. NaN values are represented as the string “nan”, positive infinity as “inf”, and negative infinity as “-inf”. To convert these string values back to their corresponding float representations in Python, wrap the returned value with
float().
- Parameters
job_id – The job id, an integer.
- Returns
The response from the Dioptra API.
Append Metric to Job#
- JobsCollectionClient.append_metric_by_id(job_id: str | int, metric_name: str, metric_value: float, metric_step: int | None = None, timestamp: datetime.datetime | str | None = None) dioptra.client.jobs.T[source]#
Posts a new metric to a job.
- Parameters
job_id – The job id, an integer.
metric_name – The name of the metric.
metric_value – The value of the metric. Can be a float, NaN, Infinity, or -Infinity. NaN values will be converted to the string “nan” and infinite values will be converted to the strings “inf” and “-inf” before sending to the API.
metric_step – The step value for the metric, optional. Sequentially increasing step values are used to track how a metric changes over time. Indexed from 0. If not provided, defaults to 0.
timestamp – A timestamp value to associate with the metric. If not provided, defaults to the server time when the metric is received.
- Returns
The response from the Dioptra API.
Get Metric History (Snapshots)#
- JobsCollectionClient.get_metrics_snapshots_by_id(job_id: str | int, metric_name: str | int, index: int = 0, page_length: int = 10) dioptra.client.jobs.T[source]#
Gets the metric history for a job with a specific metric name.
Each returned metric value is either a float or a string representing the special values of NaN, Infinity, or -Infinity. NaN values are represented as the string “nan”, positive infinity as “inf”, and negative infinity as “-inf”. To convert these string values back to their corresponding float representations in Python, wrap the returned value with
float().
- Parameters
job_id – The job id, an integer.
metric_name – The name of the metric.
index – The paging index. Optional, defaults to 0.
page_length – The maximum number of metrics to return in the paged response. Optional, defaults to 10.
- Returns
The response from the Dioptra API.
Get Logs#
- JobsCollectionClient.get_logs_by_id(job_id: str | int, index: int = 0, page_length: int = 10, sort_by: str | None = None, descending: bool | None = None, severity: list[str] | None = None) dioptra.client.jobs.T[source]#
Get log records for the given job resource. Records are returned in the order they were added.
- Parameters
job_id – The resource ID of a job.
index – Index of the first log record to return.
page_length – Number of log records to return.
sort_by – The field to use to sort the returned list. Optional, defaults to None.
descending – Sort the returned list in descending order. Optional, defaults to None.
severity – list of severities to filter on
- Returns
The response from the Dioptra API.
Append Logs#
- JobsCollectionClient.append_logs_by_id(job_id: str | int, logs: collections.abc.Iterable[dict[str, Any]]) dioptra.client.jobs.T[source]#
Add log records for the given job. Job records are dicts of the form:
{ "severity": "WARNING", "loggerName": "hello_world.tasks", "message": "Log message", }Legal values for severity include DEBUG, INFO, WARNING, ERROR, CRITICAL. The logger name captures the name of the logger that emitted the record.
- Parameters
job_id – The resource ID of a job.
logs – An iterable of log records.
- Returns
The response from the Dioptra API.
Snapshots of Job - Methods#
Methods belonging to the SnapshotsSubCollectionClient can are accessed via the snapshots property of the Jobs Client (which points to SnapshotsSubCollectionClient)
Example - Get snapshots for a Job
Get snapshots for a Job
client.jobs.snapshots.get(1)
See available methods for the SnapshotsSubCollectionClient: