qiskit-documentation/docs/api/qiskit/0.32/qiskit.providers.aer.jobs.A...

203 lines
5.7 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: AerJob
description: API reference for qiskit.providers.aer.jobs.AerJob
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.providers.aer.jobs.AerJob
---
# AerJob
<Class id="qiskit.providers.aer.jobs.AerJob" isDedicatedPage={true} github="https://github.com/qiskit/qiskit-aer/tree/stable/0.9/qiskit/providers/aer/jobs/aerjob.py" signature="AerJob(backend, job_id, fn, qobj, executor=None)" modifiers="class">
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*](qiskit.qobj.QasmQobj "qiskit.qobj.QasmQobj")) qobj to execute
* **executor** (*ThreadPoolExecutor or dask.distributed.client*) The executor to be used to submit the job.
## Methods
### backend
<Function id="qiskit.providers.aer.jobs.AerJob.backend" signature="AerJob.backend()">
Return the instance of the backend used for this job.
</Function>
### cancel
<Function id="qiskit.providers.aer.jobs.AerJob.cancel" signature="AerJob.cancel()">
Attempt to cancel the job.
</Function>
### cancelled
<Function id="qiskit.providers.aer.jobs.AerJob.cancelled" signature="AerJob.cancelled()">
Return whether the job has been cancelled.
**Return type**
`bool`
</Function>
### done
<Function id="qiskit.providers.aer.jobs.AerJob.done" signature="AerJob.done()">
Return whether the job has successfully run.
**Return type**
`bool`
</Function>
### executor
<Function id="qiskit.providers.aer.jobs.AerJob.executor" signature="AerJob.executor()">
Return the executor for this job
</Function>
### in\_final\_state
<Function id="qiskit.providers.aer.jobs.AerJob.in_final_state" signature="AerJob.in_final_state()">
Return whether the job is in a final job state such as `DONE` or `ERROR`.
**Return type**
`bool`
</Function>
### job\_id
<Function id="qiskit.providers.aer.jobs.AerJob.job_id" signature="AerJob.job_id()">
Return a unique id identifying the job.
**Return type**
`str`
</Function>
### qobj
<Function id="qiskit.providers.aer.jobs.AerJob.qobj" signature="AerJob.qobj()">
Return the Qobj submitted for this job.
**Returns**
the Qobj submitted for this job.
**Return type**
[Qobj](qiskit.qobj.Qobj "qiskit.qobj.Qobj")
</Function>
### result
<Function id="qiskit.providers.aer.jobs.AerJob.result" signature="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](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.
</Function>
### running
<Function id="qiskit.providers.aer.jobs.AerJob.running" signature="AerJob.running()">
Return whether the job is actively running.
**Return type**
`bool`
</Function>
### status
<Function id="qiskit.providers.aer.jobs.AerJob.status" signature="AerJob.status()">
Gets the status of the job by querying the Pythons future
**Returns**
The current JobStatus
**Return type**
[JobStatus](qiskit.providers.JobStatus "qiskit.providers.JobStatus")
**Raises**
* [**JobError**](qiskit.providers.JobError "qiskit.providers.JobError") If the future is in unexpected state
* **concurrent.futures.TimeoutError** if timeout occurred.
</Function>
### submit
<Function id="qiskit.providers.aer.jobs.AerJob.submit" signature="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**](qiskit.providers.JobError "qiskit.providers.JobError") if trying to re-submit the job.
</Function>
### wait\_for\_final\_state
<Function id="qiskit.providers.aer.jobs.AerJob.wait_for_final_state" signature="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**](qiskit.providers.JobTimeoutError "qiskit.providers.JobTimeoutError") If the job does not reach a final state before the specified timeout.
**Return type**
`None`
</Function>
## Attributes
### version
<Attribute id="qiskit.providers.aer.jobs.AerJob.version" attributeValue="1" />
</Class>