View source on GitHub
|
An abstract object representing a quantum program.
This program generally wraps a Circuit with additional metadata.
When combined with an appropriate RunContext, this becomes a
Job that can run on either an Engine service or simulator.
Programs can also be a batch (list of circuits) or calibration
requests.
This is an abstract class that inheritors should implement.
Methods
add_labels
@abc.abstractmethodadd_labels( labels: dict[str, str] ) -> AbstractProgram
Adds new labels to a previously created quantum program.
| Params | |
|---|---|
labels
|
New labels to add to the existing program labels. |
| Returns | |
|---|---|
| This AbstractProgram. |
batch_size
@abc.abstractmethodbatch_size() -> int
Returns the number of programs in a batch program.
| Raises | |
|---|---|
ValueError
|
if the program created was not a batch program. |
create_time
@abc.abstractmethodcreate_time() -> datetime.datetime
Returns when the program was created.
delete
@abc.abstractmethoddelete( delete_jobs: bool = False ) -> None
Deletes a previously created quantum program.
| Params | |
|---|---|
delete_jobs
|
If True will delete all the program's jobs, other this will fail if the program contains any jobs. |
delete_job
@abc.abstractmethoddelete_job( job_id: str ) -> None
Removes a child job from this program.
description
@abc.abstractmethoddescription() -> str
Returns the description of the program.
engine
@abc.abstractmethodengine() -> abstract_engine.AbstractEngine
Returns the parent Engine object.
| Returns | |
|---|---|
| The program's parent Engine. |
get_circuit
@abc.abstractmethodget_circuit() -> cirq.Circuit
Returns the cirq Circuit for the program. This is only supported if the program was created with the V2 protos.
| Returns | |
|---|---|
| The program's cirq Circuit. |
get_job
@abc.abstractmethodget_job( job_id: str ) -> abstract_job.AbstractJob
Returns an AbstractJob for an existing id.
| Args | |
|---|---|
job_id
|
Unique ID of the job within the parent program. |
| Returns | |
|---|---|
| A AbstractJob for this program. |
labels
@abc.abstractmethodlabels() -> dict[str, str]
Returns the labels of the program.
list_jobs
@abc.abstractmethodlist_jobs( created_before: (datetime.datetime | datetime.date | None) = None, created_after: (datetime.datetime | datetime.date | None) = None, has_labels: (dict[str, str] | None) = None, execution_states: (set[quantum.ExecutionStatus.State] | None) = None ) -> Sequence[abstract_job.AbstractJob]
Returns the list of jobs for this program.
| Args | |
|---|---|
project_id
|
A project_id of the parent Google Cloud Project. |
program_id
|
Unique ID of the program within the parent project. |
created_after
|
retrieve jobs that were created after this date or time. |
created_before
|
retrieve jobs that were created after this date or time. |
has_labels
|
retrieve jobs that have labels on them specified by
this dict. If the value is set to *, jobs having the label
regardless of the label value will be returned. For example, to
query programs that have the shape label and have the color
label with value red can be queried using
{'color': 'red', 'shape':'*'} |
execution_states
|
retrieve jobs that have an execution state that
is contained in execution_states. See
quantum.ExecutionStatus.State enum for accepted values.
|
| Returns | |
|---|---|
A sequence of AbstractJob objects that satisfy the constraints.
|
remove_labels
@abc.abstractmethodremove_labels( keys: list[str] ) -> AbstractProgram
Removes labels with given keys from the labels of a previously created quantum program.
| Params | |
|---|---|
label_keys
|
Label keys to remove from the existing program labels. |
| Returns | |
|---|---|
| This AbstractProgram. |
set_description
@abc.abstractmethodset_description( description: str ) -> AbstractProgram
Sets the description of the program.
| Params | |
|---|---|
description
|
The new description for the program. |
| Returns | |
|---|---|
| This AbstractProgram. |
set_labels
@abc.abstractmethodset_labels( labels: dict[str, str] ) -> AbstractProgram
Sets (overwriting) the labels for a previously created quantum program.
| Params | |
|---|---|
labels
|
The entire set of new program labels. |
| Returns | |
|---|---|
| This AbstractProgram. |
update_time
@abc.abstractmethodupdate_time() -> datetime.datetime
Returns when the program was last updated.
View source on GitHub