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
QCloudJob(job_id: str)Parameters
| Parameter | Type | Description |
|---|---|---|
| job_id | str | The unique identifier for the quantum job |
Note: QCloudJob objects are typically returned by QCloudBackend.run() rather than constructed directly.
Methods
job_id
job_id() -> strRetrieves the unique job identifier. Raises a RuntimeError if the job ID is empty.
Returns: The job ID string.
status
status() -> JobStatusRetrieves the current status of the quantum job.
Returns: A JobStatus enumeration value indicating the current state of the job. Possible values are:
| Value | Description |
|---|---|
| WAITING | The job is waiting to be processed |
| COMPUTING | The job is currently being executed |
| FINISHED | The job has completed successfully |
| FAILED | The job has failed |
| QUEUING | The job is in the execution queue |
query
query() -> QCloudResultQueries 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
result() -> QCloudResultRetrieves 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
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
- QCloudResult -- Result object returned by job queries
- QCloudService -- Cloud service for obtaining backends
- JobStatus -- Job status enumeration