From 5b2ece4886b02f862b32c1f073e0cd28c6a91093 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Thu, 18 Jun 2020 11:51:29 -0700 Subject: [PATCH] Make --storage option optional for Azure Quantum submissions --- .../Machine/QuantumMachineFactory.cs | 13 ++++++++----- src/Simulation/EntryPointDriver.Tests/Tests.fs | 10 +++++----- src/Simulation/EntryPointDriver/Azure.cs | 12 ++++++------ src/Simulation/EntryPointDriver/Driver.cs | 16 ++++++++-------- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/Azure/Azure.Quantum.Client/Machine/QuantumMachineFactory.cs b/src/Azure/Azure.Quantum.Client/Machine/QuantumMachineFactory.cs index fe7aa8a6184..fd709cee94e 100644 --- a/src/Azure/Azure.Quantum.Client/Machine/QuantumMachineFactory.cs +++ b/src/Azure/Azure.Quantum.Client/Machine/QuantumMachineFactory.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#nullable enable + using System; using Microsoft.Quantum.Runtime; @@ -13,9 +15,10 @@ public static class QuantumMachineFactory /// /// The Azure Quantum workspace. /// The execution target for job submission. - /// The connection string for the Azure storage account. + /// The connection string for the Azure storage account. /// A quantum machine for job submission targeting targetName. - public static IQuantumMachine? CreateMachine(IWorkspace workspace, string targetName, string storageAccountConnectionString) + public static IQuantumMachine? CreateMachine( + IWorkspace workspace, string targetName, string? storageConnectionString = null) { var machineName = targetName is null @@ -26,7 +29,7 @@ targetName is null ? "Microsoft.Quantum.Providers.Honeywell.Targets.HoneywellQuantumMachine, Microsoft.Quantum.Providers.Honeywell" : null; - Type machineType = null; + Type? machineType = null; if (machineName != null) { // First try to load the signed assembly with the correct version, then try the unsigned one. @@ -48,7 +51,7 @@ targetName is null machineType, targetName, workspace, - storageAccountConnectionString); + storageConnectionString); } } -} \ No newline at end of file +} diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.fs b/src/Simulation/EntryPointDriver.Tests/Tests.fs index 57f283a2d73..7f242fdc5a0 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.fs +++ b/src/Simulation/EntryPointDriver.Tests/Tests.fs @@ -179,8 +179,6 @@ let private testWith testNum defaultSimulator = /// Standard command-line arguments for the "submit" command without specifying a target. let private submitWithoutTarget = [ "submit" - "--storage" - "myStorage" "--subscription" "mySubscription" "--resource-group" @@ -550,10 +548,10 @@ let ``Submit uses default values`` () = given (submitWithNothingTarget @ ["--verbose"]) |> yields "The friendly URI for viewing job results is not available yet. Showing the job ID instead. Target: test.nothing - Storage: myStorage Subscription: mySubscription Resource Group: myResourceGroup Workspace: myWorkspace + Storage: AAD Token: Base URI: Job Name: @@ -569,6 +567,8 @@ let ``Submit allows overriding default values`` () = let given = test 1 given (submitWithNothingTarget @ [ "--verbose" + "--storage" + "myStorage" "--aad-token" "myToken" "--base-uri" @@ -580,10 +580,10 @@ let ``Submit allows overriding default values`` () = ]) |> yields "The friendly URI for viewing job results is not available yet. Showing the job ID instead. Target: test.nothing - Storage: myStorage Subscription: mySubscription Resource Group: myResourceGroup Workspace: myWorkspace + Storage: myStorage AAD Token: myToken Base URI: myBaseUri Job Name: myJobName @@ -686,10 +686,10 @@ let ``Shows help text for submit command`` () = Options: --target (REQUIRED) The target device ID. - --storage (REQUIRED) The storage account connection string. --subscription (REQUIRED) The subscription ID. --resource-group (REQUIRED) The resource group name. --workspace (REQUIRED) The workspace name. + --storage The storage account connection string. --aad-token The Azure Active Directory authentication token. --base-uri The base URI of the Azure Quantum endpoint. --job-name The name of the submitted job. diff --git a/src/Simulation/EntryPointDriver/Azure.cs b/src/Simulation/EntryPointDriver/Azure.cs index 86ad79791a3..0f3b3a91e77 100644 --- a/src/Simulation/EntryPointDriver/Azure.cs +++ b/src/Simulation/EntryPointDriver/Azure.cs @@ -195,11 +195,6 @@ internal sealed class AzureSettings /// public string? Target { get; set; } - /// - /// The storage account connection string. - /// - public string? Storage { get; set; } - /// /// The subscription ID. /// @@ -215,6 +210,11 @@ internal sealed class AzureSettings /// public string? Workspace { get; set; } + /// + /// The storage account connection string. + /// + public string? Storage { get; set; } + /// /// The Azure Active Directory authentication token. /// @@ -262,10 +262,10 @@ AadToken is null public override string ToString() => string.Join(System.Environment.NewLine, $"Target: {Target}", - $"Storage: {Storage}", $"Subscription: {Subscription}", $"Resource Group: {ResourceGroup}", $"Workspace: {Workspace}", + $"Storage: {Storage}", $"AAD Token: {AadToken}", $"Base URI: {BaseUri}", $"Job Name: {JobName}", diff --git a/src/Simulation/EntryPointDriver/Driver.cs b/src/Simulation/EntryPointDriver/Driver.cs index daabf992cde..13a836e85f2 100644 --- a/src/Simulation/EntryPointDriver/Driver.cs +++ b/src/Simulation/EntryPointDriver/Driver.cs @@ -81,10 +81,10 @@ public async Task Run(string[] args) Handler = CommandHandler.Create(Submit) }; AddOptionIfAvailable(submit, TargetOption); - AddOptionIfAvailable(submit, StorageOption); AddOptionIfAvailable(submit, SubscriptionOption); AddOptionIfAvailable(submit, ResourceGroupOption); AddOptionIfAvailable(submit, WorkspaceOption); + AddOptionIfAvailable(submit, StorageOption); AddOptionIfAvailable(submit, AadTokenOption); AddOptionIfAvailable(submit, BaseUriOption); AddOptionIfAvailable(submit, JobNameOption); @@ -133,10 +133,10 @@ private async Task Submit(ParseResult parseResult, AzureSettings azureSetti await Azure.Submit(entryPoint, parseResult, new AzureSettings { Target = azureSettings.Target, - Storage = azureSettings.Storage, Subscription = azureSettings.Subscription, ResourceGroup = azureSettings.ResourceGroup, Workspace = azureSettings.Workspace, + Storage = DefaultIfShadowed(StorageOption, azureSettings.Storage), AadToken = DefaultIfShadowed(AadTokenOption, azureSettings.AadToken), BaseUri = DefaultIfShadowed(BaseUriOption, azureSettings.BaseUri), JobName = DefaultIfShadowed(JobNameOption, azureSettings.JobName), @@ -211,12 +211,6 @@ internal static class Driver internal static readonly OptionInfo TargetOption = new OptionInfo( ImmutableList.Create("--target"), "The target device ID."); - /// - /// The storage option. - /// - internal static readonly OptionInfo StorageOption = new OptionInfo( - ImmutableList.Create("--storage"), "The storage account connection string."); - /// /// The subscription option. /// @@ -235,6 +229,12 @@ internal static class Driver internal static readonly OptionInfo WorkspaceOption = new OptionInfo( ImmutableList.Create("--workspace"), "The workspace name."); + /// + /// The storage option. + /// + internal static readonly OptionInfo StorageOption = new OptionInfo( + ImmutableList.Create("--storage"), default, "The storage account connection string."); + /// /// The AAD token option. ///