Skip to content

Commit 36ede5c

Browse files
authored
Quantum: support of Data Plane v2, priority in job params, skip container creation when retrieving linked storage (#9617)
* Updated azure quantum python dependency * Made work with DPv2, tested * Fix style check errors * Remove azure_quantum dependency as we use it inside azure_quantum_python * Location parameter is optional for most of the operations, add deprecation warning * Skip container creation when retrieving linked storage account from the service * Support providing priority in job params * Add new version to History * bypass unused argument style errors while we didn't remove not used location param to do not introduce breaking changes immediately
1 parent a4f9739 commit 36ede5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+4564
-6777
lines changed

src/quantum/HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Release History
44
===============
55

6+
1.0.0b12
7+
+++++++++++++++
8+
* Added support for Data Plane v2 including specifying priority parameter as part of job params when submitting a job
9+
* Removed container creation logic when retrieving linked storage account from the service
10+
611
1.0.0b11
712
+++++++++++++++
813
* Remove `__import__('pkg_resources').declare_namespace(__name__)` to fix the namespace package issue.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
from azure.cli.core.breaking_change import register_argument_deprecate
6+
7+
register_argument_deprecate('quantum execute', '--location', target_version="May 2026")
8+
register_argument_deprecate('quantum run', '--location', target_version="May 2026")
9+
register_argument_deprecate('quantum job submit', '--location', target_version="May 2026")
10+
register_argument_deprecate('quantum job cancel', '--location', target_version="May 2026")
11+
register_argument_deprecate('quantum job list', '--location', target_version="May 2026")
12+
register_argument_deprecate('quantum job output', '--location', target_version="May 2026")
13+
register_argument_deprecate('quantum job show', '--location', target_version="May 2026")
14+
register_argument_deprecate('quantum job wait', '--location', target_version="May 2026")
15+
register_argument_deprecate('quantum target list', '--location', target_version="May 2026")
16+
register_argument_deprecate('quantum workspace set', '--location', target_version="May 2026")
17+
register_argument_deprecate('quantum workspace quotas', '--location', target_version="May 2026")

src/quantum/azext_quantum/_client_factory.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import os
99
from ._location_helper import normalize_location
1010
from .__init__ import CLI_REPORTED_VERSION
11+
from .vendored_sdks.azure_quantum_python._client import WorkspaceClient
12+
from .vendored_sdks.azure_mgmt_quantum import AzureQuantumManagementClient
1113

1214

1315
def is_env(name):
@@ -38,9 +40,8 @@ def get_appid():
3840

3941
# Control Plane clients
4042

41-
def cf_quantum_mgmt(cli_ctx, *_):
43+
def cf_quantum_mgmt(cli_ctx, *_) -> AzureQuantumManagementClient:
4244
from azure.cli.core.commands.client_factory import get_mgmt_service_client
43-
from .vendored_sdks.azure_mgmt_quantum import AzureQuantumManagementClient
4445
client = get_mgmt_service_client(cli_ctx, AzureQuantumManagementClient, base_url_bound=False)
4546
# Add user agent on the management client to include extension information
4647
client._config.user_agent_policy.add_user_agent(get_appid())
@@ -61,22 +62,26 @@ def cf_offerings(cli_ctx, *_):
6162

6263
# Data Plane clients
6364

64-
def cf_quantum(cli_ctx, subscription_id=None, location=None):
65-
from .vendored_sdks.azure_quantum import ServicesClient
66-
creds = _get_data_credentials(cli_ctx, subscription_id)
67-
return ServicesClient(location, creds)
65+
def cf_quantum(cli_ctx, subscription: str, resource_group: str, ws_name: str, endpoint: str | None) -> WorkspaceClient:
66+
creds = _get_data_credentials(cli_ctx, subscription)
67+
if not endpoint:
68+
client = cf_workspaces(cli_ctx)
69+
ws = client.get(resource_group, ws_name)
70+
endpoint = ws.properties.endpoint_uri
71+
ws_cl = WorkspaceClient(endpoint, creds)
72+
return ws_cl
6873

6974

70-
def cf_providers(cli_ctx, subscription_id=None, location=None):
71-
return cf_quantum(cli_ctx, subscription_id, location).providers
75+
def cf_providers(cli_ctx, subscription: str, resource_group: str, ws_name: str, endpoint: str | None):
76+
return cf_quantum(cli_ctx, subscription, resource_group, ws_name, endpoint).services.providers
7277

7378

74-
def cf_jobs(cli_ctx, subscription_id=None, location=None):
75-
return cf_quantum(cli_ctx, subscription_id, location).jobs
79+
def cf_jobs(cli_ctx, subscription: str, resource_group: str, ws_name: str, endpoint: str | None):
80+
return cf_quantum(cli_ctx, subscription, resource_group, ws_name, endpoint).services.jobs
7681

7782

78-
def cf_quotas(cli_ctx, subscription_id=None, location=None):
79-
return cf_quantum(cli_ctx, subscription_id, location).quotas
83+
def cf_quotas(cli_ctx, subscription: str, resource_group: str, ws_name: str, endpoint: str | None):
84+
return cf_quantum(cli_ctx, subscription, resource_group, ws_name, endpoint).services.quotas
8085

8186

8287
# Helper clients

src/quantum/azext_quantum/_validators.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,20 @@
99
from .operations.target import TargetInfo
1010

1111

12-
def validate_workspace_internal(cmd, namespace, require_location):
12+
def validate_workspace_info(cmd, namespace):
1313
"""
14-
Internal implementation to validate workspace info parameters with an optional location
14+
Makes sure all parameters for a workspace are available.
1515
"""
1616
group = getattr(namespace, 'resource_group_name', None)
1717
name = getattr(namespace, 'workspace_name', None)
18-
location = getattr(namespace, 'location', None)
19-
ws = WorkspaceInfo(cmd, group, name, location)
18+
ws = WorkspaceInfo(cmd, group, name)
2019

2120
if not ws.subscription:
2221
raise ValueError("Missing subscription argument")
2322
if not ws.resource_group:
2423
raise ValueError("Missing resource-group argument")
2524
if not ws.name:
2625
raise ValueError("Missing workspace-name argument")
27-
if require_location and not ws.location:
28-
raise ValueError("Missing location argument")
29-
30-
31-
def validate_workspace_info(cmd, namespace):
32-
"""
33-
Makes sure all parameters for a workspace are available including location.
34-
"""
35-
validate_workspace_internal(cmd, namespace, True)
36-
37-
38-
def validate_workspace_info_no_location(cmd, namespace):
39-
"""
40-
Makes sure all parameters for a workspace are available, not including location.
41-
"""
42-
validate_workspace_internal(cmd, namespace, False)
4326

4427

4528
def validate_target_info(cmd, namespace):

src/quantum/azext_quantum/commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from collections import OrderedDict
1111
from azure.cli.core.commands import CliCommandType
12-
from ._validators import validate_workspace_info, validate_target_info, validate_workspace_and_target_info, validate_workspace_info_no_location, validate_provider_and_sku_info
12+
from ._validators import validate_workspace_info, validate_target_info, validate_workspace_and_target_info, validate_provider_and_sku_info
1313

1414
logger = logging.getLogger(__name__)
1515

@@ -126,9 +126,9 @@ def load_command_table(self, _):
126126

127127
with self.command_group('quantum workspace', workspace_ops) as w:
128128
w.command('create', 'create')
129-
w.command('delete', 'delete', validator=validate_workspace_info_no_location)
129+
w.command('delete', 'delete', validator=validate_workspace_info)
130130
w.command('list', 'list')
131-
w.show_command('show', validator=validate_workspace_info_no_location)
131+
w.show_command('show', validator=validate_workspace_info)
132132
w.command('set', 'set', validator=validate_workspace_info)
133133
w.command('clear', 'clear')
134134
w.command('quotas', 'quotas', validator=validate_workspace_info)

0 commit comments

Comments
 (0)