braket.jobs.quantum_job module

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.

abstract state(use_cached_value: bool = False) str[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.

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()

abstract logs(wait: bool = False, poll_interval_seconds: int = 5) None[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.

abstract metadata(use_cached_value: bool = False) dict[str, Any][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.

Returns:

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

abstract metrics(metric_type: MetricType = MetricType.TIMESTAMP, statistic: MetricStatistic = MetricStatistic.MAX) dict[str, list[Any]][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.

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.

abstract cancel() str[source]

Cancels the hybrid job.

Returns:

str – Indicates the status of the hybrid job.

Raises:

ClientError – If there are errors invoking the CancelJob API.

abstract result(poll_timeout_seconds: float = 864000, poll_interval_seconds: float = 5) dict[str, Any][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.

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.

abstract download_result(extract_to: str | None = None, poll_timeout_seconds: float = 864000, poll_interval_seconds: float = 5) None[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.