Skip to content

QCloudJob

QCloudJob represents a quantum job submitted to the cloud platform. It provides methods for querying the job status and retrieving the execution result.

Signature

python
QCloudJob(job_id: str)

Parameters

ParameterTypeDescription
job_idstrThe unique identifier for the quantum job

Note: QCloudJob objects are typically returned by QCloudBackend.run() rather than constructed directly.

Methods

job_id

python
job_id() -> str

Retrieves the unique job identifier. Raises a RuntimeError if the job ID is empty.

Returns: The job ID string.

status

python
status() -> JobStatus

Retrieves the current status of the quantum job.

Returns: A JobStatus enumeration value indicating the current state of the job. Possible values are:

ValueDescription
WAITINGThe job is waiting to be processed
COMPUTINGThe job is currently being executed
FINISHEDThe job has completed successfully
FAILEDThe job has failed
QUEUINGThe job is in the execution queue

query

python
query() -> QCloudResult

Queries the cloud service for the latest information about this job, including its current status and any available results.

Returns: A QCloudResult object containing the query response.

result

python
result() -> QCloudResult

Retrieves the result of the quantum job. This method blocks until the job is complete and returns the final execution result.

Returns: A QCloudResult object containing the job execution results.

Examples

python
from pyqpanda3.qcloud import QCloudService
from pyqpanda3.core import QCircuit, H, measure

service = QCloudService(api_key="your_api_key")
backend = service.backend("origin_simulation")

circuit = QCircuit(2)
circuit << H(0)
prog = QProg()
prog << circuit << measure([0], [0])

# Submit the job
job = backend.run(prog, shots=1000)

# Check the job ID
print(f"Job ID: {job.job_id()}")

# Poll for status
from pyqpanda3.qcloud import JobStatus
status = job.status()
print(f"Status: {status}")

# Retrieve the result (blocks until complete)
result = job.result()
probs = result.get_probs()
print(f"Probabilities: {probs}")

See Also

Released under the MIT License.