azure-quantum 3.5.1.dev1__py3-none-any.whl → 3.6.0__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/__init__.py +2 -2
- azure/quantum/_client/_client.py +18 -57
- azure/quantum/_client/_configuration.py +13 -22
- azure/quantum/_client/_patch.py +7 -6
- azure/quantum/_client/_utils/__init__.py +6 -0
- azure/quantum/_client/{_model_base.py → _utils/model_base.py} +210 -45
- azure/quantum/_client/{_serialization.py → _utils/serialization.py} +74 -151
- azure/quantum/_client/_validation.py +66 -0
- azure/quantum/_client/_version.py +1 -1
- azure/quantum/_client/aio/__init__.py +29 -0
- azure/quantum/_client/aio/_client.py +110 -0
- azure/quantum/_client/aio/_configuration.py +75 -0
- azure/quantum/_client/aio/_patch.py +21 -0
- azure/quantum/_client/aio/operations/__init__.py +25 -0
- azure/quantum/_client/aio/operations/_operations.py +1988 -0
- azure/quantum/_client/aio/operations/_patch.py +21 -0
- azure/quantum/_client/models/__init__.py +8 -4
- azure/quantum/_client/models/_enums.py +28 -23
- azure/quantum/_client/models/_models.py +198 -106
- azure/quantum/_client/models/_patch.py +7 -6
- azure/quantum/_client/operations/__init__.py +2 -12
- azure/quantum/_client/operations/_operations.py +900 -715
- azure/quantum/_client/operations/_patch.py +7 -6
- azure/quantum/_constants.py +5 -0
- azure/quantum/_mgmt_client.py +18 -8
- azure/quantum/_workspace_connection_params.py +27 -2
- azure/quantum/job/base_job.py +8 -0
- azure/quantum/job/job.py +1 -1
- azure/quantum/job/session.py +11 -0
- azure/quantum/target/target.py +5 -1
- azure/quantum/target/target_factory.py +14 -7
- azure/quantum/version.py +1 -1
- azure/quantum/workspace.py +35 -31
- {azure_quantum-3.5.1.dev1.dist-info → azure_quantum-3.6.0.dist-info}/METADATA +1 -1
- azure_quantum-3.6.0.dist-info/RECORD +74 -0
- azure_quantum-3.5.1.dev1.dist-info/RECORD +0 -65
- {azure_quantum-3.5.1.dev1.dist-info → azure_quantum-3.6.0.dist-info}/WHEEL +0 -0
- {azure_quantum-3.5.1.dev1.dist-info → azure_quantum-3.6.0.dist-info}/top_level.txt +0 -0
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
# --------------------------------------------------------------------------
|
|
3
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
5
6
|
"""Customize generated code here.
|
|
6
7
|
|
|
7
8
|
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
|
|
8
9
|
"""
|
|
9
|
-
from typing import List
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
__all__: list[str] = [] # Add all objects you want publicly available to users at this package level
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
def patch_sdk():
|
azure/quantum/_constants.py
CHANGED
|
@@ -51,6 +51,11 @@ class EnvironmentKind(Enum):
|
|
|
51
51
|
DOGFOOD = 3
|
|
52
52
|
|
|
53
53
|
|
|
54
|
+
class WorkspaceKind(Enum):
|
|
55
|
+
V1 = "V1"
|
|
56
|
+
V2 = "V2"
|
|
57
|
+
|
|
58
|
+
|
|
54
59
|
class ConnectionConstants:
|
|
55
60
|
DATA_PLANE_CREDENTIAL_SCOPE = "https://quantum.microsoft.com/.default"
|
|
56
61
|
ARM_CREDENTIAL_SCOPE = "https://management.azure.com/.default"
|
azure/quantum/_mgmt_client.py
CHANGED
|
@@ -9,7 +9,7 @@ Created to do not add additional azure-mgmt-* dependencies that can conflict wit
|
|
|
9
9
|
|
|
10
10
|
import logging
|
|
11
11
|
from http import HTTPStatus
|
|
12
|
-
from typing import Any, Optional, cast
|
|
12
|
+
from typing import Any, Dict, Optional, cast
|
|
13
13
|
from azure.core import PipelineClient
|
|
14
14
|
from azure.core.credentials import TokenProvider
|
|
15
15
|
from azure.core.pipeline import policies
|
|
@@ -104,8 +104,8 @@ class WorkspaceMgmtClient():
|
|
|
104
104
|
query += f"\n | where location =~ '{connection_params.location}'"
|
|
105
105
|
|
|
106
106
|
query += """
|
|
107
|
-
| extend endpointUri = tostring(properties.endpointUri)
|
|
108
|
-
| project name, subscriptionId, resourceGroup, location, endpointUri
|
|
107
|
+
| extend endpointUri = tostring(properties.endpointUri), workspaceKind = tostring(properties.workspaceKind)
|
|
108
|
+
| project name, subscriptionId, resourceGroup, location, endpointUri, workspaceKind
|
|
109
109
|
"""
|
|
110
110
|
|
|
111
111
|
request_body = {
|
|
@@ -143,20 +143,22 @@ class WorkspaceMgmtClient():
|
|
|
143
143
|
f"Please specify additional connection parameters. {self.CONNECT_DOC_MESSAGE}"
|
|
144
144
|
)
|
|
145
145
|
|
|
146
|
-
workspace_data = data[0]
|
|
146
|
+
workspace_data: Dict[str, Any] = data[0]
|
|
147
147
|
|
|
148
148
|
connection_params.subscription_id = workspace_data.get('subscriptionId')
|
|
149
149
|
connection_params.resource_group = workspace_data.get('resourceGroup')
|
|
150
150
|
connection_params.location = workspace_data.get('location')
|
|
151
151
|
connection_params.quantum_endpoint = workspace_data.get('endpointUri')
|
|
152
|
+
connection_params.workspace_kind = workspace_data.get('workspaceKind')
|
|
152
153
|
|
|
153
154
|
logger.debug(
|
|
154
|
-
"Found workspace '%s' in subscription '%s', resource group '%s', location '%s', endpoint '%s'",
|
|
155
|
+
"Found workspace '%s' in subscription '%s', resource group '%s', location '%s', endpoint '%s', kind '%s'.",
|
|
155
156
|
connection_params.workspace_name,
|
|
156
157
|
connection_params.subscription_id,
|
|
157
158
|
connection_params.resource_group,
|
|
158
159
|
connection_params.location,
|
|
159
|
-
connection_params.quantum_endpoint
|
|
160
|
+
connection_params.quantum_endpoint,
|
|
161
|
+
connection_params.workspace_kind
|
|
160
162
|
)
|
|
161
163
|
|
|
162
164
|
# If one of the required parameters is missing, probably workspace in failed provisioning state
|
|
@@ -194,7 +196,7 @@ class WorkspaceMgmtClient():
|
|
|
194
196
|
try:
|
|
195
197
|
response = self._client.send_request(request)
|
|
196
198
|
response.raise_for_status()
|
|
197
|
-
workspace_data = response.json()
|
|
199
|
+
workspace_data: Dict[str, Any] = response.json()
|
|
198
200
|
except HttpResponseError as e:
|
|
199
201
|
if e.status_code == HTTPStatus.NOT_FOUND:
|
|
200
202
|
raise ValueError(
|
|
@@ -225,7 +227,7 @@ class WorkspaceMgmtClient():
|
|
|
225
227
|
)
|
|
226
228
|
|
|
227
229
|
# Extract and apply endpoint URI from properties
|
|
228
|
-
properties = workspace_data.get("properties", {})
|
|
230
|
+
properties: Dict[str, Any] = workspace_data.get("properties", {})
|
|
229
231
|
endpoint_uri = properties.get("endpointUri")
|
|
230
232
|
if endpoint_uri:
|
|
231
233
|
connection_params.quantum_endpoint = endpoint_uri
|
|
@@ -237,3 +239,11 @@ class WorkspaceMgmtClient():
|
|
|
237
239
|
f"Failed to retrieve endpoint uri for workspace '{connection_params.workspace_name}'. "
|
|
238
240
|
f"Please check that workspace is in valid state."
|
|
239
241
|
)
|
|
242
|
+
|
|
243
|
+
# Set workspaceKind if available
|
|
244
|
+
workspace_kind = properties.get("workspaceKind")
|
|
245
|
+
if workspace_kind:
|
|
246
|
+
connection_params.workspace_kind = workspace_kind
|
|
247
|
+
logger.debug(
|
|
248
|
+
"Updated workspace kind from ARM: %s", connection_params.workspace_kind
|
|
249
|
+
)
|
|
@@ -17,6 +17,7 @@ from azure.core.pipeline.policies import AzureKeyCredentialPolicy
|
|
|
17
17
|
from azure.identity import DefaultAzureCredential
|
|
18
18
|
from azure.quantum._constants import (
|
|
19
19
|
EnvironmentKind,
|
|
20
|
+
WorkspaceKind,
|
|
20
21
|
EnvironmentVariables,
|
|
21
22
|
ConnectionConstants,
|
|
22
23
|
GUID_REGEX_PATTERN,
|
|
@@ -48,7 +49,7 @@ class WorkspaceConnectionParams:
|
|
|
48
49
|
ResourceGroupName=(?P<resource_group>[^\s;]+);
|
|
49
50
|
WorkspaceName=(?P<workspace_name>[^\s;]+);
|
|
50
51
|
ApiKey=(?P<api_key>[^\s;]+);
|
|
51
|
-
QuantumEndpoint=(?P<quantum_endpoint>https://(?P<location>[a-zA-Z0-9]+)(?:-v2)?.quantum(?:-test)?.azure.com/);
|
|
52
|
+
QuantumEndpoint=(?P<quantum_endpoint>https://(?P<location>[a-zA-Z0-9]+)(?:-(?P<workspace_kind>v2))?.quantum(?:-test)?.azure.com/);
|
|
52
53
|
""",
|
|
53
54
|
re.VERBOSE | re.IGNORECASE)
|
|
54
55
|
|
|
@@ -80,6 +81,7 @@ class WorkspaceConnectionParams:
|
|
|
80
81
|
api_version: Optional[str] = None,
|
|
81
82
|
connection_string: Optional[str] = None,
|
|
82
83
|
on_new_client_request: Optional[Callable] = None,
|
|
84
|
+
workspace_kind: Optional[str] = None,
|
|
83
85
|
):
|
|
84
86
|
# fields are used for these properties since
|
|
85
87
|
# they have special getters/setters
|
|
@@ -87,6 +89,7 @@ class WorkspaceConnectionParams:
|
|
|
87
89
|
self._environment = None
|
|
88
90
|
self._quantum_endpoint = None
|
|
89
91
|
self._arm_endpoint = None
|
|
92
|
+
self._workspace_kind = None
|
|
90
93
|
# regular connection properties
|
|
91
94
|
self.subscription_id = None
|
|
92
95
|
self.resource_group = None
|
|
@@ -120,6 +123,7 @@ class WorkspaceConnectionParams:
|
|
|
120
123
|
user_agent=user_agent,
|
|
121
124
|
user_agent_app_id=user_agent_app_id,
|
|
122
125
|
workspace_name=workspace_name,
|
|
126
|
+
workspace_kind=workspace_kind,
|
|
123
127
|
)
|
|
124
128
|
self.apply_resource_id(resource_id=resource_id)
|
|
125
129
|
# Validate connection parameters if they are set
|
|
@@ -272,6 +276,19 @@ class WorkspaceConnectionParams:
|
|
|
272
276
|
self.credential = AzureKeyCredential(value)
|
|
273
277
|
self._api_key = value
|
|
274
278
|
|
|
279
|
+
@property
|
|
280
|
+
def workspace_kind(self) -> WorkspaceKind:
|
|
281
|
+
"""
|
|
282
|
+
The workspace kind, such as V1 or V2.
|
|
283
|
+
Defaults to WorkspaceKind.V1
|
|
284
|
+
"""
|
|
285
|
+
return self._workspace_kind or WorkspaceKind.V1
|
|
286
|
+
|
|
287
|
+
@workspace_kind.setter
|
|
288
|
+
def workspace_kind(self, value: str):
|
|
289
|
+
if isinstance(value, str):
|
|
290
|
+
self._workspace_kind = WorkspaceKind[value.upper()]
|
|
291
|
+
|
|
275
292
|
def __repr__(self):
|
|
276
293
|
"""
|
|
277
294
|
Print all fields and properties.
|
|
@@ -331,6 +348,7 @@ class WorkspaceConnectionParams:
|
|
|
331
348
|
client_id: Optional[str] = None,
|
|
332
349
|
api_version: Optional[str] = None,
|
|
333
350
|
api_key: Optional[str] = None,
|
|
351
|
+
workspace_kind: Optional[str] = None,
|
|
334
352
|
):
|
|
335
353
|
"""
|
|
336
354
|
Set all fields/properties with `not None` values
|
|
@@ -352,6 +370,7 @@ class WorkspaceConnectionParams:
|
|
|
352
370
|
user_agent_app_id=user_agent_app_id,
|
|
353
371
|
workspace_name=workspace_name,
|
|
354
372
|
api_key=api_key,
|
|
373
|
+
workspace_kind=workspace_kind,
|
|
355
374
|
merge_default_mode=False,
|
|
356
375
|
)
|
|
357
376
|
return self
|
|
@@ -372,6 +391,7 @@ class WorkspaceConnectionParams:
|
|
|
372
391
|
client_id: Optional[str] = None,
|
|
373
392
|
api_version: Optional[str] = None,
|
|
374
393
|
api_key: Optional[str] = None,
|
|
394
|
+
workspace_kind: Optional[str] = None,
|
|
375
395
|
) -> WorkspaceConnectionParams:
|
|
376
396
|
"""
|
|
377
397
|
Set all fields/properties with `not None` values
|
|
@@ -394,6 +414,7 @@ class WorkspaceConnectionParams:
|
|
|
394
414
|
user_agent_app_id=user_agent_app_id,
|
|
395
415
|
workspace_name=workspace_name,
|
|
396
416
|
api_key=api_key,
|
|
417
|
+
workspace_kind=workspace_kind,
|
|
397
418
|
merge_default_mode=True,
|
|
398
419
|
)
|
|
399
420
|
return self
|
|
@@ -415,6 +436,7 @@ class WorkspaceConnectionParams:
|
|
|
415
436
|
client_id: Optional[str] = None,
|
|
416
437
|
api_version: Optional[str] = None,
|
|
417
438
|
api_key: Optional[str] = None,
|
|
439
|
+
workspace_kind: Optional[str] = None,
|
|
418
440
|
):
|
|
419
441
|
"""
|
|
420
442
|
Set all fields/properties with `not None` values
|
|
@@ -447,6 +469,7 @@ class WorkspaceConnectionParams:
|
|
|
447
469
|
# the private field as the old_value
|
|
448
470
|
self.quantum_endpoint = _get_value_or_default(self._quantum_endpoint, quantum_endpoint)
|
|
449
471
|
self.arm_endpoint = _get_value_or_default(self._arm_endpoint, arm_endpoint)
|
|
472
|
+
self.workspace_kind = _get_value_or_default(self._workspace_kind, workspace_kind)
|
|
450
473
|
return self
|
|
451
474
|
|
|
452
475
|
def _merge_connection_params(
|
|
@@ -476,6 +499,7 @@ class WorkspaceConnectionParams:
|
|
|
476
499
|
# pylint: disable=protected-access
|
|
477
500
|
arm_endpoint=connection_params._arm_endpoint,
|
|
478
501
|
quantum_endpoint=connection_params._quantum_endpoint,
|
|
502
|
+
workspace_kind=connection_params._workspace_kind,
|
|
479
503
|
)
|
|
480
504
|
return self
|
|
481
505
|
|
|
@@ -500,7 +524,7 @@ class WorkspaceConnectionParams:
|
|
|
500
524
|
def append_user_agent(self, value: str):
|
|
501
525
|
"""
|
|
502
526
|
Append a new value to the Workspace's UserAgent and re-initialize the
|
|
503
|
-
|
|
527
|
+
WorkspaceClient. The values are appended using a dash.
|
|
504
528
|
|
|
505
529
|
:param value: UserAgent value to add, e.g. "azure-quantum-<plugin>"
|
|
506
530
|
"""
|
|
@@ -640,4 +664,5 @@ class WorkspaceConnectionParams:
|
|
|
640
664
|
quantum_endpoint=get_value('quantum_endpoint'),
|
|
641
665
|
api_key=get_value('api_key'),
|
|
642
666
|
arm_endpoint=get_value('arm_endpoint'),
|
|
667
|
+
workspace_kind=get_value('workspace_kind'),
|
|
643
668
|
)
|
azure/quantum/job/base_job.py
CHANGED
|
@@ -85,6 +85,7 @@ class BaseJob(WorkspaceItem):
|
|
|
85
85
|
output_data_format: str = None,
|
|
86
86
|
input_params: Dict[str, Any] = None,
|
|
87
87
|
session_id: Optional[str] = None,
|
|
88
|
+
priority: Optional[str] = None,
|
|
88
89
|
**kwargs
|
|
89
90
|
) -> "BaseJob":
|
|
90
91
|
"""Create a new Azure Quantum job based on a raw input_data payload.
|
|
@@ -117,6 +118,8 @@ class BaseJob(WorkspaceItem):
|
|
|
117
118
|
:type input_params: Dict[str, Any]
|
|
118
119
|
:param input_params: Input params for job
|
|
119
120
|
:type input_params: Dict[str, Any]
|
|
121
|
+
:param priority: Priority of job.
|
|
122
|
+
:type priority: str
|
|
120
123
|
:return: Azure Quantum Job
|
|
121
124
|
:rtype: Job
|
|
122
125
|
"""
|
|
@@ -153,6 +156,7 @@ class BaseJob(WorkspaceItem):
|
|
|
153
156
|
provider_id=provider_id,
|
|
154
157
|
input_params=input_params,
|
|
155
158
|
session_id=session_id,
|
|
159
|
+
priority=priority,
|
|
156
160
|
**kwargs
|
|
157
161
|
)
|
|
158
162
|
|
|
@@ -171,6 +175,7 @@ class BaseJob(WorkspaceItem):
|
|
|
171
175
|
input_params: Dict[str, Any] = None,
|
|
172
176
|
submit_job: bool = True,
|
|
173
177
|
session_id: Optional[str] = None,
|
|
178
|
+
priority: Optional[str] = None,
|
|
174
179
|
**kwargs
|
|
175
180
|
) -> "BaseJob":
|
|
176
181
|
"""Create new Job from URI if input data is already uploaded
|
|
@@ -198,6 +203,8 @@ class BaseJob(WorkspaceItem):
|
|
|
198
203
|
:type input_params: Dict[str, Any]
|
|
199
204
|
:param submit_job: If job should be submitted to the service, defaults to True
|
|
200
205
|
:type submit_job: bool
|
|
206
|
+
:param priority: Priority of job.
|
|
207
|
+
:type priority: str
|
|
201
208
|
:return: Job instance
|
|
202
209
|
:rtype: Job
|
|
203
210
|
"""
|
|
@@ -223,6 +230,7 @@ class BaseJob(WorkspaceItem):
|
|
|
223
230
|
target=target,
|
|
224
231
|
input_params=input_params,
|
|
225
232
|
session_id=session_id,
|
|
233
|
+
priority=priority,
|
|
226
234
|
**kwargs
|
|
227
235
|
)
|
|
228
236
|
job = cls(workspace, details, **kwargs)
|
azure/quantum/job/job.py
CHANGED
|
@@ -125,7 +125,7 @@ class Job(BaseJob, FilteredJob):
|
|
|
125
125
|
if not self.has_completed():
|
|
126
126
|
self.wait_until_completed(timeout_secs=timeout_secs)
|
|
127
127
|
|
|
128
|
-
if not self.details.status == "Succeeded"
|
|
128
|
+
if not self.details.status == "Succeeded" and not self.details.status == "Completed":
|
|
129
129
|
if self.details.status == "Failed" and self._allow_failure_results():
|
|
130
130
|
job_blob_properties = self.download_blob_properties(self.details.output_data_uri)
|
|
131
131
|
if job_blob_properties.size > 0:
|
azure/quantum/job/session.py
CHANGED
|
@@ -48,6 +48,9 @@ class Session(WorkspaceItem):
|
|
|
48
48
|
close and not accept further jobs.
|
|
49
49
|
:type job_failure_policy: Union[str, SessionJobFailurePolicy, None]
|
|
50
50
|
|
|
51
|
+
:param priority: Priority of the session.
|
|
52
|
+
:type priority: Optional[str]
|
|
53
|
+
|
|
51
54
|
:raises ValueError: if details is passed along individual parameters,
|
|
52
55
|
or if required parameters are missing.
|
|
53
56
|
"""
|
|
@@ -61,6 +64,7 @@ class Session(WorkspaceItem):
|
|
|
61
64
|
id: Optional[str] = None,
|
|
62
65
|
name: Optional[str] = None,
|
|
63
66
|
job_failure_policy: Union[str, SessionJobFailurePolicy, None] = None,
|
|
67
|
+
priority: Optional[str] = None,
|
|
64
68
|
**kwargs):
|
|
65
69
|
from azure.quantum.target import Target
|
|
66
70
|
target_name = target.name if isinstance(target, Target) else target
|
|
@@ -92,6 +96,7 @@ class Session(WorkspaceItem):
|
|
|
92
96
|
provider_id=provider_id,
|
|
93
97
|
target=target_name,
|
|
94
98
|
job_failure_policy=job_failure_policy,
|
|
99
|
+
priority=priority,
|
|
95
100
|
**kwargs)
|
|
96
101
|
|
|
97
102
|
super().__init__(
|
|
@@ -259,6 +264,7 @@ class SessionHost(Protocol):
|
|
|
259
264
|
id: Optional[str] = None,
|
|
260
265
|
name: Optional[str] = None,
|
|
261
266
|
job_failure_policy: Union[str, SessionJobFailurePolicy, None] = None,
|
|
267
|
+
priority: Optional[str] = None,
|
|
262
268
|
**kwargs
|
|
263
269
|
) -> Session:
|
|
264
270
|
"""Opens a session and associates all future job submissions to that
|
|
@@ -295,6 +301,10 @@ class SessionHost(Protocol):
|
|
|
295
301
|
|
|
296
302
|
:param job_failure_policy: The policy that determines when a session would fail,
|
|
297
303
|
close and not accept further jobs.
|
|
304
|
+
:type job_failure_policy: Union[str, SessionJobFailurePolicy, None]
|
|
305
|
+
|
|
306
|
+
:param priority: Priority of the session.
|
|
307
|
+
:type priority: Optional[str]
|
|
298
308
|
|
|
299
309
|
:return: The session object with updated details after its opening.
|
|
300
310
|
:rtype: Session
|
|
@@ -309,6 +319,7 @@ class SessionHost(Protocol):
|
|
|
309
319
|
workspace=self._get_azure_workspace(),
|
|
310
320
|
target=self._get_azure_target_id(),
|
|
311
321
|
provider_id=self._get_azure_provider_id(),
|
|
322
|
+
priority=priority,
|
|
312
323
|
**kwargs)
|
|
313
324
|
self.latest_session = session
|
|
314
325
|
return session.open()
|
azure/quantum/target/target.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
# Licensed under the MIT License.
|
|
4
4
|
##
|
|
5
|
-
from typing import TYPE_CHECKING, Any, Dict, Union, Type,
|
|
5
|
+
from typing import TYPE_CHECKING, Any, Dict, Union, Type, Optional, Protocol, runtime_checkable
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
import io
|
|
8
8
|
import json
|
|
@@ -210,6 +210,7 @@ target '{self.name}' of provider '{self.provider_id}' not found."
|
|
|
210
210
|
name: str = "azure-quantum-job",
|
|
211
211
|
shots: int = None,
|
|
212
212
|
input_params: Union[Dict[str, Any], InputParams, None] = None,
|
|
213
|
+
priority: Optional[str] = None,
|
|
213
214
|
**kwargs
|
|
214
215
|
) -> Job:
|
|
215
216
|
"""Submit input data and return Job.
|
|
@@ -225,6 +226,8 @@ target '{self.name}' of provider '{self.provider_id}' not found."
|
|
|
225
226
|
:type shots: int
|
|
226
227
|
:param input_params: Input parameters
|
|
227
228
|
:type input_params: Dict[str, Any]
|
|
229
|
+
:param priority: Priority of job.
|
|
230
|
+
:type priority: str
|
|
228
231
|
:return: Azure Quantum job
|
|
229
232
|
:rtype: azure.quantum.job.Job
|
|
230
233
|
"""
|
|
@@ -320,6 +323,7 @@ target '{self.name}' of provider '{self.provider_id}' not found."
|
|
|
320
323
|
output_data_format=output_data_format,
|
|
321
324
|
input_params=input_params,
|
|
322
325
|
session_id=self.get_latest_session_id(),
|
|
326
|
+
priority=priority,
|
|
323
327
|
**kwargs
|
|
324
328
|
)
|
|
325
329
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import warnings
|
|
6
6
|
from typing import Any, Dict, List, TYPE_CHECKING, Union, Type
|
|
7
7
|
from azure.quantum.target import *
|
|
8
|
+
from azure.quantum._constants import WorkspaceKind
|
|
8
9
|
|
|
9
10
|
if TYPE_CHECKING:
|
|
10
11
|
from azure.quantum import Workspace
|
|
@@ -134,10 +135,16 @@ class TargetFactory:
|
|
|
134
135
|
return result
|
|
135
136
|
|
|
136
137
|
else:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
if self._workspace._connection_params.workspace_kind == WorkspaceKind.V1:
|
|
139
|
+
# Filter only relevant targets for user's selected framework like Cirq, Qiskit, etc.
|
|
140
|
+
return [
|
|
141
|
+
self.from_target_status(_provider_id, status, **kwargs)
|
|
142
|
+
for _provider_id, status in target_statuses
|
|
143
|
+
if _provider_id.lower() in self._default_targets
|
|
144
|
+
or status.id in self._all_targets
|
|
145
|
+
]
|
|
146
|
+
else:
|
|
147
|
+
return [
|
|
148
|
+
self.from_target_status(_provider_id, status, **kwargs)
|
|
149
|
+
for _provider_id, status in target_statuses
|
|
150
|
+
]
|
azure/quantum/version.py
CHANGED
azure/quantum/workspace.py
CHANGED
|
@@ -23,14 +23,14 @@ from typing import (
|
|
|
23
23
|
)
|
|
24
24
|
from typing_extensions import Self
|
|
25
25
|
from azure.core.paging import ItemPaged
|
|
26
|
-
from azure.quantum._client import
|
|
26
|
+
from azure.quantum._client import WorkspaceClient
|
|
27
27
|
from azure.quantum._client.models import JobDetails, ItemDetails, SessionDetails
|
|
28
|
-
from azure.quantum._client.operations import (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
from azure.quantum._client.operations._operations import (
|
|
29
|
+
ServicesJobsOperations,
|
|
30
|
+
ServicesStorageOperations,
|
|
31
|
+
ServicesQuotasOperations,
|
|
32
|
+
ServicesSessionsOperations,
|
|
33
|
+
ServicesTopLevelItemsOperations
|
|
34
34
|
)
|
|
35
35
|
from azure.quantum._client.models import (
|
|
36
36
|
BlobDetails,
|
|
@@ -117,6 +117,7 @@ class Workspace:
|
|
|
117
117
|
# Internal parameter names
|
|
118
118
|
_FROM_CONNECTION_STRING_PARAM = '_from_connection_string'
|
|
119
119
|
_QUANTUM_ENDPOINT_PARAM = '_quantum_endpoint'
|
|
120
|
+
_WORKSPACE_KIND_PARAM = '_workspace_kind'
|
|
120
121
|
_MGMT_CLIENT_PARAM = '_mgmt_client'
|
|
121
122
|
|
|
122
123
|
def __init__(
|
|
@@ -136,6 +137,7 @@ class Workspace:
|
|
|
136
137
|
from_connection_string = kwargs.pop(Workspace._FROM_CONNECTION_STRING_PARAM, False)
|
|
137
138
|
# In case from connection string, quantum_endpoint must be passed
|
|
138
139
|
quantum_endpoint = kwargs.pop(Workspace._QUANTUM_ENDPOINT_PARAM, None)
|
|
140
|
+
workspace_kind = kwargs.pop(Workspace._WORKSPACE_KIND_PARAM, None)
|
|
139
141
|
# Params to pass a mock in tests
|
|
140
142
|
self._mgmt_client = kwargs.pop(Workspace._MGMT_CLIENT_PARAM, None)
|
|
141
143
|
|
|
@@ -148,6 +150,7 @@ class Workspace:
|
|
|
148
150
|
resource_id=resource_id,
|
|
149
151
|
quantum_endpoint=quantum_endpoint,
|
|
150
152
|
user_agent=user_agent,
|
|
153
|
+
workspace_kind=workspace_kind,
|
|
151
154
|
**kwargs
|
|
152
155
|
).default_from_env_vars()
|
|
153
156
|
|
|
@@ -186,7 +189,7 @@ class Workspace:
|
|
|
186
189
|
|
|
187
190
|
connection_params.assert_complete()
|
|
188
191
|
|
|
189
|
-
# Create
|
|
192
|
+
# Create WorkspaceClient
|
|
190
193
|
self._client = self._create_client()
|
|
191
194
|
|
|
192
195
|
def _on_new_client_request(self) -> None:
|
|
@@ -259,18 +262,18 @@ class Workspace:
|
|
|
259
262
|
"""
|
|
260
263
|
return self._storage
|
|
261
264
|
|
|
262
|
-
def _create_client(self) ->
|
|
265
|
+
def _create_client(self) -> WorkspaceClient:
|
|
263
266
|
""""
|
|
264
267
|
An internal method to (re)create the underlying Azure SDK REST API client.
|
|
265
268
|
|
|
266
269
|
:return: Azure SDK REST API client for Azure Quantum.
|
|
267
|
-
:rtype:
|
|
270
|
+
:rtype: WorkspaceClient
|
|
268
271
|
"""
|
|
269
272
|
connection_params = self._connection_params
|
|
270
273
|
kwargs = {}
|
|
271
274
|
if connection_params.api_version:
|
|
272
275
|
kwargs["api_version"] = connection_params.api_version
|
|
273
|
-
client =
|
|
276
|
+
client = WorkspaceClient(
|
|
274
277
|
region=connection_params.location,
|
|
275
278
|
credential=connection_params.get_credential_or_default(),
|
|
276
279
|
subscription_id=connection_params.subscription_id,
|
|
@@ -320,6 +323,7 @@ class Workspace:
|
|
|
320
323
|
connection_params = WorkspaceConnectionParams(connection_string=connection_string)
|
|
321
324
|
kwargs[cls._FROM_CONNECTION_STRING_PARAM] = True
|
|
322
325
|
kwargs[cls._QUANTUM_ENDPOINT_PARAM] = connection_params.quantum_endpoint
|
|
326
|
+
kwargs[cls._WORKSPACE_KIND_PARAM] = connection_params.workspace_kind.value if connection_params.workspace_kind else None
|
|
323
327
|
return cls(
|
|
324
328
|
subscription_id=connection_params.subscription_id,
|
|
325
329
|
resource_group=connection_params.resource_group,
|
|
@@ -328,55 +332,55 @@ class Workspace:
|
|
|
328
332
|
credential=connection_params.get_credential_or_default(),
|
|
329
333
|
**kwargs)
|
|
330
334
|
|
|
331
|
-
def _get_top_level_items_client(self) ->
|
|
335
|
+
def _get_top_level_items_client(self) -> ServicesTopLevelItemsOperations:
|
|
332
336
|
"""
|
|
333
337
|
Returns the internal Azure SDK REST API client
|
|
334
338
|
for the `{workspace}/topLevelItems` API.
|
|
335
339
|
|
|
336
340
|
:return: REST API client for the `topLevelItems` API.
|
|
337
|
-
:rtype:
|
|
341
|
+
:rtype: ServicesTopLevelItemsOperations
|
|
338
342
|
"""
|
|
339
|
-
return self._client.top_level_items
|
|
343
|
+
return self._client.services.top_level_items
|
|
340
344
|
|
|
341
|
-
def _get_sessions_client(self) ->
|
|
345
|
+
def _get_sessions_client(self) -> ServicesSessionsOperations:
|
|
342
346
|
"""
|
|
343
347
|
Returns the internal Azure SDK REST API client
|
|
344
348
|
for the `{workspace}/sessions` API.
|
|
345
349
|
|
|
346
350
|
:return: REST API client for the `sessions` API.
|
|
347
|
-
:rtype:
|
|
351
|
+
:rtype: ServicesSessionsOperations
|
|
348
352
|
"""
|
|
349
|
-
return self._client.sessions
|
|
353
|
+
return self._client.services.sessions
|
|
350
354
|
|
|
351
|
-
def _get_jobs_client(self) ->
|
|
355
|
+
def _get_jobs_client(self) -> ServicesJobsOperations:
|
|
352
356
|
"""
|
|
353
357
|
Returns the internal Azure SDK REST API client
|
|
354
358
|
for the `{workspace}/jobs` API.
|
|
355
359
|
|
|
356
360
|
:return: REST API client for the `jobs` API.
|
|
357
|
-
:rtype:
|
|
361
|
+
:rtype: ServicesJobsOperations
|
|
358
362
|
"""
|
|
359
|
-
return self._client.jobs
|
|
363
|
+
return self._client.services.jobs
|
|
360
364
|
|
|
361
|
-
def _get_workspace_storage_client(self) ->
|
|
365
|
+
def _get_workspace_storage_client(self) -> ServicesStorageOperations:
|
|
362
366
|
"""
|
|
363
367
|
Returns the internal Azure SDK REST API client
|
|
364
368
|
for the `{workspace}/storage` API.
|
|
365
369
|
|
|
366
370
|
:return: REST API client for the `storage` API.
|
|
367
|
-
:rtype:
|
|
371
|
+
:rtype: ServicesStorageOperations
|
|
368
372
|
"""
|
|
369
|
-
return self._client.storage
|
|
373
|
+
return self._client.services.storage
|
|
370
374
|
|
|
371
|
-
def _get_quotas_client(self) ->
|
|
375
|
+
def _get_quotas_client(self) -> ServicesQuotasOperations:
|
|
372
376
|
"""
|
|
373
377
|
Returns the internal Azure SDK REST API client
|
|
374
378
|
for the `{workspace}/quotas` API.
|
|
375
379
|
|
|
376
380
|
:return: REST API client for the `quotas` API.
|
|
377
|
-
:rtype:
|
|
381
|
+
:rtype: ServicesQuotasOperations
|
|
378
382
|
"""
|
|
379
|
-
return self._client.quotas
|
|
383
|
+
return self._client.services.quotas
|
|
380
384
|
|
|
381
385
|
def _get_linked_storage_sas_uri(
|
|
382
386
|
self,
|
|
@@ -420,7 +424,7 @@ class Workspace:
|
|
|
420
424
|
:rtype: Job
|
|
421
425
|
"""
|
|
422
426
|
client = self._get_jobs_client()
|
|
423
|
-
details = client.
|
|
427
|
+
details = client.create(
|
|
424
428
|
self.subscription_id,
|
|
425
429
|
self.resource_group,
|
|
426
430
|
self.name,
|
|
@@ -576,7 +580,7 @@ class Workspace:
|
|
|
576
580
|
"""
|
|
577
581
|
return [
|
|
578
582
|
(provider.id, target)
|
|
579
|
-
for provider in self._client.providers.list(
|
|
583
|
+
for provider in self._client.services.providers.list(
|
|
580
584
|
self.subscription_id,
|
|
581
585
|
self.resource_group,
|
|
582
586
|
self.name)
|
|
@@ -709,7 +713,7 @@ class Workspace:
|
|
|
709
713
|
)
|
|
710
714
|
orderby = self._create_orderby(orderby_property, is_asc)
|
|
711
715
|
|
|
712
|
-
return client.
|
|
716
|
+
return client.listv2(subscription_id=self.subscription_id, resource_group_name=self.resource_group, workspace_name=self.name, filter=top_level_item_filter, orderby=orderby, top = top, skip = skip)
|
|
713
717
|
|
|
714
718
|
def list_sessions(
|
|
715
719
|
self,
|
|
@@ -770,7 +774,7 @@ class Workspace:
|
|
|
770
774
|
|
|
771
775
|
orderby = self._create_orderby(orderby_property=orderby_property, is_asc=is_asc)
|
|
772
776
|
|
|
773
|
-
return client.
|
|
777
|
+
return client.listv2(subscription_id=self.subscription_id, resource_group_name=self.resource_group, workspace_name=self.name, filter = session_filter, orderby=orderby, skip=skip, top=top)
|
|
774
778
|
|
|
775
779
|
def open_session(
|
|
776
780
|
self,
|
|
@@ -786,7 +790,7 @@ class Workspace:
|
|
|
786
790
|
:rtype: Session
|
|
787
791
|
"""
|
|
788
792
|
client = self._get_sessions_client()
|
|
789
|
-
session.details = client.
|
|
793
|
+
session.details = client.open(
|
|
790
794
|
self.subscription_id,
|
|
791
795
|
self.resource_group,
|
|
792
796
|
self.name,
|