ExecutionResult

class ExecutionResult(results=None, job_id=None)[source]

Bases: object

Result container for circuit execution.

This class provides a unified return type for all CircuitRunner.submit_circuits() methods. For synchronous backends, it contains the results directly. For asynchronous backends, it contains the job_id that can be used to fetch results later.

The class is frozen (immutable) to ensure data integrity. Use the with_results() method to create a new instance with results populated from an async ExecutionResult.

Examples

>>> # Synchronous backend
>>> result = ExecutionResult(results=[{"label": "circuit_0", "results": {"00": 100}}])
>>> result.is_async()
False
>>> # Asynchronous backend
>>> result = ExecutionResult(job_id="job-12345")
>>> result.is_async()
True
>>> # After fetching results
>>> result = backend.get_job_results(result)
>>> result.results is not None
True

Attributes Summary

job_id

Job identifier for asynchronous backends.

results

Results for synchronous backends, as a list of dicts each containing "label" (str) and "results" (dict) keys.

Methods Summary

is_async()

Check if this result represents an async job.

with_results(results)

Create a new ExecutionResult with results populated.

Attributes Documentation

job_id: str | None = None

Job identifier for asynchronous backends.

results: list[dict] | None = None

Results for synchronous backends, as a list of dicts each containing "label" (str) and "results" (dict) keys.

Methods Documentation

is_async()[source]

Check if this result represents an async job.

Returns:

True if job_id is not None and results are None (async backend),

False otherwise (sync backend or results already fetched).

Return type:

bool

with_results(results)[source]

Create a new ExecutionResult with results populated.

This method creates a new instance with results set, effectively converting an async ExecutionResult to a completed one.

Parameters:

results (list[dict]) – The job results to populate.

Returns:

A new ExecutionResult instance with results populated

and job_id preserved.

Return type:

ExecutionResult