POVMSamplerJob

class POVMSamplerJob(base_job: BasePrimitiveJob, metadata: list[POVMMetadata])[source]

Bases: BasePrimitiveJob[POVMPubResult, JobStatus]

The job returned by POVMSampler.run().

Initialize the job.

Parameters:
  • base_job (BasePrimitiveJob) – the raw job from which to extract results.

  • metadata (list[POVMMetadata]) – the metadata list associated with the submitted Pubs.

Attributes

base_job: BasePrimitiveJob

The internally submitted job instance.

metadata: list[POVMMetadata]

The metadata list associated with the submitted Pubs.

Methods

cancel()[source]

Attempt to cancel the job.

cancelled() bool[source]

Return whether the job has been cancelled.

Return type:

bool

done() bool[source]

Return whether the job has successfully run.

Return type:

bool

in_final_state() bool[source]

Return whether the job is in a final job state such as DONE or ERROR.

Return type:

bool

classmethod recover_job(filename: str, base_job: BasePrimitiveJob | None = None, *, service: QiskitRuntimeService | None = None) POVMSamplerJob[source]

Recover a POVMSamplerJob instance.

This method can be used to recover a job instance after previously saving its metadata via save_metadata().

Parameters:
  • filename (str) – name of the file where the metadata is stored.

  • base_job (BasePrimitiveJob | None) – the internal qiskit.primitives.BasePrimitiveJob object that was stored inside the original POVMSamplerJob object. If None, the internal job ID stored in the metadata will be used to recover the internal job from the QiskitRuntimeService.

  • service (QiskitRuntimeService | None) – an optional instance of the QiskitRuntimeService. If None, an instance will be generated with no arguments, resulting in it extracting the saved configuration from disk.

Raises:

ValueError – if a base_job is supplied and its ID does not match with the ID stored in the metadata file filename.

Returns:

The recovered POVMSamplerJob instance.

Return type:

POVMSamplerJob

result() PrimitiveResult[POVMPubResult][source]

Return the result of the job.

Returns:

A PrimitiveResult containing a list of POVMPubResult.

Raises:

ValueError – If the number of raw results does not match the number of metadata objects stored in metadata.

Return type:

PrimitiveResult[POVMPubResult]

running() bool[source]

Return whether the job is actively running.

Return type:

bool

save_metadata(filename: str | None = None) None[source]

Save the metadata into a pickle file.

Parameters:

filename (str | None) – name of the file where to store the metadata. If None, the default filename is f"job_metadata_{self.base_job.job_id()}.pkl".

status() JobStatus[source]

Return the status of the job.

Return type:

JobStatus

Inherited Methods

job_id() str

Return a unique id identifying the job.

Return type:

str