AerJob#

class AerJob(backend, job_id, fn, qobj=None, circuits=None, parameter_binds=None, run_options=None, executor=None)[source]#

Bases: JobV1

AerJob class for Aer Simulators.

Initializes the asynchronous job.

Parameters:
  • backend (AerBackend) – the backend used to run the job.

  • job_id (str) – a unique id in the context of the backend used to run the job.

  • fn (function) – a callable function to execute qobj on backend. This should usually be a bound AerBackend._run() method, with the signature (qobj: QasmQobj, job_id: str) -> Result.

  • qobj (QasmQobj) – qobj to execute

  • circuits (list of QuantumCircuit) – circuits to execute. If qobj is set, this argument is ignored.

  • parameter_binds (list) – parameters for circuits. If qobj is set, this argument is ignored.

  • run_options (dict) – run_options to execute. If qobj is set, this argument is ignored.

  • executor (ThreadPoolExecutor or dask.distributed.client) – The executor to be used to submit the job.

Raises:

JobError – if no qobj and no circuits.

Attributes

version = 1#

Methods

backend()[source]#

Return the instance of the backend used for this job.

cancel()[source]#

Attempt to cancel the job.

cancelled() bool#

Return whether the job has been cancelled.

circuits()[source]#

Return the list of QuantumCircuit submitted for this job.

Returns:

the list of QuantumCircuit submitted for this job.

Return type:

list of QuantumCircuit

done() bool#

Return whether the job has successfully run.

executor()[source]#

Return the executor for this job

in_final_state() bool#

Return whether the job is in a final job state such as DONE or ERROR.

job_id() str#

Return a unique id identifying the job.

qobj()[source]#

Return the Qobj submitted for this job.

Returns:

the Qobj submitted for this job.

Return type:

Qobj

result(timeout=None)[source]#

Get job result. The behavior is the same as the underlying concurrent Future objects,

https://docs.python.org/3/library/concurrent.futures.html#future-objects

Parameters:

timeout (float) – number of seconds to wait for results.

Returns:

Result object

Return type:

qiskit.Result

Raises:
  • concurrent.futures.TimeoutError – if timeout occurred.

  • concurrent.futures.CancelledError – if job cancelled before completed.

running() bool#

Return whether the job is actively running.

status()[source]#

Gets the status of the job by querying the Python’s future

Returns:

The current JobStatus

Return type:

JobStatus

Raises:
  • JobError – If the future is in unexpected state

  • concurrent.futures.TimeoutError – if timeout occurred.

submit()[source]#

Submit the job to the backend for execution.

Raises:
  • QobjValidationError – if the JSON serialization of the Qobj passed

  • during construction does not validate against the Qobj schema.

  • JobError – if trying to re-submit the job.

wait_for_final_state(timeout: float | None = None, wait: float = 5, callback: Callable | None = None) None#

Poll the job status until it progresses to a final state such as DONE or ERROR.

Parameters:
  • timeout – Seconds to wait for the job. If None, wait indefinitely.

  • wait – Seconds between queries.

  • callback

    Callback function invoked after each query. The following positional arguments are provided to the callback function:

    • job_id: Job ID

    • job_status: Status of the job from the last query

    • job: This BaseJob instance

    Note: different subclass might provide different arguments to the callback function.

Raises:

JobTimeoutError – If the job does not reach a final state before the specified timeout.