AerJobSet#
- class AerJobSet(backend, job_id, fn, experiments: List[QasmQobj], executor=None)[source]#
Bases:
JobV1
A set of
AerJob
classes for Aer simulators.An instance of this class is returned when you submit experiments with executor option. It provides methods that allow you to interact with the jobs as a single entity. For example, you can retrieve the results for all of the jobs using
result()
and cancel all jobs usingcancel()
.AerJobSet constructor.
- Parameters:
backend (Aerbackend) – Aerbackend.
job_id (int) – Job Id.
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.experiments (List[QasmQobj]) – List[QasmQobjs] to execute.
executor (ThreadPoolExecutor or dask.distributed.client) – The executor to be used to submit the job.
Attributes
- version = 1#
Methods
- cancelled() bool #
Return whether the job has been cancelled.
- done() bool #
Return whether the job has successfully run.
- in_final_state() bool #
Return whether the job is in a final job state such as
DONE
orERROR
.
- job(experiment: str | QuantumCircuit | Schedule) Tuple[AerJob, int] [source]#
Retrieve the job used to submit the specified experiment and its index.
- Parameters:
experiment –
Retrieve the job used to submit this experiment. Several types are accepted for convenience:
str: The name of the experiment.
QuantumCircuit: The name of the circuit instance will be used.
Schedule: The name of the schedule instance will be used.
- Returns:
A tuple of the job used to submit the experiment and the experiment index.
- Raises:
JobError – If the job for the experiment could not be found.
- job_id() str #
Return a unique id identifying the job.
- result(timeout: float | None = None) Result [source]#
Return the results of the jobs as a single Result object.
This call will block until all job results become available or the timeout is reached.
- Parameters:
timeout – Number of seconds to wait for job results.
- Returns:
Result object
- Return type:
qiskit.Result
- Raises:
JobError – if unable to retrieve all job results before the specified timeout.
- running() bool #
Return whether the job is actively running.
- status(worker: None | int | Iterable[int]) JobStatus | List[JobStatus] [source]#
Return the status of each job in this set.
- Args
worker: Worker id. When None, all workers’ statuses are returned.
- Returns:
A list of job statuses.
- submit()[source]#
Execute this set of jobs on an executor.
- Raises:
RuntimeError – If the jobs were already submitted.
- 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
orERROR
.- 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.
- worker(experiment: str | QuantumCircuit | Schedule) int | List[int] [source]#
Retrieve the index of job.
- Parameters:
experiment –
Retrieve the job used to submit this experiment. Several types are accepted for convenience:
str: The name of the experiment.
QuantumCircuit: The name of the circuit instance will be used.
Schedule: The name of the schedule instance will be used.
- Returns:
list or integer value of the job id
- Raises:
JobError – If the job for the experiment could not be found.
- worker_job(worker: None | int | Iterable[int]) AerJob | List[AerJob] [source]#
Retrieve the job specified with job’s id
- Parameters:
worker – retrive job used to submit with this job id.
- Returns:
A list of
AerJob
instances that represents the submitted jobs.- Raises:
JobError – If the job for the experiment could not be found.
- worker_results(worker: None | int | Iterable[int], timeout: float | None = None) Result | List[Result] [source]#
Return the result of the jobs specified with worker_id.
When the worker is None, this call return all worker’s result.
- Parameters:
worker – Worker id to wait for job result.
timeout – Number of seconds to wait for job results.
- Returns:
Result object instance that can be used to retrieve results for individual experiments.
- Return type:
qiskit.Result
- Raises:
JobError – if unable to retrieve all job results before the specified timeout.