diff --git a/src/quantum/HISTORY.rst b/src/quantum/HISTORY.rst index 3d9d908164e..6cd6d1e8a39 100644 --- a/src/quantum/HISTORY.rst +++ b/src/quantum/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +1.0.0b17 ++++++++++++++++ +* Added ``--workspace-kind`` parameter to ``az quantum workspace create`` to support creating V2 workspaces. + 1.0.0b16 +++++++++++++++ * Removed deprecated ``--location``/``-l`` parameter from ``quantum execute``, ``quantum run``, ``quantum job submit``, ``quantum job cancel``, ``quantum job list``, ``quantum job output``, ``quantum job show``, ``quantum job wait``, ``quantum target list``, ``quantum workspace set``, and ``quantum workspace quotas`` commands. diff --git a/src/quantum/azext_quantum/_help.py b/src/quantum/azext_quantum/_help.py index addd20e00da..5707ce1b7df 100644 --- a/src/quantum/azext_quantum/_help.py +++ b/src/quantum/azext_quantum/_help.py @@ -260,6 +260,10 @@ -r "MyProvider1 / MySKU1, MyProvider2 / MySKU2" --skip-autoadd -a MyStorageAccountName\n To display a list of available providers and their SKUs, use the following command: az quantum offerings list -l MyLocation -o table + - name: Create a new Azure Quantum V2 workspace. + text: |- + az quantum workspace create -g MyResourceGroup -w MyWorkspace -l MyLocation \\ + -a MyStorageAccountName --workspace-kind V2 """ helps['quantum workspace delete'] = """ diff --git a/src/quantum/azext_quantum/_params.py b/src/quantum/azext_quantum/_params.py index db958b7b54a..95f272297f7 100644 --- a/src/quantum/azext_quantum/_params.py +++ b/src/quantum/azext_quantum/_params.py @@ -55,6 +55,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals job_output_format_type = CLIArgumentType(help='The expected job output format') entry_point_type = CLIArgumentType(help='The entry point for the QIR program or circuit. Required for some provider QIR jobs.') skip_autoadd_type = CLIArgumentType(help='If specified, the plans that offer free credits will not automatically be added.') + workspace_kind_type = CLIArgumentType(options_list=['--workspace-kind'], help='The kind of the workspace to create.', choices=['V1', 'V2']) key_type = CLIArgumentType(options_list=['--key-type'], help='The api keys to be regenerated, should be Primary and/or Secondary.') enable_key_type = CLIArgumentType(options_list=['--enable-api-key'], help='Enable or disable API key authentication.') job_type_type = CLIArgumentType(options_list=['--job-type'], help='Job type to be listed, example "QuantumComputing".') @@ -75,6 +76,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals c.argument('provider_sku_list', provider_sku_list_type) c.argument('auto_accept', auto_accept_type) c.argument('skip_autoadd', skip_autoadd_type) + c.argument('workspace_kind', workspace_kind_type) with self.argument_context('quantum target') as c: c.argument('workspace_name', workspace_name_type) diff --git a/src/quantum/azext_quantum/operations/templates/create-workspace-and-assign-role.json b/src/quantum/azext_quantum/operations/templates/create-workspace-and-assign-role.json index 32d1fedef93..c82e4937c5a 100644 --- a/src/quantum/azext_quantum/operations/templates/create-workspace-and-assign-role.json +++ b/src/quantum/azext_quantum/operations/templates/create-workspace-and-assign-role.json @@ -69,6 +69,13 @@ "metadata": { "description": "Whether to allow shared key access on the storage account. Defaults to false (secure) for new accounts; existing accounts should pass their current value to avoid breaking changes." } + }, + "workspaceKind": { + "type": "string", + "defaultValue": "V1", + "metadata": { + "description": "The kind of workspace to create: V1 or V2. Defaults to V1." + } } }, "functions": [], @@ -88,7 +95,8 @@ }, "properties": { "providers": "[parameters('providers')]", - "storageAccount": "[parameters('storageAccountId')]" + "storageAccount": "[parameters('storageAccountId')]", + "workspaceKind": "[parameters('workspaceKind')]" } }, { diff --git a/src/quantum/azext_quantum/operations/workspace.py b/src/quantum/azext_quantum/operations/workspace.py index 77d58c4bff2..b581d74cac5 100644 --- a/src/quantum/azext_quantum/operations/workspace.py +++ b/src/quantum/azext_quantum/operations/workspace.py @@ -195,7 +195,7 @@ def _validate_storage_account(tier_or_kind_msg_text, tier_or_kind, supported_tie def create(cmd, resource_group_name, workspace_name, location, storage_account, skip_role_assignment=False, - provider_sku_list=None, auto_accept=False, skip_autoadd=False): + provider_sku_list=None, auto_accept=False, skip_autoadd=False, workspace_kind=None): """ Create a new Azure Quantum workspace. """ @@ -215,6 +215,7 @@ def create(cmd, resource_group_name, workspace_name, location, storage_account, if skip_role_assignment: _add_quantum_providers(cmd, quantum_workspace, provider_sku_list, auto_accept, skip_autoadd) quantum_workspace.properties.api_key_enabled = True + quantum_workspace.properties.workspace_kind = workspace_kind or 'V1' poller = client.begin_create_or_update(info.resource_group, info.name, quantum_workspace, polling=False) while not poller.done(): time.sleep(POLLING_TIME_DURATION) @@ -269,7 +270,8 @@ def create(cmd, resource_group_name, workspace_name, location, storage_account, 'storageAccountSku': storage_account_sku, 'storageAccountKind': storage_account_kind, 'storageAccountAllowSharedKeyAccess': storage_account_allow_shared_key_access, - 'storageAccountDeploymentName': "Microsoft.StorageAccount-" + time.strftime("%d-%b-%Y-%H-%M-%S", time.gmtime()) + 'storageAccountDeploymentName': "Microsoft.StorageAccount-" + time.strftime("%d-%b-%Y-%H-%M-%S", time.gmtime()), + 'workspaceKind': workspace_kind or 'V1' } parameters = {k: {'value': v} for k, v in parameters.items()} diff --git a/src/quantum/azext_quantum/tests/latest/test_quantum_workspace.py b/src/quantum/azext_quantum/tests/latest/test_quantum_workspace.py index f204e172b25..ae84e729383 100644 --- a/src/quantum/azext_quantum/tests/latest/test_quantum_workspace.py +++ b/src/quantum/azext_quantum/tests/latest/test_quantum_workspace.py @@ -319,3 +319,18 @@ def test_autoadd_providers(self): workspace_location = None _autoadd_providers(cmd, providers_in_region, providers_selected, workspace_location, True) assert providers_selected[0] == {"provider_id": "foo", "sku": "foo_credits_for_all_plan", "offer_id": "foo_offer", "publisher_id": "foo0123456789"} + + def test_workspace_kind(self): + from ...vendored_sdks.azure_mgmt_quantum.models import WorkspaceResourceProperties, WorkspaceKind + + # No kind set: field must be absent from the serialized body (not null) + assert "workspaceKind" not in WorkspaceResourceProperties().serialize() + + # V1 and V2 serialize to their expected wire values + assert WorkspaceResourceProperties(workspace_kind=WorkspaceKind.V1).serialize().get("workspaceKind") == "V1" + assert WorkspaceResourceProperties(workspace_kind=WorkspaceKind.V2).serialize().get("workspaceKind") == "V2" + + # workspace_kind can be assigned after construction (skip_role_assignment path) + props = WorkspaceResourceProperties() + props.workspace_kind = WorkspaceKind.V2 + assert props.serialize().get("workspaceKind") == "V2" \ No newline at end of file diff --git a/src/quantum/setup.py b/src/quantum/setup.py index bfb9fcd560d..a8046ab6621 100644 --- a/src/quantum/setup.py +++ b/src/quantum/setup.py @@ -17,7 +17,7 @@ # This version should match the latest entry in HISTORY.rst # Also, when updating this, please review the version used by the extension to # submit requests, which can be found at './azext_quantum/__init__.py' -VERSION = '1.0.0b16' +VERSION = '1.0.0b17' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers