Skip to content

Commit

Permalink
Fixing tests for multi-region URL change on Az CLI quantum extension (#…
Browse files Browse the repository at this point in the history
…19)

Fixing tests for multi-region URL change on Az CLI quantum extension
  • Loading branch information
ricardo-espinoza authored Dec 10, 2020
1 parent 0b230ee commit 6445133
Show file tree
Hide file tree
Showing 8 changed files with 363 additions and 60 deletions.
11 changes: 7 additions & 4 deletions src/quantum/azext_quantum/operations/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def _generate_submit_args(program_args, ws, target, token, project, job_name, sh
args.append("--workspace")
args.append(ws.name)

args.append("--location")
args.append(ws.location)

args.append("--target")
args.append(target.target_id)

Expand All @@ -103,7 +106,7 @@ def _generate_submit_args(program_args, ws, target, token, project, job_name, sh
args.append(token)

args.append("--base-uri")
args.append(base_url())
args.append(base_url(ws.location))

args.extend(program_args)

Expand All @@ -113,8 +116,8 @@ def _generate_submit_args(program_args, ws, target, token, project, job_name, sh
return args


def submit(cmd, program_args, resource_group_name=None, workspace_name=None, target_id=None, project=None,
job_name=None, shots=None, storage=None, no_build=False):
def submit(cmd, program_args, resource_group_name=None, workspace_name=None, location=None,
target_id=None, project=None, job_name=None, shots=None, storage=None, no_build=False):
"""
Submit a Q# project for execution to Azure Quantum.
"""
Expand All @@ -127,7 +130,7 @@ def submit(cmd, program_args, resource_group_name=None, workspace_name=None, tar

logger.info("Project built successfully.")

ws = WorkspaceInfo(cmd, resource_group_name, workspace_name)
ws = WorkspaceInfo(cmd, resource_group_name, workspace_name, location)
target = TargetInfo(cmd, target_id)
token = _get_data_credentials(cmd.cli_ctx, ws.subscription).get_token().token

Expand Down
4 changes: 2 additions & 2 deletions src/quantum/azext_quantum/operations/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ def show(cmd, resource_group_name=None, workspace_name=None):
return ws


def set(cmd, workspace_name, resource_group_name=None):
def set(cmd, workspace_name, resource_group_name=None, location=None):
"""
Set the default Azure Quantum workspace.
"""
client = cf_workspaces(cmd.cli_ctx)
info = WorkspaceInfo(cmd, resource_group_name, workspace_name)
info = WorkspaceInfo(cmd, resource_group_name, workspace_name, location)
ws = client.get(info.resource_group, info.name)
if ws:
info.save(cmd)
Expand Down
97 changes: 97 additions & 0 deletions src/quantum/azext_quantum/tests/latest/recordings/test_jobs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
interactions:
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- quantum workspace set
Connection:
- keep-alive
ParameterSetName:
- -g -w -l
User-Agent:
- python/3.8.2 (Windows-10-10.0.19041-SP0) msrest/0.6.19 msrest_azure/0.6.4
quantummanagementclient/2019-11-04-preview Azure-SDK-For-Python AZURECLI/2.15.1
accept-language:
- en-US
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aqua-provider-validator/providers/Microsoft.Quantum/workspaces/validator-workspace-westus?api-version=2019-11-04-preview
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aqua-provider-validator/providers/microsoft.quantum/workspaces/validator-workspace-westus","name":"validator-workspace-westus","type":"microsoft.quantum/workspaces","location":"westus","properties":{"providers":[{"providerId":"Microsoft","providerSku":"Basic","applicationName":"validator-workspace-westus-Microsoft","provisioningState":"Succeeded"}],"provisioningState":"Succeeded","usable":"Yes"}}'
headers:
cache-control:
- no-cache
content-length:
- '473'
content-type:
- application/json; charset=utf-8
date:
- Thu, 10 Dec 2020 00:41:54 GMT
etag:
- '"57010011-0000-0700-0000-5fa604730000"'
expires:
- '-1'
pragma:
- no-cache
server:
- Kestrel
strict-transport-security:
- max-age=31536000; includeSubDomains
transfer-encoding:
- chunked
vary:
- Accept-Encoding
x-content-type-options:
- nosniff
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- python/3.8.2 (Windows-10-10.0.19041-SP0) msrest/0.6.19 msrest_azure/0.6.4
quantumclient/2019-11-04-preview Azure-SDK-For-Python
accept-language:
- en-US
method: GET
uri: https://westus.quantum.azure.com/v1.0/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aqua-provider-validator/providers/Microsoft.Quantum/workspaces/validator-workspace-westus/providerStatus
response:
body:
string: '{"value":[{"id":"Microsoft","currentAvailability":"Available","targets":[{"id":"microsoft.paralleltempering-parameterfree.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.paralleltempering.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing-parameterfree.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.tabu-parameterfree.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.tabu.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing-parameterfree.fpga","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing.fpga","currentAvailability":"Available","averageQueueTime":0,"statusPage":null}]}],"nextLink":null}'
headers:
content-length:
- '1040'
content-type:
- application/json; charset=utf-8
date:
- Thu, 10 Dec 2020 00:41:54 GMT
request-context:
- appId=cid-v1:4d6ac272-7369-45c6-9036-63d733c8519f
server:
- Microsoft-IIS/10.0
set-cookie:
- ARRAffinity=27001002d8b8551188d2c7cc4823ffdcadf45dae9b5914f9158d130543bcca9c;Path=/;HttpOnly;Secure;Domain=westus.quantum.azure.com
- ARRAffinitySameSite=27001002d8b8551188d2c7cc4823ffdcadf45dae9b5914f9158d130543bcca9c;Path=/;HttpOnly;SameSite=None;Secure;Domain=westus.quantum.azure.com
strict-transport-security:
- max-age=2592000
transfer-encoding:
- chunked
vary:
- Accept-Encoding
x-powered-by:
- ASP.NET
status:
code: 200
message: OK
version: 1
46 changes: 27 additions & 19 deletions src/quantum/azext_quantum/tests/latest/recordings/test_targets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,28 @@ interactions:
Connection:
- keep-alive
ParameterSetName:
- -g -w
- -g -w -l
User-Agent:
- python/3.7.4 (Windows-10-10.0.19041-SP0) msrest/0.6.13 msrest_azure/0.6.3
quantummanagementclient/2019-11-04-preview Azure-SDK-For-Python AZURECLI/2.7.0
- python/3.8.2 (Windows-10-10.0.19041-SP0) msrest/0.6.19 msrest_azure/0.6.4
quantummanagementclient/2019-11-04-preview Azure-SDK-For-Python AZURECLI/2.15.1
accept-language:
- en-US
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aqua-provider-validator/providers/microsoft.quantum/workspaces/validator-workspace-westus?api-version=2019-11-04-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aqua-provider-validator/providers/Microsoft.Quantum/workspaces/validator-workspace-westus?api-version=2019-11-04-preview
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aqua-provider-validator/providers/microsoft.quantum/workspaces/validator-workspace-westus","name":"validator-workspace-westus","type":"microsoft.quantum/workspaces","location":"westus","identity":null,"properties":{"providers":[{"providerId":"Microsoft","providerSku":"Basic","applicationName":"validator-workspace-westus-Microsoft","provisioningState":"Succeeded"}],"provisioningState":"Succeeded","usable":"Yes"}}'
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aqua-provider-validator/providers/microsoft.quantum/workspaces/validator-workspace-westus","name":"validator-workspace-westus","type":"microsoft.quantum/workspaces","location":"westus","properties":{"providers":[{"providerId":"Microsoft","providerSku":"Basic","applicationName":"validator-workspace-westus-Microsoft","provisioningState":"Succeeded"}],"provisioningState":"Succeeded","usable":"Yes"}}'
headers:
cache-control:
- no-cache
content-length:
- '489'
- '473'
content-type:
- application/json; charset=utf-8
date:
- Thu, 11 Jun 2020 09:18:59 GMT
- Thu, 10 Dec 2020 00:41:53 GMT
etag:
- '"57010011-0000-0700-0000-5fa604730000"'
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -58,30 +60,33 @@ interactions:
Connection:
- keep-alive
User-Agent:
- python/3.7.4 (Windows-10-10.0.19041-SP0) msrest/0.6.13 msrest_azure/0.6.3
- python/3.8.2 (Windows-10-10.0.19041-SP0) msrest/0.6.19 msrest_azure/0.6.4
quantumclient/2019-11-04-preview Azure-SDK-For-Python
accept-language:
- en-US
method: GET
uri: https://app-jobscheduler-prod.azurewebsites.net/v1.0/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aqua-provider-validator/providers/Microsoft.Quantum/workspaces/validator-workspace-westus/providerStatus
uri: https://westus.quantum.azure.com/v1.0/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aqua-provider-validator/providers/Microsoft.Quantum/workspaces/validator-workspace-westus/providerStatus
response:
body:
string: '{"value":[{"id":"Microsoft","currentAvailability":"Available","targets":[{"id":"p2","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"p3","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"s2","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"s3","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"a_s","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"a_p","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.paralleltempering-parameterfree.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.paralleltempering.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing-parameterfree.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.paralleltempering.fpga","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing.fpga","currentAvailability":"Available","averageQueueTime":0,"statusPage":null}]}],"nextLink":null}'
string: '{"value":[{"id":"Microsoft","currentAvailability":"Available","targets":[{"id":"microsoft.paralleltempering-parameterfree.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.paralleltempering.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing-parameterfree.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.tabu-parameterfree.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.tabu.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing-parameterfree.fpga","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing.fpga","currentAvailability":"Available","averageQueueTime":0,"statusPage":null}]}],"nextLink":null}'
headers:
content-length:
- '1321'
- '1040'
content-type:
- application/json; charset=utf-8
date:
- Thu, 11 Jun 2020 09:19:01 GMT
- Thu, 10 Dec 2020 00:41:54 GMT
request-context:
- appId=cid-v1:4d6ac272-7369-45c6-9036-63d733c8519f
server:
- Microsoft-IIS/10.0
set-cookie:
- ARRAffinity=08e31a4953421e4acc8f85a9de4c15a37fb2c04b2d4bea64f09dfa61db9f7085;Path=/;HttpOnly;Domain=app-jobscheduler-prod.azurewebsites.net
- ARRAffinity=27001002d8b8551188d2c7cc4823ffdcadf45dae9b5914f9158d130543bcca9c;Path=/;HttpOnly;Secure;Domain=westus.quantum.azure.com
- ARRAffinitySameSite=27001002d8b8551188d2c7cc4823ffdcadf45dae9b5914f9158d130543bcca9c;Path=/;HttpOnly;SameSite=None;Secure;Domain=westus.quantum.azure.com
strict-transport-security:
- max-age=2592000
transfer-encoding:
- chunked
vary:
- Accept-Encoding
x-powered-by:
Expand All @@ -99,30 +104,33 @@ interactions:
Connection:
- keep-alive
User-Agent:
- python/3.7.4 (Windows-10-10.0.19041-SP0) msrest/0.6.13 msrest_azure/0.6.3
- python/3.8.2 (Windows-10-10.0.19041-SP0) msrest/0.6.19 msrest_azure/0.6.4
quantumclient/2019-11-04-preview Azure-SDK-For-Python
accept-language:
- en-US
method: GET
uri: https://app-jobscheduler-prod.azurewebsites.net/v1.0/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aqua-provider-validator/providers/Microsoft.Quantum/workspaces/validator-workspace-westus/providerStatus
uri: https://westus.quantum.azure.com/v1.0/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aqua-provider-validator/providers/Microsoft.Quantum/workspaces/validator-workspace-westus/providerStatus
response:
body:
string: '{"value":[{"id":"Microsoft","currentAvailability":"Available","targets":[{"id":"p2","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"p3","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"s2","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"s3","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"a_s","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"a_p","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.paralleltempering-parameterfree.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.paralleltempering.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing-parameterfree.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.paralleltempering.fpga","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing.fpga","currentAvailability":"Available","averageQueueTime":0,"statusPage":null}]}],"nextLink":null}'
string: '{"value":[{"id":"Microsoft","currentAvailability":"Available","targets":[{"id":"microsoft.paralleltempering-parameterfree.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.paralleltempering.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing-parameterfree.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.tabu-parameterfree.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.tabu.cpu","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing-parameterfree.fpga","currentAvailability":"Available","averageQueueTime":0,"statusPage":null},{"id":"microsoft.simulatedannealing.fpga","currentAvailability":"Available","averageQueueTime":0,"statusPage":null}]}],"nextLink":null}'
headers:
content-length:
- '1321'
- '1040'
content-type:
- application/json; charset=utf-8
date:
- Thu, 11 Jun 2020 09:19:02 GMT
- Thu, 10 Dec 2020 00:41:54 GMT
request-context:
- appId=cid-v1:4d6ac272-7369-45c6-9036-63d733c8519f
server:
- Microsoft-IIS/10.0
set-cookie:
- ARRAffinity=08e31a4953421e4acc8f85a9de4c15a37fb2c04b2d4bea64f09dfa61db9f7085;Path=/;HttpOnly;Domain=app-jobscheduler-prod.azurewebsites.net
- ARRAffinity=27001002d8b8551188d2c7cc4823ffdcadf45dae9b5914f9158d130543bcca9c;Path=/;HttpOnly;Secure;Domain=westus.quantum.azure.com
- ARRAffinitySameSite=27001002d8b8551188d2c7cc4823ffdcadf45dae9b5914f9158d130543bcca9c;Path=/;HttpOnly;SameSite=None;Secure;Domain=westus.quantum.azure.com
strict-transport-security:
- max-age=2592000
transfer-encoding:
- chunked
vary:
- Accept-Encoding
x-powered-by:
Expand Down
Loading

0 comments on commit 6445133

Please sign in to comment.