QuantumJob

class braket.jobs.quantum_job.QuantumJob[source]

Bases: ABC

DEFAULT_RESULTS_POLL_TIMEOUT = 864000
DEFAULT_RESULTS_POLL_INTERVAL = 5
abstract property arn: str

The ARN (Amazon Resource Name) of the hybrid job.

Returns:

str – The ARN (Amazon Resource Name) of the hybrid job.

abstract property name: str

The name of the hybrid job.

Returns:

str – The name of the hybrid job.

abstractmethod state(use_cached_value=False)[source]

The state of the hybrid job.

Parameters:

use_cached_value (bool) – If True, uses the value most recently retrieved value from the Amazon Braket GetJob operation. If False, calls the GetJob operation to retrieve metadata, which also updates the cached value. Default = False.

Return type:

str

Returns:

str – The value of status in metadata(). This is the value of the status key in the Amazon Braket GetJob operation.

See also

metadata()

abstractmethod logs(wait=False, poll_interval_seconds=5)[source]

Display logs for a given hybrid job, optionally tailing them until hybrid job is complete.

If the output is a tty or a Jupyter cell, it will be color-coded based on which instance the log entry is from.

Parameters:
  • wait (bool) – True to keep looking for new log entries until the hybrid job completes; otherwise False. Default: False.

  • poll_interval_seconds (int) – The interval of time, in seconds, between polling for new log entries and hybrid job completion (default: 5).

Raises:

RuntimeError – If waiting and the hybrid job fails.

Return type:

None

abstractmethod metadata(use_cached_value=False)[source]

Gets the job metadata defined in Amazon Braket.

Parameters:

use_cached_value (bool) – If True, uses the value most recently retrieved from the Amazon Braket GetJob operation, if it exists; if does not exist, GetJob is called to retrieve the metadata. If False, always calls GetJob, which also updates the cached value. Default: False.

Return type:

dict[str, Any]

Returns:

dict[str, Any] – Dict that specifies the hybrid job metadata defined in Amazon Braket.

abstractmethod metrics(metric_type=MetricType.TIMESTAMP, statistic=MetricStatistic.MAX)[source]

Gets all the metrics data, where the keys are the column names, and the values are a list containing the values in each row.

Parameters:
  • metric_type (MetricType) – The type of metrics to get. Default: MetricType.TIMESTAMP.

  • statistic (MetricStatistic) – The statistic to determine which metric value to use when there is a conflict. Default: MetricStatistic.MAX.

Return type:

dict[str, list[Any]]

Returns:

dict[str, list[Any]] – The metrics data.

Example

timestamp energy

0 0.1 1 0.2

would be represented as: { “timestamp” : [0, 1], “energy” : [0.1, 0.2] } values may be integers, floats, strings or None.

abstractmethod cancel()[source]

Cancels the hybrid job.

Return type:

str

Returns:

str – Indicates the status of the hybrid job.

Raises:

ClientError – If there are errors invoking the CancelJob API.

abstractmethod result(poll_timeout_seconds=864000, poll_interval_seconds=5)[source]

Retrieves the hybrid job result persisted using save_job_result() function.

Parameters:
  • poll_timeout_seconds (float) – The polling timeout, in seconds, for result(). Default: 10 days.

  • poll_interval_seconds (float) – The polling interval, in seconds, for result(). Default: 5 seconds.

Return type:

dict[str, Any]

Returns:

dict[str, Any] – Dict specifying the hybrid job results.

Raises:
  • RuntimeError – if hybrid job is in a FAILED or CANCELLED state.

  • TimeoutError – if hybrid job execution exceeds the polling timeout period.

abstractmethod download_result(extract_to=None, poll_timeout_seconds=864000, poll_interval_seconds=5)[source]

Downloads the results from the hybrid job output S3 bucket and extracts the tar.gz bundle to the location specified by extract_to. If no location is specified, the results are extracted to the current directory.

Parameters:
  • extract_to (str | None) – The directory to which the results are extracted. The results are extracted to a folder titled with the hybrid job name within this directory. Default= Current working directory.

  • poll_timeout_seconds (float) – The polling timeout, in seconds, for download_result(). Default: 10 days.

  • poll_interval_seconds (float) – The polling interval, in seconds, for download_result().Default: 5 seconds.

Raises:
  • RuntimeError – if hybrid job is in a FAILED or CANCELLED state.

  • TimeoutError – if hybrid job execution exceeds the polling timeout period.

Return type:

None