391 lines
12 KiB
Plaintext
391 lines
12 KiB
Plaintext
---
|
||
title: RuntimeJobV2 (v0.34)
|
||
description: API reference for qiskit_ibm_runtime.RuntimeJobV2 in qiskit-ibm-runtime v0.34
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit_ibm_runtime.RuntimeJobV2
|
||
---
|
||
|
||
# RuntimeJobV2
|
||
|
||
<Class id="qiskit_ibm_runtime.RuntimeJobV2" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/runtime_job_v2.py#L53-L273" signature="RuntimeJobV2(backend, api_client, client_params, job_id, program_id, service, creation_date=None, user_callback=None, result_decoder=None, image='', session_id=None, tags=None, version=None)" modifiers="class">
|
||
Bases: [`BasePrimitiveJob`](/api/qiskit/qiskit.primitives.BasePrimitiveJob "(in Qiskit v1.3)")\[[`PrimitiveResult`](/api/qiskit/qiskit.primitives.PrimitiveResult "(in Qiskit v1.3)"), `Literal`\[‘INITIALIZING’, ‘QUEUED’, ‘RUNNING’, ‘CANCELLED’, ‘DONE’, ‘ERROR’]], `BaseRuntimeJob`
|
||
|
||
Representation of a runtime V2 primitive exeuction.
|
||
|
||
RuntimeJob constructor.
|
||
|
||
**Parameters**
|
||
|
||
* **backend** ([*Backend*](/api/qiskit/qiskit.providers.Backend "(in Qiskit v1.3)")) – The backend instance used to run this job.
|
||
* **api\_client** (*RuntimeClient*) – Object for connecting to the server.
|
||
* **client\_params** (*ClientParameters*) – Parameters used for server connection.
|
||
* **job\_id** (*str*) – Job ID.
|
||
* **program\_id** (*str*) – ID of the program this job is for.
|
||
* **creation\_date** (*str | None*) – Job creation date, in UTC.
|
||
* **user\_callback** (*Callable | None*) – User callback function.
|
||
* **result\_decoder** (*Type\[ResultDecoder] | Sequence\[Type\[ResultDecoder]] | None*) – A `ResultDecoder` subclass used to decode job results.
|
||
* **image** (*str | None*) – Runtime image used for this job: image\_name:tag.
|
||
* **service** ([*qiskit\_runtime\_service.QiskitRuntimeService*](qiskit-runtime-service "qiskit_ibm_runtime.qiskit_runtime_service.QiskitRuntimeService")) – Runtime service.
|
||
* **session\_id** (*str | None*) – Job ID of the first job in a runtime session.
|
||
* **tags** (*List | None*) – Tags assigned to the job.
|
||
* **version** (*int | None*) – Primitive version.
|
||
|
||
## Attributes
|
||
|
||
### ERROR
|
||
|
||
<Attribute id="qiskit_ibm_runtime.RuntimeJobV2.ERROR" attributeTypeHint="str | RuntimeJobStatus" attributeValue="'ERROR'" />
|
||
|
||
### JOB\_FINAL\_STATES
|
||
|
||
<Attribute id="qiskit_ibm_runtime.RuntimeJobV2.JOB_FINAL_STATES" attributeTypeHint="Tuple[Literal['INITIALIZING', 'QUEUED', 'RUNNING', 'CANCELLED', 'DONE', 'ERROR'], ...]" attributeValue="('DONE', 'CANCELLED', 'ERROR')" />
|
||
|
||
### creation\_date
|
||
|
||
<Attribute id="qiskit_ibm_runtime.RuntimeJobV2.creation_date">
|
||
Job creation date in local time.
|
||
|
||
**Returns**
|
||
|
||
The job creation date as a datetime object, in local time, or `None` if creation date is not available.
|
||
</Attribute>
|
||
|
||
### image
|
||
|
||
<Attribute id="qiskit_ibm_runtime.RuntimeJobV2.image">
|
||
Return the runtime image used for the job.
|
||
|
||
**Returns**
|
||
|
||
image\_name:tag or “” if the default image is used.
|
||
|
||
**Return type**
|
||
|
||
Runtime image
|
||
</Attribute>
|
||
|
||
### inputs
|
||
|
||
<Attribute id="qiskit_ibm_runtime.RuntimeJobV2.inputs">
|
||
Job input parameters.
|
||
|
||
**Returns**
|
||
|
||
Input parameters used in this job.
|
||
</Attribute>
|
||
|
||
### instance
|
||
|
||
<Attribute id="qiskit_ibm_runtime.RuntimeJobV2.instance">
|
||
For ibm\_quantum channel jobs, return the instance where the job was run. For ibm\_cloud, None is returned.
|
||
</Attribute>
|
||
|
||
### primitive\_id
|
||
|
||
<Attribute id="qiskit_ibm_runtime.RuntimeJobV2.primitive_id">
|
||
Primitive name. :returns: Primitive this job is for.
|
||
</Attribute>
|
||
|
||
### session\_id
|
||
|
||
<Attribute id="qiskit_ibm_runtime.RuntimeJobV2.session_id">
|
||
Session ID.
|
||
|
||
**Returns**
|
||
|
||
Session ID. None if the backend is a simulator.
|
||
</Attribute>
|
||
|
||
### tags
|
||
|
||
<Attribute id="qiskit_ibm_runtime.RuntimeJobV2.tags">
|
||
Job tags.
|
||
|
||
**Returns**
|
||
|
||
Tags assigned to the job that can be used for filtering.
|
||
</Attribute>
|
||
|
||
### usage\_estimation
|
||
|
||
<Attribute id="qiskit_ibm_runtime.RuntimeJobV2.usage_estimation">
|
||
Return the usage estimation infromation for this job.
|
||
|
||
**Returns**
|
||
|
||
`quantum_seconds` which is the estimated system execution time of the job in seconds. Quantum time represents the time that the system is dedicated to processing your job.
|
||
</Attribute>
|
||
|
||
## Methods
|
||
|
||
### backend
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.backend" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/runtime_job_v2.py#L259-L273" signature="backend(timeout=None)">
|
||
Return the backend where this job was executed. Retrieve data again if backend is None.
|
||
|
||
**Raises**
|
||
|
||
**IBMRuntimeError** – If a network error occurred.
|
||
|
||
**Parameters**
|
||
|
||
**timeout** (*float | None*)
|
||
|
||
**Return type**
|
||
|
||
[*Backend*](/api/qiskit/qiskit.providers.Backend "(in Qiskit v1.3)") | None
|
||
</Function>
|
||
|
||
### cancel
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.cancel" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/runtime_job_v2.py#L148-L162" signature="cancel()">
|
||
Cancel the job.
|
||
|
||
**Raises**
|
||
|
||
* **RuntimeInvalidStateError** – If the job is in a state that cannot be cancelled.
|
||
* **IBMRuntimeError** – If unable to cancel job.
|
||
|
||
**Return type**
|
||
|
||
None
|
||
</Function>
|
||
|
||
### cancel\_result\_streaming
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.cancel_result_streaming" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/base_runtime_job.py#L132-L136" signature="cancel_result_streaming()">
|
||
Cancel result streaming.
|
||
|
||
**Return type**
|
||
|
||
None
|
||
</Function>
|
||
|
||
### cancelled
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.cancelled" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/runtime_job_v2.py#L190-L192" signature="cancelled()">
|
||
Return whether the job has been cancelled.
|
||
|
||
**Return type**
|
||
|
||
bool
|
||
</Function>
|
||
|
||
### done
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.done" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/runtime_job_v2.py#L194-L196" signature="done()">
|
||
Return whether the job has successfully run.
|
||
|
||
**Return type**
|
||
|
||
bool
|
||
</Function>
|
||
|
||
### error\_message
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.error_message" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/base_runtime_job.py#L207-L214" signature="error_message()">
|
||
Returns the reason if the job failed.
|
||
|
||
**Returns**
|
||
|
||
Error message string or `None`.
|
||
|
||
**Return type**
|
||
|
||
str | None
|
||
</Function>
|
||
|
||
### errored
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.errored" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/runtime_job_v2.py#L198-L200" signature="errored()">
|
||
Return whether the job has failed.
|
||
|
||
**Return type**
|
||
|
||
bool
|
||
</Function>
|
||
|
||
### in\_final\_state
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.in_final_state" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/runtime_job_v2.py#L202-L204" signature="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_ibm_runtime.RuntimeJobV2.job_id" signature="job_id()">
|
||
Return a unique id identifying the job.
|
||
|
||
**Return type**
|
||
|
||
str
|
||
</Function>
|
||
|
||
### logs
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.logs" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/runtime_job_v2.py#L210-L229" signature="logs()">
|
||
Return job logs.
|
||
|
||
<Admonition title="Note" type="note">
|
||
Job logs are only available after the job finishes.
|
||
</Admonition>
|
||
|
||
**Returns**
|
||
|
||
Job logs, including standard output and error.
|
||
|
||
**Raises**
|
||
|
||
**IBMRuntimeError** – If a network error occurred.
|
||
|
||
**Return type**
|
||
|
||
str
|
||
</Function>
|
||
|
||
### metrics
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.metrics" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/base_runtime_job.py#L146-L162" signature="metrics()">
|
||
Return job metrics.
|
||
|
||
**Returns**
|
||
|
||
* `timestamps`: Timestamps of when the job was created, started running, and finished.
|
||
|
||
* **`usage`: Details regarding job usage, the measurement of the amount of**
|
||
|
||
time the QPU is locked for your workload.
|
||
|
||
**Return type**
|
||
|
||
A dictionary with job metrics including but not limited to the following
|
||
|
||
**Raises**
|
||
|
||
**IBMRuntimeError** – If a network error occurred.
|
||
</Function>
|
||
|
||
### properties
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.properties" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/base_runtime_job.py#L193-L205" signature="properties(refresh=False)">
|
||
Return the backend properties for this job.
|
||
|
||
**Parameters**
|
||
|
||
**refresh** (*bool*) – If `True`, re-query the server for the backend properties. Otherwise, return a cached version.
|
||
|
||
**Returns**
|
||
|
||
The backend properties used for this job, at the time the job was run, or `None` if properties are not available.
|
||
|
||
**Return type**
|
||
|
||
*BackendProperties* | None
|
||
</Function>
|
||
|
||
### result
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.result" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/runtime_job_v2.py#L113-L146" signature="result(timeout=None, decoder=None)">
|
||
Return the results of the job.
|
||
|
||
**Parameters**
|
||
|
||
* **timeout** (*float | None*) – Number of seconds to wait for job.
|
||
* **decoder** (*Type\[ResultDecoder] | None*) – A `ResultDecoder` subclass used to decode job results.
|
||
|
||
**Returns**
|
||
|
||
Runtime job result.
|
||
|
||
**Raises**
|
||
|
||
* **RuntimeJobFailureError** – If the job failed.
|
||
* **RuntimeJobMaxTimeoutError** – If the job does not complete within given timeout.
|
||
* **RuntimeInvalidStateError** – If the job was cancelled, and attempting to retrieve result.
|
||
|
||
**Return type**
|
||
|
||
*Any*
|
||
</Function>
|
||
|
||
### running
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.running" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/runtime_job_v2.py#L206-L208" signature="running()">
|
||
Return whether the job is actively running.
|
||
|
||
**Return type**
|
||
|
||
bool
|
||
</Function>
|
||
|
||
### status
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.status" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/runtime_job_v2.py#L164-L171" signature="status()">
|
||
Return the status of the job.
|
||
|
||
**Returns**
|
||
|
||
Status of this job.
|
||
|
||
**Return type**
|
||
|
||
*Literal*\[‘INITIALIZING’, ‘QUEUED’, ‘RUNNING’, ‘CANCELLED’, ‘DONE’, ‘ERROR’]
|
||
</Function>
|
||
|
||
### update\_tags
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.update_tags" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/base_runtime_job.py#L164-L191" signature="update_tags(new_tags)">
|
||
Update the tags associated with this job.
|
||
|
||
**Parameters**
|
||
|
||
**new\_tags** (*List\[str]*) – New tags to assign to the job.
|
||
|
||
**Returns**
|
||
|
||
The new tags associated with this job.
|
||
|
||
**Raises**
|
||
|
||
**IBMApiError** – If an unexpected error occurred when communicating with the server or updating the job tags.
|
||
|
||
**Return type**
|
||
|
||
*List*\[str]
|
||
</Function>
|
||
|
||
### usage
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.usage" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/base_runtime_job.py#L138-L144" signature="usage()">
|
||
Return job usage in seconds.
|
||
|
||
**Return type**
|
||
|
||
float
|
||
</Function>
|
||
|
||
### wait\_for\_final\_state
|
||
|
||
<Function id="qiskit_ibm_runtime.RuntimeJobV2.wait_for_final_state" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.34/qiskit_ibm_runtime/runtime_job_v2.py#L231-L257" signature="wait_for_final_state(timeout=None)">
|
||
Poll for the job status from the API until the status is in a final state.
|
||
|
||
**Parameters**
|
||
|
||
**timeout** (*float | None*) – Seconds to wait for the job. If `None`, wait indefinitely.
|
||
|
||
**Raises**
|
||
|
||
**RuntimeJobTimeoutError** – If the job does not complete within given timeout.
|
||
|
||
**Return type**
|
||
|
||
None
|
||
</Function>
|
||
</Class>
|
||
|