IBMQJob

class IBMQJob(backend, api_client, job_id, creation_date, status, kind=None, name=None, time_per_step=None, result=None, qobj=None, error=None, tags=None, run_mode=None, share_level=None, client_info=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 call IBMQBackend.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 the JobStatus 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 use creation_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_client (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.

  • share_level (Optional[str]) – Level the job can be shared with.

  • client_info (Optional[Dict[str, str]]) – Client version.

  • kwargs (Any) – Additional job attributes.

Attributes

IBMQJob.client_version

Return version of the client used for this job.

Methods

IBMQJob.backend()

Return the backend where this job was executed.

IBMQJob.cancel()

Attempt to cancel the job.

IBMQJob.cancelled()

Return whether the job has been cancelled.

IBMQJob.creation_date()

Return job creation date, in local time.

IBMQJob.done()

Return whether the job has successfully run.

IBMQJob.error_message()

Provide details about the reason of failure.

IBMQJob.from_dict(data)

Deserialize a dictionary of simple types into an instance of this class.

IBMQJob.in_final_state()

Return whether the job is in a final job state.

IBMQJob.job_id()

Return the job ID assigned by the server.

IBMQJob.name()

Return the name assigned to this job.

IBMQJob.properties()

Return the backend properties for this job.

IBMQJob.qobj()

Return the Qobj for this job.

IBMQJob.queue_info()

Return queue information for this job.

IBMQJob.queue_position([refresh])

Return the position of the job in the server queue.

IBMQJob.refresh()

Obtain the latest job information from the server.

IBMQJob.result([timeout, wait, partial, refresh])

Return the result of the job.

IBMQJob.running()

Return whether the job is actively running.

IBMQJob.scheduling_mode()

Return the scheduling mode the job is in.

IBMQJob.share_level()

Return the share level of the job.

IBMQJob.status()

Query the server for the latest job status.

IBMQJob.submit()

Submit this job to an IBM Quantum Experience backend.

IBMQJob.tags()

Return the tags assigned to this job.

IBMQJob.time_per_step()

Return the date and time information on each step of the job processing.

IBMQJob.to_dict()

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 or ERROR.