IBMQJob¶
- class IBMQJob(backend, api, job_id, creation_date, status, kind=None, name=None, time_per_step=None, result=None, qobj=None, error=None, tags=None, run_mode=None, **kwargs)[source]¶
Representation of a job that executes on an IBM Quantum Experience backend.
The job may be executed on a simulator or a real device. A new
IBMQJob
instance is returned when you callIBMQBackend.run()
to submit a job to a particular backend.If the job is successfully submitted, you can inspect the job’s status by calling
status()
. Job status can be one of theJobStatus
members. For example:from qiskit.providers.jobstatus import JobStatus job = backend.run(...) try: job_status = job.status() # Query the backend server for job status. if job_status is JobStatus.RUNNING: print("The job is still running") except IBMQJobApiError as ex: print("Something wrong happened!: {}".format(ex))
Note
An error may occur when querying the remote server to get job information. The most common errors are temporary network failures and server errors, in which case an
IBMQJobApiError
is raised. These errors usually clear quickly, so retrying the operation is likely to succeed.Some of the methods in this class are blocking, which means control may not be returned immediately.
result()
is an example of a blocking method:job = backend.run(...) try: job_result = job.result() # It will block until the job finishes. print("The job finished with result {}".format(job_result)) except JobError as ex: print("Something wrong happened!: {}".format(ex))
Job information retrieved from the server is attached to the
IBMQJob
instance as attributes. Given that Qiskit and the server can be updated independently, some of these attributes might be deprecated or experimental. Supported attributes can be retrieved via methods. For example, you can usecreation_date()
to retrieve the job creation date, which is a supported attribute.IBMQJob constructor.
- Parameters
backend (
IBMQBackend
) – The backend instance used to run this job.api (
AccountClient
) – Object for connecting to the server.job_id (
str
) – Job ID.creation_date (
str
) – Job creation date.status (
str
) – Job status returned by the server.kind (
Optional
[str
]) – Job type.name (
Optional
[str
]) – Job name.time_per_step (
Optional
[dict
]) – Time spent for each processing step.result (
Optional
[dict
]) – Job result.qobj (
Union
[dict
,QasmQobj
,PulseQobj
,None
]) – Qobj for this job.error (
Optional
[dict
]) – Job error.tags (
Optional
[List
[str
]]) – Job tags.run_mode (
Optional
[str
]) – Scheduling mode the job runs in.kwargs (
Any
) – Additional job attributes.
Methods
Return the backend where this job was executed.
Attempt to cancel the job.
Return whether the job has been cancelled.
Return job creation date, in local time.
Return whether the job has successfully run.
Provide details about the reason of failure.
IBMQJob.from_dict
(data)Deserialize a dictionary of simple types into an instance of this class.
Return whether the job is in a final job state.
Return the job ID assigned by the server.
Return the name assigned to this job.
Return the backend properties for this job.
Return the Qobj for this job.
Return queue information for this job.
IBMQJob.queue_position
([refresh])Return the position of the job in the server queue.
Obtain the latest job information from the server.
IBMQJob.result
([timeout, wait, partial, refresh])Return the result of the job.
Return whether the job is actively running.
Return the scheduling mode the job is in.
Query the server for the latest job status.
Submit this job to an IBM Quantum Experience backend.
Return the tags assigned to this job.
Return the date and time information on each step of the job processing.
Serialize the model into a Python dict of simple types.
IBMQJob.update_name
(name)Update the name associated with this job.
IBMQJob.update_tags
([replacement_tags, …])Update the tags associated with this job.
IBMQJob.wait_for_final_state
([timeout, …])Wait until the job progresses to a final state such as
DONE
orERROR
.