Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version

AerJob

AerJob(backend, job_id, fn, qobj, executor=None)

GitHub(opens in a new tab)

Bases: qiskit.providers.job.JobV1

AerJob class for Qiskit 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
  • executor (ThreadPoolExecutor or dask.distributed.client) – The executor to be used to submit the job.

Methods

backend

AerJob.backend()

Return the instance of the backend used for this job.

cancel

AerJob.cancel()

Attempt to cancel the job.

cancelled

AerJob.cancelled()

Return whether the job has been cancelled.

Return type

bool

done

AerJob.done()

Return whether the job has successfully run.

Return type

bool

executor

AerJob.executor()

Return the executor for this job

in_final_state

AerJob.in_final_state()

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

Return type

bool

job_id

AerJob.job_id()

Return a unique id identifying the job.

Return type

str

qobj

AerJob.qobj()

Return the Qobj submitted for this job.

Returns

the Qobj submitted for this job.

Return type

Qobj

result

AerJob.result(timeout=None)

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(opens in a new tab)

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

AerJob.running()

Return whether the job is actively running.

Return type

bool

status

AerJob.status()

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

AerJob.submit()

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

AerJob.wait_for_final_state(timeout=None, wait=5, callback=None)

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

Parameters

  • timeout (Optional[float]) – Seconds to wait for the job. If None, wait indefinitely.

  • wait (float) – Seconds between queries.

  • callback (Optional[Callable]) –

    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.

Return type

None


Attributes

version

= 1

Was this page helpful?
Report a bug or request content on GitHub.