Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable command 'az quantum workspace quotas' #31

Merged
merged 1 commit into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/quantum/azext_quantum/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ def cf_providers(cli_ctx, subscription_id=None, resource_group_name=None, worksp

def cf_jobs(cli_ctx, subscription_id=None, resource_group_name=None, workspace_name=None, location=None):
return cf_quantum(cli_ctx, subscription_id, resource_group_name, workspace_name, location).jobs


def cf_quotas(cli_ctx, subscription_id=None, resource_group_name=None, workspace_name=None, location=None):
return cf_quantum(cli_ctx, subscription_id, resource_group_name, workspace_name, location).quotas
3 changes: 3 additions & 0 deletions src/quantum/azext_quantum/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
- name: Select a default Azure Quantum workspace for future commands
text: |-
az quantum workspace set -g MyResourceGroup -w MyWorkspace -l MyLocation
- name: List the quota information of a workspace
text: |-
az quantum workspace quotas -g MyResourceGroup -w MyWorkspace -l MyLocation
- name: Show the currently selected default Azure Quantum workspace
text: |-
az quantum workspace show
Expand Down
1 change: 1 addition & 0 deletions src/quantum/azext_quantum/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def load_command_table(self, _):
w.command('show', 'show', validator=validate_workspace_info_no_location)
w.command('set', 'set', validator=validate_workspace_info)
w.command('clear', 'clear')
w.command('quotas', 'quotas', validator=validate_workspace_info)

with self.command_group('quantum target', target_ops) as t:
t.command('list', 'list', validator=validate_workspace_info, table_transformer=transform_targets)
Expand Down
16 changes: 13 additions & 3 deletions src/quantum/azext_quantum/operations/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from knack.util import CLIError

from .._client_factory import cf_workspaces
from .._client_factory import cf_workspaces, cf_quotas
from ..vendored_sdks.azure_mgmt_quantum.models import QuantumWorkspace
from ..vendored_sdks.azure_mgmt_quantum.models import QuantumWorkspaceIdentity
from ..vendored_sdks.azure_mgmt_quantum.models import Provider
Expand Down Expand Up @@ -123,8 +123,8 @@ def create(cmd, resource_group_name=None, workspace_name=None, location=None, st
info = WorkspaceInfo(cmd, resource_group_name, workspace_name, location)
if (not info.resource_group):
raise CLIError("Please run 'az quantum workspace set' first to select a default resource group.")
_show_tip(f"Workspace {info.name} will be created with the Basic SKU of the Microsoft QIO optimization provider.")
_show_tip("Please go to the Azure portal https://portal.azure.com/ to configure additional providers.")
_show_tip(f"Workspace {info.name} will be created with the Basic SKU of the Microsoft QIO optimization provider.\n"
"Please go to the Azure portal https://portal.azure.com/ to configure additional providers.")
quantum_workspace = _get_basic_quantum_workspace(location, info, storage_account)
poller = client.create_or_update(info.resource_group, info.name, quantum_workspace, polling=False)
while not poller.done():
Expand All @@ -151,6 +151,7 @@ def delete(cmd, resource_group_name=None, workspace_name=None):
ws = client.get(info.resource_group, info.name)
return ws


def list(cmd, resource_group_name=None, tag=None, location=None):
"""
Get the list of Azure Quantum workspaces available.
Expand All @@ -171,6 +172,15 @@ def show(cmd, resource_group_name=None, workspace_name=None):
return ws


def quotas(cmd, resource_group_name=None, workspace_name=None, location=None):
"""
List the quotas for the given (or current) Azure Quantum workspace.
"""
info = WorkspaceInfo(cmd, resource_group_name, workspace_name, location)
client = cf_quotas(cmd.cli_ctx, info.subscription, info.resource_group, info.name, info.location)
return client.list()


def set(cmd, workspace_name, resource_group_name=None, location=None):
"""
Set the default Azure Quantum workspace.
Expand Down