azure-quantum 1.1.2.dev0__py3-none-any.whl → 1.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- azure/quantum/_client/_version.py +1 -1
- azure/quantum/_workspace_connection_params.py +1 -0
- azure/quantum/job/__init__.py +4 -2
- azure/quantum/job/job.py +5 -2
- azure/quantum/job/job_failed_with_results_error.py +12 -4
- azure/quantum/qiskit/__init__.py +2 -1
- azure/quantum/qiskit/backends/__init__.py +6 -0
- azure/quantum/qiskit/backends/backend.py +2 -1
- azure/quantum/qiskit/backends/quantinuum.py +3 -2
- azure/quantum/qiskit/provider.py +14 -12
- azure/quantum/target/microsoft/elements/dft/job.py +4 -2
- azure/quantum/target/pasqal/result.py +4 -4
- azure/quantum/target/pasqal/target.py +26 -1
- azure/quantum/target/rigetti/result.py +15 -10
- azure/quantum/target/rigetti/target.py +19 -0
- azure/quantum/target/target.py +1 -1
- azure/quantum/version.py +1 -1
- azure/quantum/workspace.py +286 -111
- {azure_quantum-1.1.2.dev0.dist-info → azure_quantum-1.2.1.dist-info}/METADATA +6 -6
- {azure_quantum-1.1.2.dev0.dist-info → azure_quantum-1.2.1.dist-info}/RECORD +22 -22
- {azure_quantum-1.1.2.dev0.dist-info → azure_quantum-1.2.1.dist-info}/WHEEL +0 -0
- {azure_quantum-1.1.2.dev0.dist-info → azure_quantum-1.2.1.dist-info}/top_level.txt +0 -0
azure/quantum/job/__init__.py
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
from azure.quantum._client.models import JobDetails
|
|
9
9
|
from .base_job import BaseJob
|
|
10
10
|
from .filtered_job import FilteredJob
|
|
11
|
-
from .job import Job
|
|
11
|
+
from .job import Job, ContentType
|
|
12
12
|
from .job_failed_with_results_error import JobFailedWithResultsError
|
|
13
13
|
from .workspace_item import WorkspaceItem
|
|
14
14
|
from .workspace_item_factory import WorkspaceItemFactory
|
|
@@ -17,6 +17,7 @@ from .session import Session, SessionHost, SessionDetails, SessionStatus, Sessio
|
|
|
17
17
|
__all__ = [
|
|
18
18
|
"Job",
|
|
19
19
|
"JobDetails",
|
|
20
|
+
"ContentType",
|
|
20
21
|
"BaseJob",
|
|
21
22
|
"FilteredJob",
|
|
22
23
|
"WorkspaceItem",
|
|
@@ -24,5 +25,6 @@ __all__ = [
|
|
|
24
25
|
"SessionHost",
|
|
25
26
|
"SessionDetails",
|
|
26
27
|
"SessionStatus",
|
|
27
|
-
"SessionJobFailurePolicy"
|
|
28
|
+
"SessionJobFailurePolicy",
|
|
29
|
+
"JobFailedWithResultsError"
|
|
28
30
|
]
|
azure/quantum/job/job.py
CHANGED
|
@@ -105,13 +105,16 @@ class Job(BaseJob, FilteredJob):
|
|
|
105
105
|
def get_results(self, timeout_secs: float = DEFAULT_TIMEOUT):
|
|
106
106
|
"""Get job results by downloading the results blob from the
|
|
107
107
|
storage container linked via the workspace.
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
Raises :class:`RuntimeError` if job execution fails.
|
|
110
|
+
|
|
111
|
+
Raises :class:`azure.quantum.job.JobFailedWithResultsError` if job execution fails,
|
|
112
|
+
but failure results could still be retrieved (e.g. for jobs submitted against "microsoft.dft" target).
|
|
110
113
|
|
|
111
114
|
:param timeout_secs: Timeout in seconds, defaults to 300
|
|
112
115
|
:type timeout_secs: float
|
|
113
116
|
:return: Results dictionary with histogram shots, or raw results if not a json object.
|
|
114
|
-
:rtype: Any
|
|
117
|
+
:rtype: typing.Any
|
|
115
118
|
"""
|
|
116
119
|
if self.results is not None:
|
|
117
120
|
return self.results
|
|
@@ -2,14 +2,22 @@ import json
|
|
|
2
2
|
from typing import Any, Dict, Union
|
|
3
3
|
|
|
4
4
|
class JobFailedWithResultsError(RuntimeError):
|
|
5
|
-
"""
|
|
6
|
-
Error produced when Job completes with status "Failed" and the Job
|
|
5
|
+
"""Error produced when Job completes with status "Failed" and the Job
|
|
7
6
|
supports producing failure results.
|
|
8
7
|
|
|
9
|
-
The failure results can be accessed with get_failure_results() method
|
|
8
|
+
The failure results can be accessed with get_failure_results() method.
|
|
10
9
|
"""
|
|
11
|
-
|
|
10
|
+
|
|
12
11
|
def __init__(self, message: str, failure_results: Any, *args: object) -> None:
|
|
12
|
+
"""Initializes error produced when Job completes with status "Failed" and the Job
|
|
13
|
+
supports producing failure results.
|
|
14
|
+
|
|
15
|
+
:param message: Error message.
|
|
16
|
+
:type message: str
|
|
17
|
+
:param failure_results: Failure results produced by the job.
|
|
18
|
+
:type failure_results: Any
|
|
19
|
+
"""
|
|
20
|
+
|
|
13
21
|
self._set_error_details(message, failure_results)
|
|
14
22
|
super().__init__(message, *args)
|
|
15
23
|
|
azure/quantum/qiskit/__init__.py
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
"""Azure Quantum Qiskit Provider"""
|
|
7
7
|
|
|
8
|
-
from .provider import AzureQuantumProvider
|
|
8
|
+
from .provider import AzureQuantumProvider, AzureQuantumJob
|
|
9
9
|
from azure.quantum import __version__
|
|
10
10
|
|
|
11
11
|
__all__ = [
|
|
12
12
|
"AzureQuantumProvider",
|
|
13
|
+
"AzureQuantumJob",
|
|
13
14
|
"__version__"
|
|
14
15
|
]
|
|
@@ -129,6 +129,7 @@ class AzureBackendBase(Backend, SessionHost):
|
|
|
129
129
|
if self._can_send_shots_input_param():
|
|
130
130
|
options_shots = options.pop(self.__class__._SHOTS_PARAM_NAME, None)
|
|
131
131
|
|
|
132
|
+
final_shots = None
|
|
132
133
|
# First we check for the explicitly specified 'shots' parameter, then for a provider-specific
|
|
133
134
|
# field in options, then for a backend's default value.
|
|
134
135
|
|
|
@@ -142,7 +143,7 @@ class AzureBackendBase(Backend, SessionHost):
|
|
|
142
143
|
|
|
143
144
|
elif shots is not None:
|
|
144
145
|
final_shots = shots
|
|
145
|
-
|
|
146
|
+
elif options_shots is not None:
|
|
146
147
|
warnings.warn(
|
|
147
148
|
f"Parameter '{self.__class__._SHOTS_PARAM_NAME}' is subject to change in future versions. "
|
|
148
149
|
"Please, use 'shots' parameter instead."
|
|
@@ -14,6 +14,7 @@ from qiskit import QuantumCircuit
|
|
|
14
14
|
from qiskit.providers.models import BackendConfiguration
|
|
15
15
|
from qiskit.providers import Options
|
|
16
16
|
from qiskit.providers import Provider
|
|
17
|
+
from qiskit.qasm2 import dumps
|
|
17
18
|
|
|
18
19
|
import logging
|
|
19
20
|
|
|
@@ -243,7 +244,7 @@ class QuantinuumBackend(AzureBackend):
|
|
|
243
244
|
|
|
244
245
|
def _translate_input(self, circuit):
|
|
245
246
|
"""Translates the input values to the format expected by the AzureBackend."""
|
|
246
|
-
return circuit
|
|
247
|
+
return dumps(circuit)
|
|
247
248
|
|
|
248
249
|
def estimate_cost(
|
|
249
250
|
self, circuit: QuantumCircuit, shots: int = None, count: int = None
|
|
@@ -267,7 +268,7 @@ class QuantinuumBackend(AzureBackend):
|
|
|
267
268
|
if shots is None:
|
|
268
269
|
raise ValueError("Missing input argument 'shots'.")
|
|
269
270
|
|
|
270
|
-
input_data = circuit
|
|
271
|
+
input_data = dumps(circuit)
|
|
271
272
|
workspace = self.provider().get_workspace()
|
|
272
273
|
target = workspace.get_targets(self.name())
|
|
273
274
|
return target.estimate_cost(input_data, shots=shots)
|
azure/quantum/qiskit/provider.py
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import warnings
|
|
7
7
|
import inspect
|
|
8
8
|
from itertools import groupby
|
|
9
|
-
from typing import Dict, List, Tuple, Type
|
|
9
|
+
from typing import Dict, List, Optional, Tuple, Type
|
|
10
10
|
from azure.quantum import Workspace
|
|
11
11
|
|
|
12
12
|
try:
|
|
@@ -24,17 +24,13 @@ from azure.quantum.qiskit.backends.backend import AzureBackendBase
|
|
|
24
24
|
from azure.quantum.qiskit.job import AzureQuantumJob
|
|
25
25
|
from azure.quantum.qiskit.backends import *
|
|
26
26
|
|
|
27
|
-
|
|
28
27
|
QISKIT_USER_AGENT = "azure-quantum-qiskit"
|
|
29
28
|
|
|
30
|
-
|
|
31
29
|
class AzureQuantumProvider(Provider):
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def __init__(self, workspace: Workspace=None, **kwargs):
|
|
37
|
-
"""AzureQuantumService class
|
|
30
|
+
|
|
31
|
+
def __init__(self, workspace: Optional[Workspace]=None, **kwargs):
|
|
32
|
+
"""Class for interfacing with the Azure Quantum service
|
|
33
|
+
using Qiskit quantum circuits.
|
|
38
34
|
|
|
39
35
|
:param workspace: Azure Quantum workspace. If missing it will create a new Workspace passing `kwargs` to the constructor. Defaults to None.
|
|
40
36
|
:type workspace: Workspace
|
|
@@ -66,7 +62,7 @@ class AzureQuantumProvider(Provider):
|
|
|
66
62
|
name (str): name of the backend.
|
|
67
63
|
**kwargs: dict used for filtering.
|
|
68
64
|
Returns:
|
|
69
|
-
|
|
65
|
+
azure.quantum.qiskit.backends.AzureBackendBase: a backend matching the filtering.
|
|
70
66
|
Raises:
|
|
71
67
|
QiskitBackendNotFoundError: if no backend could be found or
|
|
72
68
|
more than one backend matches the filtering criteria.
|
|
@@ -110,7 +106,7 @@ see https://aka.ms/AQ/Docs/AddProvider"
|
|
|
110
106
|
name (str): name of the backend.
|
|
111
107
|
**kwargs: dict used for filtering.
|
|
112
108
|
Returns:
|
|
113
|
-
typing.List[qiskit.
|
|
109
|
+
typing.List[azure.quantum.qiskit.backends.AzureBackendBase]: a list of Backends that match the filtering
|
|
114
110
|
criteria.
|
|
115
111
|
"""
|
|
116
112
|
|
|
@@ -143,7 +139,13 @@ see https://aka.ms/AQ/Docs/AddProvider"
|
|
|
143
139
|
return backends
|
|
144
140
|
|
|
145
141
|
def get_job(self, job_id) -> AzureQuantumJob:
|
|
146
|
-
"""Returns the Job instance associated with the given id.
|
|
142
|
+
"""Returns the Job instance associated with the given id.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
job_id (str): Id of the Job to return.
|
|
146
|
+
Returns:
|
|
147
|
+
AzureQuantumJob: Job instance.
|
|
148
|
+
"""
|
|
147
149
|
azure_job = self._workspace.get_job(job_id)
|
|
148
150
|
backend = self.get_backend(azure_job.details.target)
|
|
149
151
|
return AzureQuantumJob(backend, azure_job)
|
|
@@ -27,8 +27,10 @@ class MicrosoftElementsDftJob(Job):
|
|
|
27
27
|
|
|
28
28
|
:param timeout_secs: Timeout in seconds, defaults to 300
|
|
29
29
|
:type timeout_secs: float
|
|
30
|
-
:raises: :class:`RuntimeError`
|
|
31
|
-
:
|
|
30
|
+
:raises: :class:`RuntimeError` if job execution failed.
|
|
31
|
+
:raises: :class:`azure.quantum.job.JobFailedWithResultsError` if job execution failed,
|
|
32
|
+
but failure results could still be retrieved.
|
|
33
|
+
:return: Results dictionary.
|
|
32
34
|
"""
|
|
33
35
|
|
|
34
36
|
try:
|
|
@@ -26,16 +26,16 @@ class Result:
|
|
|
26
26
|
job = Job(...) # This job should come from a Pasqal target
|
|
27
27
|
job.wait_until_completed()
|
|
28
28
|
result = Result(job)
|
|
29
|
-
|
|
30
29
|
"""
|
|
31
30
|
|
|
32
31
|
def __init__(self, job: Job) -> None:
|
|
33
32
|
"""
|
|
34
33
|
Decode the results of a Job with output type of "pasqal.pulser-results.v1"
|
|
35
34
|
|
|
36
|
-
:
|
|
37
|
-
|
|
38
|
-
:
|
|
35
|
+
Args:
|
|
36
|
+
job (Job): Azure Quantum job
|
|
37
|
+
Raises:
|
|
38
|
+
RuntimeError: if the job has not completed successfully
|
|
39
39
|
"""
|
|
40
40
|
|
|
41
41
|
if job.details.status != "Succeeded":
|
|
@@ -25,6 +25,8 @@ class PasqalTarget(str, Enum):
|
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
27
|
SIM_EMU_TN = "pasqal.sim.emu-tn"
|
|
28
|
+
"""pasqal.sim.emu-tn target"""
|
|
29
|
+
|
|
28
30
|
QPU_FRESNEL = "pasqal.qpu.fresnel"
|
|
29
31
|
"""A simulator target for Quil. See https://github.com/quil-lang/qvm for more info."""
|
|
30
32
|
|
|
@@ -52,7 +54,11 @@ class PasqalTarget(str, Enum):
|
|
|
52
54
|
|
|
53
55
|
@dataclass
|
|
54
56
|
class InputParams:
|
|
55
|
-
"""Input parameters
|
|
57
|
+
"""Input parameters
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
runs (int): The number of times to run the experiment.
|
|
61
|
+
"""
|
|
56
62
|
|
|
57
63
|
runs: int = 1
|
|
58
64
|
"""The number of times to run the experiment."""
|
|
@@ -79,6 +85,25 @@ class Pasqal(Target):
|
|
|
79
85
|
encoding: str = "",
|
|
80
86
|
**kwargs,
|
|
81
87
|
):
|
|
88
|
+
"""
|
|
89
|
+
Initializes a new target.
|
|
90
|
+
|
|
91
|
+
:param workspace: Associated workspace
|
|
92
|
+
:type workspace: Workspace
|
|
93
|
+
:param name: Target name
|
|
94
|
+
:type name: str
|
|
95
|
+
:param input_data_format: Format of input data (ex. "pasqal.pulser.v1")
|
|
96
|
+
:type input_data_format: str
|
|
97
|
+
:param output_data_format: Format of output data (ex. "pasqal.pulser-results.v1")
|
|
98
|
+
:type output_data_format: str
|
|
99
|
+
:param capability: QIR capability
|
|
100
|
+
:type capability: str
|
|
101
|
+
:param provider_id: Id of provider (ex. "pasqal")
|
|
102
|
+
:type provider_id: str
|
|
103
|
+
:param encoding: "Content-Encoding" attribute value to set on input blob (ex. "gzip")
|
|
104
|
+
:type encoding: str
|
|
105
|
+
"""
|
|
106
|
+
|
|
82
107
|
super().__init__(
|
|
83
108
|
workspace=workspace,
|
|
84
109
|
name=name,
|
|
@@ -21,22 +21,26 @@ RawData = Union[int, float, List[float]]
|
|
|
21
21
|
class Result:
|
|
22
22
|
"""Downloads the data of a completed Job and extracts the ``Readout`` for each register.
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
.. highlight:: python
|
|
25
|
+
.. code-block::
|
|
26
|
+
|
|
27
|
+
from azure.quantum.job import Job
|
|
28
|
+
from azure.quantum.target.rigetti import Result
|
|
29
|
+
job = Job(...) # This job should come from a Rigetti target
|
|
30
|
+
job.wait_until_completed()
|
|
31
|
+
result = Result(job)
|
|
32
|
+
ro_data = result["ro"]
|
|
33
|
+
first_shot_data = ro_data[0]
|
|
31
34
|
"""
|
|
32
35
|
|
|
33
36
|
def __init__(self, job: Job) -> None:
|
|
34
37
|
"""
|
|
35
38
|
Decode the results of a Job with output type of "rigetti.quil-results.v1"
|
|
36
39
|
|
|
37
|
-
:
|
|
38
|
-
|
|
39
|
-
:
|
|
40
|
+
Args:
|
|
41
|
+
job (Job): Azure Quantum job
|
|
42
|
+
Raises:
|
|
43
|
+
RuntimeError: if the job has not completed successfully
|
|
40
44
|
"""
|
|
41
45
|
|
|
42
46
|
if job.details.status != "Succeeded":
|
|
@@ -53,6 +57,7 @@ class Result:
|
|
|
53
57
|
|
|
54
58
|
|
|
55
59
|
T = TypeVar("T", bound=Union[int, float, complex])
|
|
60
|
+
|
|
56
61
|
Readout = List[List[T]]
|
|
57
62
|
"""Contains the data of a declared "readout" memory region, usually the ``ro`` register.
|
|
58
63
|
|
|
@@ -146,6 +146,25 @@ class Rigetti(Target):
|
|
|
146
146
|
encoding: str = "",
|
|
147
147
|
**kwargs,
|
|
148
148
|
):
|
|
149
|
+
"""
|
|
150
|
+
Initializes a new target.
|
|
151
|
+
|
|
152
|
+
:param workspace: Associated workspace
|
|
153
|
+
:type workspace: Workspace
|
|
154
|
+
:param name: Target name
|
|
155
|
+
:type name: str
|
|
156
|
+
:param input_data_format: Format of input data (ex. "rigetti.quil.v1")
|
|
157
|
+
:type input_data_format: str
|
|
158
|
+
:param output_data_format: Format of output data (ex. "rigetti.quil-results.v1")
|
|
159
|
+
:type output_data_format: str
|
|
160
|
+
:param capability: QIR capability
|
|
161
|
+
:type capability: str
|
|
162
|
+
:param provider_id: Id of provider (ex. "rigetti")
|
|
163
|
+
:type provider_id: str
|
|
164
|
+
:param encoding: "Content-Encoding" attribute value to set on input blob (ex. "gzip")
|
|
165
|
+
:type encoding: str
|
|
166
|
+
"""
|
|
167
|
+
|
|
149
168
|
super().__init__(
|
|
150
169
|
workspace=workspace,
|
|
151
170
|
name=name,
|
azure/quantum/target/target.py
CHANGED
|
@@ -77,7 +77,7 @@ class Target(abc.ABC, SessionHost):
|
|
|
77
77
|
:param provider_id: Id of provider (ex. "microsoft-qc")
|
|
78
78
|
:type provider_id: str
|
|
79
79
|
:param content_type: "Content-Type" attribute value to set on input blob (ex. "application/json")
|
|
80
|
-
:type content_type: ContentType
|
|
80
|
+
:type content_type: azure.quantum.job.ContentType
|
|
81
81
|
:param encoding: "Content-Encoding" attribute value to set on input blob (ex. "gzip")
|
|
82
82
|
:type encoding: str
|
|
83
83
|
:param average_queue_time: Set average queue time (for internal use)
|
azure/quantum/version.py
CHANGED
azure/quantum/workspace.py
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
# Licensed under the MIT License.
|
|
4
4
|
##
|
|
5
|
+
"""
|
|
6
|
+
Module providing the Workspace class, used to connect to
|
|
7
|
+
an Azure Quantum Workspace.
|
|
8
|
+
"""
|
|
5
9
|
|
|
6
10
|
from __future__ import annotations
|
|
7
11
|
from datetime import datetime
|
|
@@ -14,8 +18,8 @@ from typing import (
|
|
|
14
18
|
Optional,
|
|
15
19
|
TYPE_CHECKING,
|
|
16
20
|
Tuple,
|
|
17
|
-
Union
|
|
18
|
-
|
|
21
|
+
Union,
|
|
22
|
+
)
|
|
19
23
|
from azure.quantum._client import QuantumClient
|
|
20
24
|
from azure.quantum._client.operations import (
|
|
21
25
|
JobsOperations,
|
|
@@ -24,8 +28,13 @@ from azure.quantum._client.operations import (
|
|
|
24
28
|
SessionsOperations,
|
|
25
29
|
TopLevelItemsOperations
|
|
26
30
|
)
|
|
27
|
-
from azure.quantum._client.models import
|
|
28
|
-
|
|
31
|
+
from azure.quantum._client.models import (
|
|
32
|
+
BlobDetails,
|
|
33
|
+
JobStatus,
|
|
34
|
+
TargetStatus,
|
|
35
|
+
)
|
|
36
|
+
from azure.quantum import Job, Session
|
|
37
|
+
from azure.quantum.job.workspace_item_factory import WorkspaceItemFactory
|
|
29
38
|
from azure.quantum._workspace_connection_params import (
|
|
30
39
|
WorkspaceConnectionParams
|
|
31
40
|
)
|
|
@@ -37,30 +46,28 @@ from azure.quantum.storage import (
|
|
|
37
46
|
get_container_uri,
|
|
38
47
|
ContainerClient
|
|
39
48
|
)
|
|
40
|
-
|
|
41
49
|
if TYPE_CHECKING:
|
|
42
|
-
from azure.quantum._client.models import TargetStatus
|
|
43
50
|
from azure.quantum.target import Target
|
|
44
51
|
|
|
52
|
+
|
|
45
53
|
logger = logging.getLogger(__name__)
|
|
46
54
|
|
|
47
55
|
__all__ = ["Workspace"]
|
|
48
56
|
|
|
49
|
-
|
|
57
|
+
# pylint: disable=line-too-long
|
|
58
|
+
# pylint: disable=too-many-public-methods
|
|
50
59
|
class Workspace:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"""Represents an Azure Quantum workspace.
|
|
60
|
+
"""
|
|
61
|
+
Represents an Azure Quantum workspace.
|
|
54
62
|
|
|
55
63
|
When creating a Workspace object, callers have two options for
|
|
56
64
|
identifying the Azure Quantum workspace (in order of precedence):
|
|
57
65
|
1. specify a valid location and resource ID; or
|
|
58
|
-
2. specify a valid location, subscription ID,
|
|
59
|
-
resource group, and workspace name.
|
|
66
|
+
2. specify a valid location, subscription ID, resource group, and workspace name.
|
|
60
67
|
|
|
61
68
|
You can also use a connection string to specify the connection parameters
|
|
62
|
-
to
|
|
63
|
-
|
|
69
|
+
to an Azure Quantum Workspace by calling
|
|
70
|
+
:obj:`~ Workspace.from_connection_string() <Workspace.from_connection_string>`.
|
|
64
71
|
|
|
65
72
|
If the Azure Quantum workspace does not have linked storage, the caller
|
|
66
73
|
must also pass a valid Azure storage account connection string.
|
|
@@ -92,13 +99,14 @@ class Workspace:
|
|
|
92
99
|
|
|
93
100
|
:param credential:
|
|
94
101
|
The credential to use to connect to Azure services.
|
|
95
|
-
Normally one of the credential types from Azure.Identity
|
|
102
|
+
Normally one of the credential types from [Azure.Identity](https://learn.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#credential-classes).
|
|
96
103
|
|
|
97
104
|
Defaults to \"DefaultAzureCredential\", which will attempt multiple
|
|
98
105
|
forms of authentication.
|
|
99
106
|
|
|
100
107
|
:param user_agent:
|
|
101
|
-
Add the specified value as a prefix to the HTTP User-Agent header
|
|
108
|
+
Add the specified value as a prefix to the HTTP User-Agent header
|
|
109
|
+
when communicating to the Azure Quantum service.
|
|
102
110
|
"""
|
|
103
111
|
def __init__(
|
|
104
112
|
self,
|
|
@@ -111,7 +119,7 @@ class Workspace:
|
|
|
111
119
|
credential: Optional[object] = None,
|
|
112
120
|
user_agent: Optional[str] = None,
|
|
113
121
|
**kwargs: Any,
|
|
114
|
-
):
|
|
122
|
+
) -> None:
|
|
115
123
|
connection_params = WorkspaceConnectionParams(
|
|
116
124
|
location=location,
|
|
117
125
|
subscription_id=subscription_id,
|
|
@@ -122,12 +130,12 @@ class Workspace:
|
|
|
122
130
|
user_agent=user_agent,
|
|
123
131
|
**kwargs
|
|
124
132
|
).default_from_env_vars()
|
|
125
|
-
|
|
133
|
+
|
|
126
134
|
logger.info("Using %s environment.", connection_params.environment)
|
|
127
135
|
|
|
128
136
|
connection_params.assert_complete()
|
|
129
137
|
|
|
130
|
-
connection_params.on_new_client_request = self.
|
|
138
|
+
connection_params.on_new_client_request = self._on_new_client_request
|
|
131
139
|
|
|
132
140
|
self._connection_params = connection_params
|
|
133
141
|
self._storage = storage
|
|
@@ -135,34 +143,83 @@ class Workspace:
|
|
|
135
143
|
# Create QuantumClient
|
|
136
144
|
self._client = self._create_client()
|
|
137
145
|
|
|
138
|
-
def
|
|
146
|
+
def _on_new_client_request(self) -> None:
|
|
147
|
+
"""
|
|
148
|
+
An internal callback method used by the WorkspaceConnectionParams
|
|
149
|
+
to ask the Workspace to recreate the underlying Azure SDK REST API client.
|
|
150
|
+
This is used when some value (such as the UserAgent) has changed
|
|
151
|
+
in the WorkspaceConnectionParams and requires the client to be
|
|
152
|
+
recreated.
|
|
153
|
+
"""
|
|
139
154
|
self._client = self._create_client()
|
|
140
155
|
|
|
141
156
|
@property
|
|
142
|
-
def location(self):
|
|
157
|
+
def location(self) -> str:
|
|
158
|
+
"""
|
|
159
|
+
Returns the Azure location of the Quantum Workspace.
|
|
160
|
+
|
|
161
|
+
:return: Azure location name.
|
|
162
|
+
:rtype: str
|
|
163
|
+
"""
|
|
143
164
|
return self._connection_params.location
|
|
144
165
|
|
|
145
166
|
@property
|
|
146
|
-
def subscription_id(self):
|
|
167
|
+
def subscription_id(self) -> str:
|
|
168
|
+
"""
|
|
169
|
+
Returns the Azure Subscription ID of the Quantum Workspace.
|
|
170
|
+
|
|
171
|
+
:return: Azure Subscription ID.
|
|
172
|
+
:rtype: str
|
|
173
|
+
"""
|
|
147
174
|
return self._connection_params.subscription_id
|
|
148
175
|
|
|
149
176
|
@property
|
|
150
|
-
def resource_group(self):
|
|
177
|
+
def resource_group(self) -> str:
|
|
178
|
+
"""
|
|
179
|
+
Returns the Azure Resource Group of the Quantum Workspace.
|
|
180
|
+
|
|
181
|
+
:return: Azure Resource Group name.
|
|
182
|
+
:rtype: str
|
|
183
|
+
"""
|
|
151
184
|
return self._connection_params.resource_group
|
|
152
185
|
|
|
153
186
|
@property
|
|
154
|
-
def name(self):
|
|
187
|
+
def name(self) -> str:
|
|
188
|
+
"""
|
|
189
|
+
Returns the Name of the Quantum Workspace.
|
|
190
|
+
|
|
191
|
+
:return: Azure Quantum Workspace name.
|
|
192
|
+
:rtype: str
|
|
193
|
+
"""
|
|
155
194
|
return self._connection_params.workspace_name
|
|
156
195
|
|
|
157
196
|
@property
|
|
158
|
-
def credential(self):
|
|
197
|
+
def credential(self) -> Any:
|
|
198
|
+
"""
|
|
199
|
+
Returns the Credential used to connect to the Quantum Workspace.
|
|
200
|
+
|
|
201
|
+
:return: Azure SDK Credential from [Azure.Identity](https://learn.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#credential-classes).
|
|
202
|
+
:rtype: typing.Any
|
|
203
|
+
"""
|
|
159
204
|
return self._connection_params.credential
|
|
160
205
|
|
|
161
206
|
@property
|
|
162
|
-
def storage(self):
|
|
207
|
+
def storage(self) -> str:
|
|
208
|
+
"""
|
|
209
|
+
Returns the Azure Storage account name associated with the Quantum Workspace.
|
|
210
|
+
|
|
211
|
+
:return: Azure Storage account name.
|
|
212
|
+
:rtype: str
|
|
213
|
+
"""
|
|
163
214
|
return self._storage
|
|
164
215
|
|
|
165
216
|
def _create_client(self) -> QuantumClient:
|
|
217
|
+
""""
|
|
218
|
+
An internal method to (re)create the underlying Azure SDK REST API client.
|
|
219
|
+
|
|
220
|
+
:return: Azure SDK REST API client for Azure Quantum.
|
|
221
|
+
:rtype: QuantumClient
|
|
222
|
+
"""
|
|
166
223
|
connection_params = self._connection_params
|
|
167
224
|
kwargs = {}
|
|
168
225
|
if connection_params.api_version:
|
|
@@ -182,19 +239,23 @@ class Workspace:
|
|
|
182
239
|
return client
|
|
183
240
|
|
|
184
241
|
@property
|
|
185
|
-
def user_agent(self):
|
|
242
|
+
def user_agent(self) -> str:
|
|
186
243
|
"""
|
|
187
|
-
|
|
188
|
-
the service via the header.
|
|
244
|
+
Returns the Workspace's UserAgent string that is sent to
|
|
245
|
+
the service via the UserAgent header.
|
|
246
|
+
|
|
247
|
+
:return: User Agent string.
|
|
248
|
+
:rtype: str
|
|
189
249
|
"""
|
|
190
250
|
return self._connection_params.get_full_user_agent()
|
|
191
251
|
|
|
192
|
-
def append_user_agent(self, value: str):
|
|
252
|
+
def append_user_agent(self, value: str) -> None:
|
|
193
253
|
"""
|
|
194
|
-
Append a new value to the Workspace's UserAgent
|
|
195
|
-
|
|
254
|
+
Append a new value to the Workspace's UserAgent.
|
|
255
|
+
The values are appended using a dash.
|
|
196
256
|
|
|
197
|
-
:param value:
|
|
257
|
+
:param value:
|
|
258
|
+
UserAgent value to add, e.g. "azure-quantum-<plugin>"
|
|
198
259
|
"""
|
|
199
260
|
self._connection_params.append_user_agent(value=value)
|
|
200
261
|
|
|
@@ -202,6 +263,13 @@ class Workspace:
|
|
|
202
263
|
def from_connection_string(cls, connection_string: str, **kwargs) -> Workspace:
|
|
203
264
|
"""
|
|
204
265
|
Creates a new Azure Quantum Workspace client from a connection string.
|
|
266
|
+
|
|
267
|
+
:param connection_string:
|
|
268
|
+
A valid connection string, usually obtained from the
|
|
269
|
+
`Quantum Workspace -> Operations -> Access Keys` blade in the Azure Portal.
|
|
270
|
+
|
|
271
|
+
:return: New Azure Quantum Workspace client.
|
|
272
|
+
:rtype: Workspace
|
|
205
273
|
"""
|
|
206
274
|
connection_params = WorkspaceConnectionParams(connection_string=connection_string)
|
|
207
275
|
return cls(
|
|
@@ -213,25 +281,72 @@ class Workspace:
|
|
|
213
281
|
**kwargs)
|
|
214
282
|
|
|
215
283
|
def _get_top_level_items_client(self) -> TopLevelItemsOperations:
|
|
284
|
+
"""
|
|
285
|
+
Returns the internal Azure SDK REST API client
|
|
286
|
+
for the `{workspace}/topLevelItems` API.
|
|
287
|
+
|
|
288
|
+
:return: REST API client for the `topLevelItems` API.
|
|
289
|
+
:rtype: TopLevelItemsOperations
|
|
290
|
+
"""
|
|
216
291
|
return self._client.top_level_items
|
|
217
292
|
|
|
218
293
|
def _get_sessions_client(self) -> SessionsOperations:
|
|
294
|
+
"""
|
|
295
|
+
Returns the internal Azure SDK REST API client
|
|
296
|
+
for the `{workspace}/sessions` API.
|
|
297
|
+
|
|
298
|
+
:return: REST API client for the `sessions` API.
|
|
299
|
+
:rtype: SessionsOperations
|
|
300
|
+
"""
|
|
219
301
|
return self._client.sessions
|
|
220
302
|
|
|
221
303
|
def _get_jobs_client(self) -> JobsOperations:
|
|
304
|
+
"""
|
|
305
|
+
Returns the internal Azure SDK REST API client
|
|
306
|
+
for the `{workspace}/jobs` API.
|
|
307
|
+
|
|
308
|
+
:return: REST API client for the `jobs` API.
|
|
309
|
+
:rtype: JobsOperations
|
|
310
|
+
"""
|
|
222
311
|
return self._client.jobs
|
|
223
312
|
|
|
224
313
|
def _get_workspace_storage_client(self) -> StorageOperations:
|
|
314
|
+
"""
|
|
315
|
+
Returns the internal Azure SDK REST API client
|
|
316
|
+
for the `{workspace}/storage` API.
|
|
317
|
+
|
|
318
|
+
:return: REST API client for the `storage` API.
|
|
319
|
+
:rtype: StorageOperations
|
|
320
|
+
"""
|
|
225
321
|
return self._client.storage
|
|
226
322
|
|
|
227
323
|
def _get_quotas_client(self) -> QuotasOperations:
|
|
324
|
+
"""
|
|
325
|
+
Returns the internal Azure SDK REST API client
|
|
326
|
+
for the `{workspace}/quotas` API.
|
|
327
|
+
|
|
328
|
+
:return: REST API client for the `quotas` API.
|
|
329
|
+
:rtype: QuotasOperations
|
|
330
|
+
"""
|
|
228
331
|
return self._client.quotas
|
|
229
332
|
|
|
230
333
|
def _get_linked_storage_sas_uri(
|
|
231
|
-
self,
|
|
334
|
+
self,
|
|
335
|
+
container_name: str,
|
|
336
|
+
blob_name: Optional[str] = None
|
|
232
337
|
) -> str:
|
|
233
338
|
"""
|
|
234
|
-
Calls the service and returns a container
|
|
339
|
+
Calls the service and returns a container/blob SAS URL
|
|
340
|
+
for the Storage associated with the Quantum Workspace.
|
|
341
|
+
|
|
342
|
+
:param container_name:
|
|
343
|
+
The name of the storage container.
|
|
344
|
+
|
|
345
|
+
:param blob_name:
|
|
346
|
+
Optional name of the blob. Defaults to `None`.
|
|
347
|
+
|
|
348
|
+
:return: Storage Account SAS URL to a container or blob.
|
|
349
|
+
:rtype: str
|
|
235
350
|
"""
|
|
236
351
|
client = self._get_workspace_storage_client()
|
|
237
352
|
blob_details = BlobDetails(
|
|
@@ -239,15 +354,18 @@ class Workspace:
|
|
|
239
354
|
)
|
|
240
355
|
container_uri = client.sas_uri(blob_details=blob_details)
|
|
241
356
|
|
|
242
|
-
logger.debug(
|
|
357
|
+
logger.debug("Container URI from service: %s", container_uri)
|
|
243
358
|
return container_uri.sas_uri
|
|
244
359
|
|
|
245
360
|
def submit_job(self, job: Job) -> Job:
|
|
246
361
|
"""
|
|
247
|
-
|
|
362
|
+
Submits a job to be processed in the Workspace.
|
|
363
|
+
|
|
364
|
+
:param job:
|
|
365
|
+
Job to submit.
|
|
248
366
|
|
|
249
|
-
:
|
|
250
|
-
:
|
|
367
|
+
:return: Azure Quantum Job that was submitted, with an updated status.
|
|
368
|
+
:rtype: Job
|
|
251
369
|
"""
|
|
252
370
|
client = self._get_jobs_client()
|
|
253
371
|
details = client.create(
|
|
@@ -257,10 +375,14 @@ class Workspace:
|
|
|
257
375
|
|
|
258
376
|
def cancel_job(self, job: Job) -> Job:
|
|
259
377
|
"""
|
|
260
|
-
|
|
378
|
+
Requests the Workspace to cancel the
|
|
379
|
+
execution of a job.
|
|
380
|
+
|
|
381
|
+
:param job:
|
|
382
|
+
Job to cancel.
|
|
261
383
|
|
|
262
|
-
:
|
|
263
|
-
:
|
|
384
|
+
:return: Azure Quantum Job that was requested to be cancelled, with an updated status.
|
|
385
|
+
:rtype: Job
|
|
264
386
|
"""
|
|
265
387
|
client = self._get_jobs_client()
|
|
266
388
|
client.cancel(job.details.id)
|
|
@@ -271,17 +393,20 @@ class Workspace:
|
|
|
271
393
|
"""
|
|
272
394
|
Returns the job corresponding to the given id.
|
|
273
395
|
|
|
274
|
-
:param job_id:
|
|
275
|
-
|
|
276
|
-
|
|
396
|
+
:param job_id:
|
|
397
|
+
Id of a job to fetch.
|
|
398
|
+
|
|
399
|
+
:return: Azure Quantum Job.
|
|
277
400
|
:rtype: Job
|
|
278
401
|
"""
|
|
402
|
+
# pylint: disable=import-outside-toplevel
|
|
279
403
|
from azure.quantum.target.target_factory import TargetFactory
|
|
280
404
|
from azure.quantum.target import Target
|
|
281
405
|
|
|
282
406
|
client = self._get_jobs_client()
|
|
283
407
|
details = client.get(job_id)
|
|
284
408
|
target_factory = TargetFactory(base_cls=Target, workspace=self)
|
|
409
|
+
# pylint: disable=protected-access
|
|
285
410
|
target_cls = target_factory._target_cls(
|
|
286
411
|
details.provider_id,
|
|
287
412
|
details.target)
|
|
@@ -290,17 +415,23 @@ class Workspace:
|
|
|
290
415
|
|
|
291
416
|
def list_jobs(
|
|
292
417
|
self,
|
|
293
|
-
name_match: str = None,
|
|
418
|
+
name_match: Optional[str] = None,
|
|
294
419
|
status: Optional[JobStatus] = None,
|
|
295
420
|
created_after: Optional[datetime] = None
|
|
296
421
|
) -> List[Job]:
|
|
297
422
|
"""
|
|
298
423
|
Returns list of jobs that meet optional (limited) filter criteria.
|
|
299
424
|
|
|
300
|
-
:param name_match:
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
:
|
|
425
|
+
:param name_match:
|
|
426
|
+
Optional Regular Expression for job name matching. Defaults to `None`.
|
|
427
|
+
|
|
428
|
+
:param status:
|
|
429
|
+
Optional filter by job status. Defaults to `None`.
|
|
430
|
+
|
|
431
|
+
:param created_after:
|
|
432
|
+
Optional filter by jobs that were created after the given time. Defaults to `None`.
|
|
433
|
+
|
|
434
|
+
:return: Jobs that matched the search criteria.
|
|
304
435
|
:rtype: typing.List[Job]
|
|
305
436
|
"""
|
|
306
437
|
client = self._get_jobs_client()
|
|
@@ -314,8 +445,24 @@ class Workspace:
|
|
|
314
445
|
|
|
315
446
|
return result
|
|
316
447
|
|
|
317
|
-
def _get_target_status(
|
|
318
|
-
|
|
448
|
+
def _get_target_status(
|
|
449
|
+
self,
|
|
450
|
+
name: Optional[str] = None,
|
|
451
|
+
provider_id: Optional[str] = None,
|
|
452
|
+
) -> List[Tuple[str, TargetStatus]]:
|
|
453
|
+
"""
|
|
454
|
+
Returns a list of tuples containing the `Provider ID` and `Target Status`,
|
|
455
|
+
with the option of filtering that list by a combination of Provider ID and Target Name.
|
|
456
|
+
|
|
457
|
+
:param name:
|
|
458
|
+
Optional name of the Target to filter for. Defaults to `None`.
|
|
459
|
+
|
|
460
|
+
:param provider_id:
|
|
461
|
+
Optional Provider ID to filter for. Defaults to `None`.
|
|
462
|
+
|
|
463
|
+
:return: List of tuples containing Provider ID and TargetStatus.
|
|
464
|
+
:rtype: typing.List[typing.Tuple[str, TargetStatus]]
|
|
465
|
+
"""
|
|
319
466
|
return [
|
|
320
467
|
(provider.id, target)
|
|
321
468
|
for provider in self._client.providers.get_status()
|
|
@@ -325,21 +472,25 @@ class Workspace:
|
|
|
325
472
|
]
|
|
326
473
|
|
|
327
474
|
def get_targets(
|
|
328
|
-
self,
|
|
329
|
-
name: str = None,
|
|
330
|
-
provider_id: str = None,
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
475
|
+
self,
|
|
476
|
+
name: Optional[str] = None,
|
|
477
|
+
provider_id: Optional[str] = None,
|
|
478
|
+
) -> Union[Target, Iterable[Target]]:
|
|
479
|
+
"""
|
|
480
|
+
Returns all available targets for this workspace filtered by Target name and Provider ID.
|
|
481
|
+
If the target name is passed, a single `Target` object will be returned.
|
|
482
|
+
Otherwise it returns a iterable/list of `Target` objects, optionally filtered by the Provider ID.
|
|
334
483
|
|
|
335
|
-
:param name:
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
:
|
|
484
|
+
:param name:
|
|
485
|
+
Optional target name to filter by, defaults to `None`.
|
|
486
|
+
|
|
487
|
+
:param provider_id:
|
|
488
|
+
Optional provider Id to filter by, defaults to `None`.
|
|
339
489
|
|
|
340
|
-
:return: Targets
|
|
341
|
-
:rtype: typing.Iterable[Target]
|
|
490
|
+
:return: A single Azure Quantum Target or a iterable/list of Targets.
|
|
491
|
+
:rtype: typing.Union[Target, typing.Iterable[Target]]
|
|
342
492
|
"""
|
|
493
|
+
# pylint: disable=import-outside-toplevel
|
|
343
494
|
from azure.quantum.target.target_factory import TargetFactory
|
|
344
495
|
from azure.quantum.target import Target
|
|
345
496
|
|
|
@@ -347,17 +498,27 @@ class Workspace:
|
|
|
347
498
|
base_cls=Target,
|
|
348
499
|
workspace=self
|
|
349
500
|
)
|
|
350
|
-
|
|
351
501
|
return target_factory.get_targets(
|
|
352
502
|
name=name,
|
|
353
503
|
provider_id=provider_id
|
|
354
504
|
)
|
|
355
505
|
|
|
356
506
|
def get_quotas(self) -> List[Dict[str, Any]]:
|
|
357
|
-
"""
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
507
|
+
"""
|
|
508
|
+
Get a list of quotas for the given workspace.
|
|
509
|
+
Each quota is represented as a dictionary, containing the
|
|
510
|
+
properties for that quota.
|
|
511
|
+
|
|
512
|
+
Common Quota properties are:
|
|
513
|
+
- "dimension": The dimension that the quota is applied to.
|
|
514
|
+
- "scope": The scope that the quota is applied to.
|
|
515
|
+
- "provider_id": The provider that the quota is applied to.
|
|
516
|
+
- "utilization": The current utilization of the quota.
|
|
517
|
+
- "limit": The limit of the quota.
|
|
518
|
+
- "period": The period that the quota is applied to.
|
|
519
|
+
|
|
520
|
+
:return: Workspace quotas.
|
|
521
|
+
:rtype: typing.List[typing.Dict[str, typing.Any]
|
|
361
522
|
"""
|
|
362
523
|
client = self._get_quotas_client()
|
|
363
524
|
return [q.as_dict() for q in client.list()]
|
|
@@ -365,41 +526,47 @@ class Workspace:
|
|
|
365
526
|
def list_top_level_items(
|
|
366
527
|
self
|
|
367
528
|
) -> List[Union[Job, Session]]:
|
|
368
|
-
"""
|
|
529
|
+
"""
|
|
530
|
+
Get a list of top level items for the given workspace,
|
|
531
|
+
which can be standalone Jobs (Jobs not associated with a Session)
|
|
532
|
+
or Sessions (which can contain Jobs).
|
|
369
533
|
|
|
370
|
-
:return: Workspace
|
|
371
|
-
:rtype: typing.List[
|
|
534
|
+
:return: List of Workspace top level Jobs or Sessions.
|
|
535
|
+
:rtype: typing.List[typing.Union[Job, Session]]
|
|
372
536
|
"""
|
|
373
|
-
from azure.quantum.job.workspace_item_factory import WorkspaceItemFactory
|
|
374
537
|
client = self._get_top_level_items_client()
|
|
375
538
|
item_details_list = client.list()
|
|
376
|
-
result = [WorkspaceItemFactory.__new__(workspace=self, item_details=item_details)
|
|
539
|
+
result = [WorkspaceItemFactory.__new__(workspace=self, item_details=item_details)
|
|
377
540
|
for item_details in item_details_list]
|
|
378
541
|
return result
|
|
379
542
|
|
|
380
543
|
def list_sessions(
|
|
381
544
|
self
|
|
382
545
|
) -> List[Session]:
|
|
383
|
-
"""
|
|
546
|
+
"""
|
|
547
|
+
Get the list of sessions in the given workspace.
|
|
384
548
|
|
|
385
|
-
:return:
|
|
549
|
+
:return: List of Workspace Sessions.
|
|
386
550
|
:rtype: typing.List[Session]
|
|
387
551
|
"""
|
|
388
552
|
client = self._get_sessions_client()
|
|
389
553
|
session_details_list = client.list()
|
|
390
|
-
result = [Session(workspace=self,details=session_details)
|
|
554
|
+
result = [Session(workspace=self,details=session_details)
|
|
391
555
|
for session_details in session_details_list]
|
|
392
556
|
return result
|
|
393
557
|
|
|
394
558
|
def open_session(
|
|
395
559
|
self,
|
|
396
560
|
session: Session,
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
561
|
+
) -> None:
|
|
562
|
+
"""
|
|
563
|
+
Opens/creates a session in the given workspace.
|
|
564
|
+
|
|
565
|
+
:param session:
|
|
566
|
+
The session to be opened/created.
|
|
400
567
|
|
|
401
|
-
:
|
|
402
|
-
:
|
|
568
|
+
:return: A new open Azure Quantum Session.
|
|
569
|
+
:rtype: Session
|
|
403
570
|
"""
|
|
404
571
|
client = self._get_sessions_client()
|
|
405
572
|
session.details = client.open(
|
|
@@ -409,13 +576,14 @@ class Workspace:
|
|
|
409
576
|
def close_session(
|
|
410
577
|
self,
|
|
411
578
|
session: Session
|
|
412
|
-
):
|
|
413
|
-
"""
|
|
414
|
-
|
|
415
|
-
|
|
579
|
+
) -> None:
|
|
580
|
+
"""
|
|
581
|
+
Closes a session in the given workspace if the
|
|
582
|
+
session is not in a terminal state.
|
|
583
|
+
Otherwise, just refreshes the session details.
|
|
416
584
|
|
|
417
|
-
:param session:
|
|
418
|
-
|
|
585
|
+
:param session:
|
|
586
|
+
The session to be closed.
|
|
419
587
|
"""
|
|
420
588
|
client = self._get_sessions_client()
|
|
421
589
|
if not session.is_in_terminal_state():
|
|
@@ -431,12 +599,13 @@ class Workspace:
|
|
|
431
599
|
def refresh_session(
|
|
432
600
|
self,
|
|
433
601
|
session: Session
|
|
434
|
-
):
|
|
435
|
-
"""
|
|
436
|
-
|
|
602
|
+
) -> None:
|
|
603
|
+
"""
|
|
604
|
+
Updates the session details with the latest information
|
|
605
|
+
from the workspace.
|
|
437
606
|
|
|
438
|
-
:param session:
|
|
439
|
-
|
|
607
|
+
:param session:
|
|
608
|
+
The session to be refreshed.
|
|
440
609
|
"""
|
|
441
610
|
session.details = self.get_session(session_id=session.id).details
|
|
442
611
|
|
|
@@ -444,12 +613,13 @@ class Workspace:
|
|
|
444
613
|
self,
|
|
445
614
|
session_id: str
|
|
446
615
|
) -> Session:
|
|
447
|
-
"""
|
|
616
|
+
"""
|
|
617
|
+
Gets a session from the workspace.
|
|
448
618
|
|
|
449
|
-
:param session_id:
|
|
450
|
-
|
|
619
|
+
:param session_id:
|
|
620
|
+
The id of session to be retrieved.
|
|
451
621
|
|
|
452
|
-
:return: Session
|
|
622
|
+
:return: Azure Quantum Session
|
|
453
623
|
:rtype: Session
|
|
454
624
|
"""
|
|
455
625
|
client = self._get_sessions_client()
|
|
@@ -461,10 +631,11 @@ class Workspace:
|
|
|
461
631
|
self,
|
|
462
632
|
session_id: str
|
|
463
633
|
) -> List[Job]:
|
|
464
|
-
"""
|
|
634
|
+
"""
|
|
635
|
+
Gets all jobs associated with a session.
|
|
465
636
|
|
|
466
|
-
:param session_id:
|
|
467
|
-
|
|
637
|
+
:param session_id:
|
|
638
|
+
The id of session.
|
|
468
639
|
|
|
469
640
|
:return: List of all jobs associated with a session.
|
|
470
641
|
:rtype: typing.List[Job]
|
|
@@ -477,20 +648,24 @@ class Workspace:
|
|
|
477
648
|
|
|
478
649
|
def get_container_uri(
|
|
479
650
|
self,
|
|
480
|
-
job_id: str = None,
|
|
481
|
-
container_name: str = None,
|
|
482
|
-
container_name_format: str =
|
|
651
|
+
job_id: Optional[str] = None,
|
|
652
|
+
container_name: Optional[str] = None,
|
|
653
|
+
container_name_format: Optional[str] = "job-{job_id}"
|
|
483
654
|
) -> str:
|
|
484
|
-
"""
|
|
655
|
+
"""
|
|
656
|
+
Get container URI based on job ID or container name.
|
|
485
657
|
Creates a new container if it does not yet exist.
|
|
486
658
|
|
|
487
|
-
:param job_id:
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
:
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
:
|
|
659
|
+
:param job_id:
|
|
660
|
+
Job ID, defaults to `None`.
|
|
661
|
+
|
|
662
|
+
:param container_name:
|
|
663
|
+
Container name, defaults to `None`.
|
|
664
|
+
|
|
665
|
+
:param container_name_format:
|
|
666
|
+
Container name format, defaults to "job-{job_id}".
|
|
667
|
+
|
|
668
|
+
:return: Container URI.
|
|
494
669
|
:rtype: str
|
|
495
670
|
"""
|
|
496
671
|
if container_name is None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: azure-quantum
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: Python client for Azure Quantum
|
|
5
5
|
Home-page: https://github.com/microsoft/azure-quantum-python
|
|
6
6
|
Author: Microsoft
|
|
@@ -10,9 +10,9 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Requires-Python: >=3.7
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
|
-
Requires-Dist: azure-core <2.0
|
|
14
|
-
Requires-Dist: azure-identity <2.0
|
|
15
|
-
Requires-Dist: azure-storage-blob <13.0
|
|
13
|
+
Requires-Dist: azure-core <2.0,>=1.30
|
|
14
|
+
Requires-Dist: azure-identity <2.0,>=1.15
|
|
15
|
+
Requires-Dist: azure-storage-blob <13.0,>=12.19
|
|
16
16
|
Requires-Dist: msrest <1.0,>=0.7.1
|
|
17
17
|
Requires-Dist: numpy <2.0,>=1.21.0
|
|
18
18
|
Requires-Dist: deprecated <2.0,>=1.2.12
|
|
@@ -26,7 +26,7 @@ Requires-Dist: azure-devtools <2.0,>=1.2.0 ; extra == 'all'
|
|
|
26
26
|
Requires-Dist: graphviz >=0.20.1 ; extra == 'all'
|
|
27
27
|
Requires-Dist: qiskit-ionq <1.0,>=0.3.3 ; extra == 'all'
|
|
28
28
|
Requires-Dist: qiskit-qir <0.5,>=0.4 ; extra == 'all'
|
|
29
|
-
Requires-Dist: qiskit-terra <0.
|
|
29
|
+
Requires-Dist: qiskit-terra <0.47,>=0.46 ; extra == 'all'
|
|
30
30
|
Requires-Dist: Markdown <4.0,>=3.4.1 ; extra == 'all'
|
|
31
31
|
Requires-Dist: python-markdown-math <1.0,>=0.8.0 ; extra == 'all'
|
|
32
32
|
Requires-Dist: qsharp <2.0,>=1.0.33 ; extra == 'all'
|
|
@@ -41,7 +41,7 @@ Requires-Dist: graphviz >=0.20.1 ; extra == 'dev'
|
|
|
41
41
|
Provides-Extra: qiskit
|
|
42
42
|
Requires-Dist: qiskit-ionq <1.0,>=0.3.3 ; extra == 'qiskit'
|
|
43
43
|
Requires-Dist: qiskit-qir <0.5,>=0.4 ; extra == 'qiskit'
|
|
44
|
-
Requires-Dist: qiskit-terra <0.
|
|
44
|
+
Requires-Dist: qiskit-terra <0.47,>=0.46 ; extra == 'qiskit'
|
|
45
45
|
Requires-Dist: Markdown <4.0,>=3.4.1 ; extra == 'qiskit'
|
|
46
46
|
Requires-Dist: python-markdown-math <1.0,>=0.8.0 ; extra == 'qiskit'
|
|
47
47
|
Provides-Extra: qsharp
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
azure/quantum/__init__.py,sha256=Za8xZY4lzFkW8m4ero-bqrfN437D2NRukM77ukb4GPM,508
|
|
2
2
|
azure/quantum/_constants.py,sha256=6FCBpjUK2GHeycKejgGYTvxtlSsfWdbG2iOXGQg8NaM,3219
|
|
3
|
-
azure/quantum/_workspace_connection_params.py,sha256=
|
|
3
|
+
azure/quantum/_workspace_connection_params.py,sha256=KoT90U89Dj6pVwAKp_ENJL1hyTF0oQe7w0QioOGvjXg,21685
|
|
4
4
|
azure/quantum/storage.py,sha256=_4bMniDk9LrB_K5CQwuCivJFZXdmhRvU2b6Z3xxXw9I,12556
|
|
5
|
-
azure/quantum/version.py,sha256
|
|
6
|
-
azure/quantum/workspace.py,sha256=
|
|
5
|
+
azure/quantum/version.py,sha256=q2DcrJ1aWYDRwz6uwfszz2q8kvsbOddBvWYXb-rKcBU,235
|
|
6
|
+
azure/quantum/workspace.py,sha256=1__iZTe59ozAsAGJ4nECxmk_211Dm8ALJi-MFIdrg4o,23438
|
|
7
7
|
azure/quantum/_authentication/__init__.py,sha256=bniNZlS0hMIjO_y7DevGBAS6MixyA5pbPHcdGipUWM4,236
|
|
8
8
|
azure/quantum/_authentication/_chained.py,sha256=0rdohB_fVGFHUhlly9sGxqQTBTZGpGxtlBqNHDFbAqE,4848
|
|
9
9
|
azure/quantum/_authentication/_default.py,sha256=RzhK5UNQb6TK95VQI4o8Gm2nxtOaz64yA0J9Tw9zpW4,6625
|
|
@@ -14,7 +14,7 @@ azure/quantum/_client/_configuration.py,sha256=5uktKtZxoVVAoSyeL0VNGS9AfPERp-9rU
|
|
|
14
14
|
azure/quantum/_client/_patch.py,sha256=YTV6yZ9bRfBBaw2z7v4MdzR-zeHkdtKkGb4SU8C25mE,694
|
|
15
15
|
azure/quantum/_client/_serialization.py,sha256=KJSS6KWgnKcz-cENQCmWZ9Ziv303lnBbLwFIpYZeKFU,81097
|
|
16
16
|
azure/quantum/_client/_vendor.py,sha256=h8ByiyZ4cCQyFxqnuhTQdv1Rms3dVjKsrgZDzwMcSJ0,996
|
|
17
|
-
azure/quantum/_client/_version.py,sha256=
|
|
17
|
+
azure/quantum/_client/_version.py,sha256=Coisxue-0LHHN5ZivYhh-CWvOwnZ4B4MyLq5oY5xV2Y,495
|
|
18
18
|
azure/quantum/_client/models/__init__.py,sha256=c1PRpzNsQTcDk4GkrFMMIlwNQQa2c0p5N0Lzd-23YBA,2100
|
|
19
19
|
azure/quantum/_client/models/_enums.py,sha256=omj_B8_E8ONzTHg5hLgDlFYibRRbdr9sEN298im_otA,2977
|
|
20
20
|
azure/quantum/_client/models/_models.py,sha256=wktCM5oBVfwQetNoHobL1wNsC3knXV-HmqBq_Q77Kw4,41810
|
|
@@ -32,23 +32,23 @@ azure/quantum/cirq/targets/__init__.py,sha256=cpb677Kg1V5cdI0kdgkLafI8xfwYZZYx0t
|
|
|
32
32
|
azure/quantum/cirq/targets/ionq.py,sha256=xCabcYklH9wW1TFBzpMdxvipzqhKWCYbtcgNqDHbPXM,6804
|
|
33
33
|
azure/quantum/cirq/targets/quantinuum.py,sha256=t7L5prczDQJlzStth6Rh6r35DX1Z8J_my-VJxLBp2n4,4537
|
|
34
34
|
azure/quantum/cirq/targets/target.py,sha256=1EEog72dFZoiOTQP7obOrCuO3VH0yjXGAIMeO6bm22o,2184
|
|
35
|
-
azure/quantum/job/__init__.py,sha256=
|
|
35
|
+
azure/quantum/job/__init__.py,sha256=nFuOsG25a8WzYFLwA2fhA0JMNWtblfDjV5WRgB6UQbw,829
|
|
36
36
|
azure/quantum/job/base_job.py,sha256=NovuhFFH4HCpXRDn2EwlWAxcpY8Kenu58RwbddIbtdA,12882
|
|
37
37
|
azure/quantum/job/filtered_job.py,sha256=qZfxTuDp0hzK4wermn4GRzLxnDy4yM-j6oZQ3D0O4vI,1877
|
|
38
|
-
azure/quantum/job/job.py,sha256=
|
|
39
|
-
azure/quantum/job/job_failed_with_results_error.py,sha256=
|
|
38
|
+
azure/quantum/job/job.py,sha256=UcNkD8qwJ7leQ99xvWegssUMsuHDOkhZwKyvG2Caag8,6390
|
|
39
|
+
azure/quantum/job/job_failed_with_results_error.py,sha256=bSqOZ0c6FNbS9opvwkCXG9mfTkAiyZRvp_YA3V-ktEs,1597
|
|
40
40
|
azure/quantum/job/session.py,sha256=EEJVKEEB5g0yyH963aaR0GY0Cd0axrX-49gwDWxBcfE,11961
|
|
41
41
|
azure/quantum/job/workspace_item.py,sha256=lyBIJCtUfIZMGJYJkX7Se8IDnXhXe4JU0RnqzSuhhI4,1380
|
|
42
42
|
azure/quantum/job/workspace_item_factory.py,sha256=QRWyrtgcKZqUucJOFi9V_SYMV3lj6S74tGRrPtk3NE0,1200
|
|
43
|
-
azure/quantum/qiskit/__init__.py,sha256=
|
|
43
|
+
azure/quantum/qiskit/__init__.py,sha256=gjKsmRwtVNcbbsuOvy2wT0ASELh5NXGmuwaEwjZcVQo,314
|
|
44
44
|
azure/quantum/qiskit/job.py,sha256=PHgEIY7dOQtpfo-J--frj-PVX3OWr8llfBUv9VClLNg,14370
|
|
45
|
-
azure/quantum/qiskit/provider.py,sha256=
|
|
46
|
-
azure/quantum/qiskit/backends/__init__.py,sha256=
|
|
47
|
-
azure/quantum/qiskit/backends/backend.py,sha256=
|
|
45
|
+
azure/quantum/qiskit/provider.py,sha256=x6UheEdrL2z32ukNT5SF4OBBuZI9R1g1kh7smITn6RY,10975
|
|
46
|
+
azure/quantum/qiskit/backends/__init__.py,sha256=OjcYgOyhVjsw-AngJmZLKtBKntzeIJnvvfWW5dv-Gw4,1163
|
|
47
|
+
azure/quantum/qiskit/backends/backend.py,sha256=uzm5KOxVsjFVLZwLDtJJhBhys-D4ZbsmPmOsTSiStwk,20467
|
|
48
48
|
azure/quantum/qiskit/backends/ionq.py,sha256=rxAhWvXrAMuFbdg72qDy_MKIx8EuCV7BvKCgwQwpogY,18024
|
|
49
49
|
azure/quantum/qiskit/backends/microsoft.py,sha256=MDPIYpWcKxEQPNYjoRczYvw38iTVRH3JqqWXQNoFvVU,3441
|
|
50
50
|
azure/quantum/qiskit/backends/qci.py,sha256=U8xi9J1OjHt8EOF6uBrE4T_CGLighXhiLL-69aULggc,4819
|
|
51
|
-
azure/quantum/qiskit/backends/quantinuum.py,sha256=
|
|
51
|
+
azure/quantum/qiskit/backends/quantinuum.py,sha256=s8qDhRce07sXZbZmDnZpYu2WuKSvIYNp0oLq4IOpDZk,13635
|
|
52
52
|
azure/quantum/qiskit/backends/rigetti.py,sha256=QeV_kQveHk9uUZUZLR0CiHhrcVY8twJWLb2Wh1h5Lrk,4248
|
|
53
53
|
azure/quantum/qiskit/results/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
54
54
|
azure/quantum/qiskit/results/resource_estimator.py,sha256=pAP5ZpVxdzNekQ_qXfSdSKYWWuqL_Vq7WK6pWU4wbEQ,814
|
|
@@ -56,7 +56,7 @@ azure/quantum/target/__init__.py,sha256=F0nIEJdlbczmxAdtvPDWf8J1Y33_XjPzloliHeWp
|
|
|
56
56
|
azure/quantum/target/ionq.py,sha256=f6V_Ce09RHU56NmCdwcupDDjSxA3kDVodjwEBvpWrvg,8130
|
|
57
57
|
azure/quantum/target/params.py,sha256=oI-35HUEMCskNjpxCJU3tjL664K-TxqAg5LA5xU0nso,9130
|
|
58
58
|
azure/quantum/target/quantinuum.py,sha256=2VWng9h-OA7v9GeSsmMFWHVqBITqPrFjQcD5fH8ANHU,7710
|
|
59
|
-
azure/quantum/target/target.py,sha256=
|
|
59
|
+
azure/quantum/target/target.py,sha256=mb-z640nMU2S0YkHxVulE-ahz0imCr1Z_VCDspsd-HU,13868
|
|
60
60
|
azure/quantum/target/target_factory.py,sha256=5nYFo_PLvnDrsILMd4zzprnjQSJCj2P-as5Z-J8_tnk,5053
|
|
61
61
|
azure/quantum/target/microsoft/__init__.py,sha256=36kM2YlWv69AzAfUA5wMdWyYRSaCMwX2Ajhffpzx67g,570
|
|
62
62
|
azure/quantum/target/microsoft/job.py,sha256=GM4OA-rxFUqQzsH8V59pVc4BmBaPYvd99E26pyPwxto,1249
|
|
@@ -64,15 +64,15 @@ azure/quantum/target/microsoft/result.py,sha256=AntJptXKHNRdRR6oxhTlKKPOJVSU7u9f
|
|
|
64
64
|
azure/quantum/target/microsoft/target.py,sha256=D7KS3AH-sjD1MVXL-J0SG61aGdWlrTZNT9JicjJzWeE,17879
|
|
65
65
|
azure/quantum/target/microsoft/elements/__init__.py,sha256=gVVpaN5086iuBnajtvTjSd7MLExtnsR6RDCmcgz6xpE,70
|
|
66
66
|
azure/quantum/target/microsoft/elements/dft/__init__.py,sha256=kCXOA9HT-gb23An-A0eyktlB66VoH6EwNO4gPM97l3U,224
|
|
67
|
-
azure/quantum/target/microsoft/elements/dft/job.py,sha256=
|
|
67
|
+
azure/quantum/target/microsoft/elements/dft/job.py,sha256=REDLDF6-HBwB4OxUMrgKfZWCE6W7RWj7HKhiYeH1a-E,2936
|
|
68
68
|
azure/quantum/target/microsoft/elements/dft/target.py,sha256=IeFDVh3SqDsQOZmd9UKhl1Qu0ChkOEIHHb5fC5x4YGE,2556
|
|
69
69
|
azure/quantum/target/pasqal/__init__.py,sha256=qbe6oWTQTsnTYwY3xZr32z4AWaYIchx71bYlqC2rQqw,348
|
|
70
|
-
azure/quantum/target/pasqal/result.py,sha256=
|
|
71
|
-
azure/quantum/target/pasqal/target.py,sha256=
|
|
70
|
+
azure/quantum/target/pasqal/result.py,sha256=SUvpnrtgvCGiepmNpyifW8b4p14-SZZ1ToCC0NAdIwg,1463
|
|
71
|
+
azure/quantum/target/pasqal/target.py,sha256=DMt2uYeCeaUFh7vlnf687VOoRStXCWL-6Mk_Dub8anI,4833
|
|
72
72
|
azure/quantum/target/rigetti/__init__.py,sha256=I1vyzZBYGI540pauTqJd0RSSyTShGqkEL7Yjo25_RNY,378
|
|
73
|
-
azure/quantum/target/rigetti/result.py,sha256=
|
|
74
|
-
azure/quantum/target/rigetti/target.py,sha256=
|
|
75
|
-
azure_quantum-1.
|
|
76
|
-
azure_quantum-1.
|
|
77
|
-
azure_quantum-1.
|
|
78
|
-
azure_quantum-1.
|
|
73
|
+
azure/quantum/target/rigetti/result.py,sha256=65mtAZxfdNrTWNjWPqgfwt2BZN6Nllo4g_bls7-Nm68,2334
|
|
74
|
+
azure/quantum/target/rigetti/target.py,sha256=CKj7oP_CXivoHWJH59Lxfl8JEBFEEpiedYfT92-z_dM,7219
|
|
75
|
+
azure_quantum-1.2.1.dist-info/METADATA,sha256=8NahehTMbH2bHaei1_QtY2uB6yW2S1zD42BDK4U12xo,7292
|
|
76
|
+
azure_quantum-1.2.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
77
|
+
azure_quantum-1.2.1.dist-info/top_level.txt,sha256=S7DhWV9m80TBzAhOFjxDUiNbKszzoThbnrSz5MpbHSQ,6
|
|
78
|
+
azure_quantum-1.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|