From cbce8e2a1ff13535a8592a1b5f9f0b18fbc8a778 Mon Sep 17 00:00:00 2001 From: Mario Bourgoin Date: Tue, 26 Nov 2019 14:33:36 -0500 Subject: [PATCH 1/2] Allow both human-friendly subscription name and machine-enabled subscription ID --- 03_Run_Locally.ipynb | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/03_Run_Locally.ipynb b/03_Run_Locally.ipynb index 6461b4e..22879c4 100644 --- a/03_Run_Locally.ipynb +++ b/03_Run_Locally.ipynb @@ -39,7 +39,7 @@ "metadata": {}, "source": [ "## Azure subscription \n", - "If you have multiple subscriptions select the subscription you want to use. If you want to run this in a different location that supports HyperDrive, you may the one you want to use. You can also set the name of the resource group in which this tutorial will add resources. *IMPORTANT NOTE:* The last notebook in this example will delete this resource group and all associated resources." + "If you have multiple subscriptions select the subscription you want to use. You may supply either the subscription's name or the subscription's ID. If you want to run this in a different location that supports HyperDrive, you may enter the one you want to use. You can also set the name of the resource group in which this tutorial will add resources. *IMPORTANT NOTE:* The last notebook in this example will delete this resource group and all associated resources." ] }, { @@ -52,11 +52,33 @@ }, "outputs": [], "source": [ - "selected_subscription=\"YOUR_SUBSCRIPTION\"\n", + "subscription_name=\"YOUR_SUBSCRIPTION_NAME\"\n", + "subscription_id=\"YOUR_SUBSCRIPTION_ID\"\n", "location=\"eastus\"\n", "resource_group=\"hypetuning\"" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Check that we have either a subscription name or ID. If the ID has been supplied, then use that value." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if (subscription_name == \"YOUR_SUBSCRIPTION_NAME\"\n", + " and subscription_id == \"YOUR_SUBSCRIPTION_ID\"):\n", + " raise Exception(\"At least one of a subscription's name or ID must be supplied\")\n", + "if subscription_id != \"YOUR_SUBSCRIPTION_ID\":\n", + " print(\"A subscription ID has been supplied, so it will be used\")\n", + " subscription_name = subscription_id" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -92,7 +114,7 @@ "metadata": {}, "outputs": [], "source": [ - "%%bash -s \"$selected_subscription\"\n", + "%%bash -s \"$subscription_name\"\n", "az account set --subscription \"$1\"\n", "az account show -o table" ] @@ -101,7 +123,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Get the information for the selected Azure subscription." + "Get the ID for the selected Azure subscription." ] }, { @@ -111,7 +133,8 @@ "outputs": [], "source": [ "az_profile = get_cli_profile()\n", - "subscription_id = az_profile.get_subscription_id()" + "subscription_id = az_profile.get_subscription_id()\n", + "print(\"Using subscription ID\", subscription_id)" ] }, { From 8ba6868dae688ed3d1269e68c286fe07d89c9862 Mon Sep 17 00:00:00 2001 From: Mario Bourgoin Date: Tue, 26 Nov 2019 20:47:57 +0000 Subject: [PATCH 2/2] Set subscription_id instead of selected_subscription --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 320555d..ee44441 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -58,7 +58,7 @@ jobs: source /usr/share/miniconda/etc/profile.d/conda.sh conda activate MLHyperparameterTuning echo Executing 03_Run_Locally.ipynb - papermill 03_Run_Locally.ipynb 03_Run_Locally_Output.ipynb --log-output --no-progress-bar -k python3 -p selected_subscription $(subscriptionid) -p resource_group $(azurergname) + papermill 03_Run_Locally.ipynb 03_Run_Locally_Output.ipynb --log-output --no-progress-bar -k python3 -p subscription_id $(subscriptionid) -p resource_group $(azurergname) displayName: '03_Run_Locally.ipynb' - bash: |