Updated with the AML v0.1.65 after public launch at Ignite
This commit is contained in:
Родитель
8e927f5437
Коммит
d10f106962
|
@ -0,0 +1,457 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Do the pre-req setup\n",
|
||||
"https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-configure-environment#create-workspace-configuration-file\n",
|
||||
"https://github.com/Azure/ViennaDocs/blob/master/PrivatePreview/notebooks/00.configuration.ipynb"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[33mThe behavior of this command has been altered by the following extension: azure-ml-admin-cli\u001b[0m\n",
|
||||
"\u001b[33mNote, we have launched a browser for you to login. For old experience with device code, use \"az login --use-device-code\"\u001b[0m\n",
|
||||
"\u001b[33mYou have logged in. Now let us find all the subscriptions to which you have access...\u001b[0m\n",
|
||||
"\u001b[33mFailed to authenticate '{'additional_properties': {}, 'id': '/tenants/4f04fe57-837f-4b9d-9767-b066e63799b9', 'tenant_id': '4f04fe57-837f-4b9d-9767-b066e63799b9'}' due to error 'Get Token request returned http error: 400 and server response: {\"error\":\"interaction_required\",\"error_description\":\"AADSTS53003: Blocked by conditional access.\\r\\nTrace ID: 3eb069a2-ceae-469e-b6cd-04848f99e201\\r\\nCorrelation ID: b6894118-737f-405a-9f3f-5cebb40aafc2\\r\\nTimestamp: 2018-10-03 16:06:17Z\",\"error_codes\":[53003],\"timestamp\":\"2018-10-03 16:06:17Z\",\"trace_id\":\"3eb069a2-ceae-469e-b6cd-04848f99e201\",\"correlation_id\":\"b6894118-737f-405a-9f3f-5cebb40aafc2\",\"suberror\":\"message_only\"}'\u001b[0m\n",
|
||||
"[\n",
|
||||
" {\n",
|
||||
" \"cloudName\": \"AzureCloud\",\n",
|
||||
" \"id\": \"0ca618d2-22a8-413a-96d0-0f1b531129c3\",\n",
|
||||
" \"isDefault\": false,\n",
|
||||
" \"name\": \"Boston DS Dev\",\n",
|
||||
" \"state\": \"Enabled\",\n",
|
||||
" \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\n",
|
||||
" \"user\": {\n",
|
||||
" \"name\": \"jaymathe@microsoft.com\",\n",
|
||||
" \"type\": \"user\"\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"cloudName\": \"AzureCloud\",\n",
|
||||
" \"id\": \"edf507a2-6235-46c5-b560-fd463ba2e771\",\n",
|
||||
" \"isDefault\": true,\n",
|
||||
" \"name\": \"Boston Team Danielle\",\n",
|
||||
" \"state\": \"Enabled\",\n",
|
||||
" \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\n",
|
||||
" \"user\": {\n",
|
||||
" \"name\": \"jaymathe@microsoft.com\",\n",
|
||||
" \"type\": \"user\"\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"cloudName\": \"AzureCloud\",\n",
|
||||
" \"id\": \"ff18d7a8-962a-406c-858f-49acd23d6c01\",\n",
|
||||
" \"isDefault\": false,\n",
|
||||
" \"name\": \"Boston Team Ilan\",\n",
|
||||
" \"state\": \"Enabled\",\n",
|
||||
" \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\n",
|
||||
" \"user\": {\n",
|
||||
" \"name\": \"jaymathe@microsoft.com\",\n",
|
||||
" \"type\": \"user\"\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"cloudName\": \"AzureCloud\",\n",
|
||||
" \"id\": \"a8183b2d-7a4c-45e9-8736-dac11b84ff14\",\n",
|
||||
" \"isDefault\": false,\n",
|
||||
" \"name\": \"Azure Stack Diagnostics CI and Production VaaS\",\n",
|
||||
" \"state\": \"Enabled\",\n",
|
||||
" \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\n",
|
||||
" \"user\": {\n",
|
||||
" \"name\": \"jaymathe@microsoft.com\",\n",
|
||||
" \"type\": \"user\"\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"cloudName\": \"AzureCloud\",\n",
|
||||
" \"id\": \"fc4ea3c9-1d30-4f18-b33b-7404e7da0123\",\n",
|
||||
" \"isDefault\": false,\n",
|
||||
" \"name\": \"Azure Cat E2E\",\n",
|
||||
" \"state\": \"Enabled\",\n",
|
||||
" \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\n",
|
||||
" \"user\": {\n",
|
||||
" \"name\": \"jaymathe@microsoft.com\",\n",
|
||||
" \"type\": \"user\"\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"cloudName\": \"AzureCloud\",\n",
|
||||
" \"id\": \"54e18c35-3863-4a17-8e52-b5aa1e65847e\",\n",
|
||||
" \"isDefault\": false,\n",
|
||||
" \"name\": \"Core-ES-BLD\",\n",
|
||||
" \"state\": \"Enabled\",\n",
|
||||
" \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\n",
|
||||
" \"user\": {\n",
|
||||
" \"name\": \"jaymathe@microsoft.com\",\n",
|
||||
" \"type\": \"user\"\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"cloudName\": \"AzureCloud\",\n",
|
||||
" \"id\": \"dae41bd3-9db4-4b9b-943e-832b57cac828\",\n",
|
||||
" \"isDefault\": false,\n",
|
||||
" \"name\": \"Cosmos_WDG_Core_BnB_100348\",\n",
|
||||
" \"state\": \"Enabled\",\n",
|
||||
" \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\n",
|
||||
" \"user\": {\n",
|
||||
" \"name\": \"jaymathe@microsoft.com\",\n",
|
||||
" \"type\": \"user\"\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"cloudName\": \"AzureCloud\",\n",
|
||||
" \"id\": \"3bcfa59c-82a0-44f9-ac08-b3479370bace\",\n",
|
||||
" \"isDefault\": false,\n",
|
||||
" \"name\": \"Solution Template Testing\",\n",
|
||||
" \"state\": \"Enabled\",\n",
|
||||
" \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\n",
|
||||
" \"user\": {\n",
|
||||
" \"name\": \"jaymathe@microsoft.com\",\n",
|
||||
" \"type\": \"user\"\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"cloudName\": \"AzureCloud\",\n",
|
||||
" \"id\": \"bc4170f0-cc6e-49d2-ba65-bc00a7a4df6b\",\n",
|
||||
" \"isDefault\": false,\n",
|
||||
" \"name\": \"Boston Engineering\",\n",
|
||||
" \"state\": \"Enabled\",\n",
|
||||
" \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\n",
|
||||
" \"user\": {\n",
|
||||
" \"name\": \"jaymathe@microsoft.com\",\n",
|
||||
" \"type\": \"user\"\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
"]\n",
|
||||
"\u001b[0m"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#Connect to your Azure Subscription\n",
|
||||
"!az login"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{\r\n",
|
||||
" \"environmentName\": \"AzureCloud\",\r\n",
|
||||
" \"id\": \"edf507a2-6235-46c5-b560-fd463ba2e771\",\r\n",
|
||||
" \"isDefault\": true,\r\n",
|
||||
" \"name\": \"Boston Team Danielle\",\r\n",
|
||||
" \"state\": \"Enabled\",\r\n",
|
||||
" \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n",
|
||||
" \"user\": {\r\n",
|
||||
" \"name\": \"jaymathe@microsoft.com\",\r\n",
|
||||
" \"type\": \"user\"\r\n",
|
||||
" }\r\n",
|
||||
"}\r\n",
|
||||
"\u001b[0m"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!az account show"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[33mRegistering is still on-going. You can monitor using 'az provider show -n Microsoft.MachineLearningServices'\u001b[0m\n",
|
||||
"\u001b[0m{\n",
|
||||
" \"authorization\": {\n",
|
||||
" \"applicationId\": \"0736f41a-0425-4b46-bdb5-1563eff02385\",\n",
|
||||
" \"managedByRoleDefinitionId\": \"91d00862-cf55-46a5-9dce-260bbd92ce25\",\n",
|
||||
" \"roleDefinitionId\": \"376aa7d7-51a9-463d-bd4d-7e1691345612\"\n",
|
||||
" },\n",
|
||||
" \"id\": \"/subscriptions/edf507a2-6235-46c5-b560-fd463ba2e771/providers/Microsoft.MachineLearningServices\",\n",
|
||||
" \"namespace\": \"Microsoft.MachineLearningServices\",\n",
|
||||
" \"registrationState\": \"Registered\",\n",
|
||||
" \"resourceTypes\": [\n",
|
||||
" {\n",
|
||||
" \"aliases\": null,\n",
|
||||
" \"apiVersions\": [\n",
|
||||
" \"2018-03-01-preview\"\n",
|
||||
" ],\n",
|
||||
" \"capabilities\": \"CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SystemAssignedResourceIdentity\",\n",
|
||||
" \"defaultApiVersion\": \"2018-03-01-preview\",\n",
|
||||
" \"locations\": [\n",
|
||||
" \"East US\",\n",
|
||||
" \"Australia East\",\n",
|
||||
" \"East US 2\",\n",
|
||||
" \"West US 2\",\n",
|
||||
" \"West Central US\",\n",
|
||||
" \"Southeast Asia\",\n",
|
||||
" \"West Europe\",\n",
|
||||
" \"South Central US\",\n",
|
||||
" \"East US 2 EUAP\"\n",
|
||||
" ],\n",
|
||||
" \"properties\": null,\n",
|
||||
" \"resourceType\": \"workspaces\"\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"aliases\": null,\n",
|
||||
" \"apiVersions\": [\n",
|
||||
" \"2018-03-01-preview\"\n",
|
||||
" ],\n",
|
||||
" \"locations\": [\n",
|
||||
" \"East US\",\n",
|
||||
" \"Australia East\",\n",
|
||||
" \"East US 2\",\n",
|
||||
" \"West US 2\",\n",
|
||||
" \"West Central US\",\n",
|
||||
" \"Southeast Asia\",\n",
|
||||
" \"West Europe\",\n",
|
||||
" \"South Central US\",\n",
|
||||
" \"East US 2 EUAP\"\n",
|
||||
" ],\n",
|
||||
" \"properties\": null,\n",
|
||||
" \"resourceType\": \"workspaces/computes\"\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"aliases\": null,\n",
|
||||
" \"apiVersions\": [\n",
|
||||
" \"2018-03-01-preview\"\n",
|
||||
" ],\n",
|
||||
" \"locations\": [\n",
|
||||
" \"East US 2\",\n",
|
||||
" \"East US 2 EUAP\"\n",
|
||||
" ],\n",
|
||||
" \"properties\": null,\n",
|
||||
" \"resourceType\": \"operations\"\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"aliases\": null,\n",
|
||||
" \"apiVersions\": [\n",
|
||||
" \"2018-03-01-preview\"\n",
|
||||
" ],\n",
|
||||
" \"locations\": [\n",
|
||||
" \"East US 2\",\n",
|
||||
" \"East US 2 EUAP\"\n",
|
||||
" ],\n",
|
||||
" \"properties\": null,\n",
|
||||
" \"resourceType\": \"locations\"\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"aliases\": null,\n",
|
||||
" \"apiVersions\": [\n",
|
||||
" \"2018-03-01-preview\"\n",
|
||||
" ],\n",
|
||||
" \"locations\": [\n",
|
||||
" \"East US\",\n",
|
||||
" \"Australia East\",\n",
|
||||
" \"East US 2\",\n",
|
||||
" \"West US 2\",\n",
|
||||
" \"West Central US\",\n",
|
||||
" \"Southeast Asia\",\n",
|
||||
" \"West Europe\",\n",
|
||||
" \"South Central US\",\n",
|
||||
" \"East US 2 EUAP\"\n",
|
||||
" ],\n",
|
||||
" \"properties\": null,\n",
|
||||
" \"resourceType\": \"locations/computeOperationsStatus\"\n",
|
||||
" }\n",
|
||||
" ]\n",
|
||||
"}\n",
|
||||
"\u001b[0m"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# register the new RP\n",
|
||||
"!az provider register -n Microsoft.MachineLearningServices\n",
|
||||
"\n",
|
||||
"# check the registration status\n",
|
||||
"!az provider show -n Microsoft.MachineLearningServices"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"SDK Version: 0.1.65\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import azureml.core\n",
|
||||
"\n",
|
||||
"print(\"SDK Version:\", azureml.core.VERSION)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#Initialize an Azure ML Workspace\n",
|
||||
"subscription_id = \"edf507a2-6235-46c5-b560-fd463ba2e771\"\n",
|
||||
"resource_group = \"jayavienna\"\n",
|
||||
"workspace_name = \"jayavienna\"\n",
|
||||
"workspace_region = \"eastus2\" # or eastus2euap"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# import the Workspace class and check the azureml SDK version\n",
|
||||
"#from azureml.core import Workspace\n",
|
||||
"\n",
|
||||
"#ws = Workspace.create(name = workspace_name,\n",
|
||||
"# subscription_id = subscription_id,\n",
|
||||
"# resource_group = resource_group, \n",
|
||||
"# location = workspace_region)\n",
|
||||
"#ws.get_details()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Wrote the config file config.json to: /home/jayaubuntudsvm/Desktop/AKSDeploymentTutorial/Keras_Tensorflow/aml_config/config.json\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from azureml.core import Workspace\n",
|
||||
"\n",
|
||||
"ws = Workspace(workspace_name = workspace_name,\n",
|
||||
" subscription_id = subscription_id,\n",
|
||||
" resource_group = resource_group)\n",
|
||||
"\n",
|
||||
"# persist the subscription id, resource group name, and workspace name in aml_config/config.json.\n",
|
||||
"ws.write_config()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Found the config file in: /home/jayaubuntudsvm/Desktop/AKSDeploymentTutorial/Keras_Tensorflow/aml_config/config.json\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'id': '/subscriptions/edf507a2-6235-46c5-b560-fd463ba2e771/resourceGroups/jayavienna/providers/Microsoft.MachineLearningServices/workspaces/jayavienna',\n",
|
||||
" 'name': 'jayavienna',\n",
|
||||
" 'location': 'eastus2',\n",
|
||||
" 'type': 'Microsoft.MachineLearningServices/workspaces',\n",
|
||||
" 'description': '',\n",
|
||||
" 'friendlyName': 'jayavienna',\n",
|
||||
" 'containerRegistry': '/subscriptions/edf507a2-6235-46c5-b560-fd463ba2e771/resourcegroups/jayavienna/providers/microsoft.containerregistry/registries/jayavienacrzhqxfpoo',\n",
|
||||
" 'keyVault': '/subscriptions/edf507a2-6235-46c5-b560-fd463ba2e771/resourcegroups/jayavienna/providers/microsoft.keyvault/vaults/jayavienkeyvaultffjnhcad',\n",
|
||||
" 'applicationInsights': '/subscriptions/edf507a2-6235-46c5-b560-fd463ba2e771/resourcegroups/jayavienna/providers/microsoft.insights/components/jayavieninsightsjjxuauup',\n",
|
||||
" 'batchaiWorkspace': '/subscriptions/edf507a2-6235-46c5-b560-fd463ba2e771/resourcegroups/jayavienna/providers/microsoft.batchai/workspaces/jayavienbatchai_rlifpbub',\n",
|
||||
" 'identityPrincipalId': '4f27819f-a74d-4dd5-b8a0-a3f4ca3da1e8',\n",
|
||||
" 'identityTenantId': '72f988bf-86f1-41af-91ab-2d7cd011db47',\n",
|
||||
" 'identityType': 'SystemAssigned',\n",
|
||||
" 'storageAccount': '/subscriptions/edf507a2-6235-46c5-b560-fd463ba2e771/resourcegroups/jayavienna/providers/microsoft.storage/storageaccounts/jayavienstoragesiexgjip'}"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# load workspace configuratio from ./aml_config/config.json file.ß\n",
|
||||
"my_workspace = Workspace.from_config()\n",
|
||||
"my_workspace.get_details()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Sample projects will be created in ./sample_projects.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"sample_projects_folder = './sample_projects'\n",
|
||||
"\n",
|
||||
"if not os.path.isdir(sample_projects_folder):\n",
|
||||
" os.mkdir(sample_projects_folder)\n",
|
||||
" \n",
|
||||
"print('Sample projects will be created in {}.'.format(sample_projects_folder))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python [conda env:myenv]",
|
||||
"language": "python",
|
||||
"name": "conda-env-myenv-py"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.6.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,832 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Refer to \n",
|
||||
"https://github.com/Azure/ViennaDocs/blob/master/PrivatePreview/notebooks/01.train-within-notebook.ipynb\n",
|
||||
"https://github.com/Azure/ViennaDocs/blob/master/PrivatePreview/notebooks/11.production-deploy-to-aks.ipynb"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from azureml.core import Workspace\n",
|
||||
"from azureml.core.compute import AksCompute, ComputeTarget\n",
|
||||
"from azureml.core.webservice import Webservice, AksWebservice\n",
|
||||
"from azureml.core.image import Image\n",
|
||||
"from azureml.core.model import Model"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"0.1.65\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import azureml.core\n",
|
||||
"print(azureml.core.VERSION)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Found the config file in: /home/jayaubuntudsvm/Desktop/AKSDeploymentTutorial/Keras_Tensorflow/aml_config/config.json\n",
|
||||
"jayavienna\n",
|
||||
"jayavienna\n",
|
||||
"eastus2\n",
|
||||
"edf507a2-6235-46c5-b560-fd463ba2e771\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from azureml.core.workspace import Workspace\n",
|
||||
"\n",
|
||||
"ws = Workspace.from_config()\n",
|
||||
"print(ws.name, ws.resource_group, ws.location, ws.subscription_id, sep = '\\n')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Using TensorFlow backend.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#Creating the model pickle file\n",
|
||||
"import tensorflow as tf\n",
|
||||
"from resnet152 import ResNet152\n",
|
||||
"from keras.preprocessing import image\n",
|
||||
"from keras.applications.imagenet_utils import preprocess_input, decode_predictions\n",
|
||||
"\n",
|
||||
"model = ResNet152(weights='imagenet')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"<keras.engine.training.Model at 0x7f893e08df60>"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"model"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"model_json = model.to_json()\n",
|
||||
"with open(\"model_resnet.json\", \"w\") as json_file:\n",
|
||||
" json_file.write(model_json)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"model.save_weights(\"model_resnet_weights.h5\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#from keras.models import model_from_json\n",
|
||||
"#model = model_from_json(model_json)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"model.load_weights('model_resnet_weights.h5')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"<keras.engine.training.Model at 0x7f893e08df60>"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"model"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#Register the model\n",
|
||||
"#from azureml.core.model import Model\n",
|
||||
"#model = Model.register(model_path = \"model_resnet_weights.h5\", # this points to a local file\n",
|
||||
"# model_name = \"resnet_model\", # this is the name the model is registered as\n",
|
||||
"# tags = [\"dl\", \"resnet\"],\n",
|
||||
"# description = \"resnet 152 model\",\n",
|
||||
"# workspace = ws)\n",
|
||||
"\n",
|
||||
"#print(model.name, model.description, model.version)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#define init() function\n",
|
||||
"def init():\n",
|
||||
" import tensorflow as tf\n",
|
||||
" from resnet152 import ResNet152\n",
|
||||
" from keras.preprocessing import image\n",
|
||||
" from keras.applications.imagenet_utils import preprocess_input, decode_predictions\n",
|
||||
"\n",
|
||||
" import numpy as np\n",
|
||||
" import timeit as t\n",
|
||||
" import base64\n",
|
||||
" import json\n",
|
||||
" from PIL import Image, ImageOps\n",
|
||||
" from io import BytesIO\n",
|
||||
" import logging\n",
|
||||
"\n",
|
||||
" global model\n",
|
||||
" model = ResNet152(weights='imagenet')\n",
|
||||
" print('Model loaded')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Model loaded\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"init()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#define run() function \n",
|
||||
"def run(img_path):\n",
|
||||
" \n",
|
||||
" import tensorflow as tf\n",
|
||||
" from resnet152 import ResNet152\n",
|
||||
" from keras.preprocessing import image\n",
|
||||
" from keras.applications.imagenet_utils import preprocess_input, decode_predictions\n",
|
||||
"\n",
|
||||
" import numpy as np\n",
|
||||
" import timeit as t\n",
|
||||
" import base64\n",
|
||||
" import json\n",
|
||||
" from PIL import Image, ImageOps\n",
|
||||
" from io import BytesIO\n",
|
||||
" import logging \n",
|
||||
" \n",
|
||||
" model = ResNet152(weights='imagenet')\n",
|
||||
" print('Model loaded')\n",
|
||||
" \n",
|
||||
" img = image.load_img(img_path, target_size=(224, 224))\n",
|
||||
" img = image.img_to_array(img)\n",
|
||||
" img = np.expand_dims(img, axis=0)\n",
|
||||
" img = preprocess_input(img)\n",
|
||||
" \n",
|
||||
" preds = model.predict(img)\n",
|
||||
" print('Predicted:', decode_predictions(preds, top=3))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'220px-Lynx_lynx_poing (1).jpg'"
|
||||
]
|
||||
},
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import wget\n",
|
||||
"wget.download('https://upload.wikimedia.org/wikipedia/commons/thumb/6/68/Lynx_lynx_poing.jpg/220px-Lynx_lynx_poing.jpg')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"img_path = '220px-Lynx_lynx_poing.jpg'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Model loaded\n",
|
||||
"Predicted: [[('n02127052', 'lynx', 0.99590886), ('n02128385', 'leopard', 0.001150445), ('n02123159', 'tiger_cat', 0.0009417962)]]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"run(img_path)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Overwriting score.py\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%%writefile score.py\n",
|
||||
"def init():\n",
|
||||
" import tensorflow as tf\n",
|
||||
" from resnet152 import ResNet152\n",
|
||||
" from keras.preprocessing import image\n",
|
||||
" from keras.applications.imagenet_utils import preprocess_input, decode_predictions\n",
|
||||
"\n",
|
||||
" import numpy as np\n",
|
||||
" import timeit as t\n",
|
||||
" import base64\n",
|
||||
" import json\n",
|
||||
" from PIL import Image, ImageOps\n",
|
||||
" from io import BytesIO\n",
|
||||
" import logging\n",
|
||||
"\n",
|
||||
" global model\n",
|
||||
" model = ResNet152(weights='imagenet')\n",
|
||||
" print('Model loaded')\n",
|
||||
" \n",
|
||||
"def run(img_path):\n",
|
||||
" \n",
|
||||
" import tensorflow as tf\n",
|
||||
" from resnet152 import ResNet152\n",
|
||||
" from keras.preprocessing import image\n",
|
||||
" from keras.applications.imagenet_utils import preprocess_input, decode_predictions\n",
|
||||
"\n",
|
||||
" import numpy as np\n",
|
||||
" import timeit as t\n",
|
||||
" import base64\n",
|
||||
" import json\n",
|
||||
" from PIL import Image, ImageOps\n",
|
||||
" from io import BytesIO\n",
|
||||
" import logging \n",
|
||||
" \n",
|
||||
" model = ResNet152(weights='imagenet')\n",
|
||||
" print('Model loaded')\n",
|
||||
" \n",
|
||||
" img = image.load_img(img_path, target_size=(224, 224))\n",
|
||||
" img = image.img_to_array(img)\n",
|
||||
" img = np.expand_dims(img, axis=0)\n",
|
||||
" img = preprocess_input(img)\n",
|
||||
" \n",
|
||||
" preds = model.predict(img)\n",
|
||||
" print('Predicted:', decode_predictions(preds, top=3)) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%run score.py"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"def init():\n",
|
||||
" import tensorflow as tf\n",
|
||||
" from resnet152 import ResNet152\n",
|
||||
" from keras.preprocessing import image\n",
|
||||
" from keras.applications.imagenet_utils import preprocess_input, decode_predi\n",
|
||||
"ctions\n",
|
||||
"\n",
|
||||
" import numpy as np\n",
|
||||
" import timeit as t\n",
|
||||
" import base64\n",
|
||||
" import json\n",
|
||||
" from PIL import Image, ImageOps\n",
|
||||
" from io import BytesIO\n",
|
||||
" import logging\n",
|
||||
"\n",
|
||||
" global model\n",
|
||||
" model = ResNet152(weights='imagenet')\n",
|
||||
" print('Model loaded')\n",
|
||||
" \n",
|
||||
"def run(img_path):\n",
|
||||
" \n",
|
||||
" import tensorflow as tf\n",
|
||||
" from resnet152 import ResNet152\n",
|
||||
"\u001b[Km--More--(46%)\u001b[m"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!more score.py"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"# Conda environment specification. The dependencies defined in this file will\n",
|
||||
"# be automatically provisioned for runs with userManagedDependencies=False.\n",
|
||||
"\n",
|
||||
"# Details about the Conda environment file format:\n",
|
||||
"# https://conda.io/docs/user-guide/tasks/manage-environments.html#create-env-fil\n",
|
||||
"e-manually\n",
|
||||
"\n",
|
||||
"name: project_environment\n",
|
||||
"dependencies:\n",
|
||||
" # The python interpreter version.\n",
|
||||
" # Currently Azure ML only supports 3.5.2 and later.\n",
|
||||
"- python=3.6\n",
|
||||
"\n",
|
||||
"- pip:\n",
|
||||
" # Required packages for AzureML execution, history, and data preparation.\n",
|
||||
" - --index-url https://azuremlsdktestpypi.azureedge.net/sdk-release/Preview/E75\n",
|
||||
"01C02541B433786111FE8E140CAA1\n",
|
||||
" - --extra-index-url https://pypi.python.org/simple\n",
|
||||
" - azureml-defaults\n",
|
||||
" - papermill==0.14.1\n",
|
||||
" - python-dotenv==0.9.0\n",
|
||||
" - Pillow==5.2.0\n",
|
||||
" - wget==3.2\n",
|
||||
"\u001b[Km--More--(86%)\u001b[m"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!more conda_dependencies.yml"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'/home/jayaubuntudsvm/Desktop/AKSDeploymentTutorial/Keras_Tensorflow'"
|
||||
]
|
||||
},
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"os.getcwd()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"['AML_00_configuration_v0.1.50.ipynb',\n",
|
||||
" '00_DevelopModel.ipynb',\n",
|
||||
" 'AML_02_DevelopModelDriver_AKS-old.ipynb',\n",
|
||||
" 'AML_01_trainlocal-docker.ipynb',\n",
|
||||
" 'model_resnet_weights.h5',\n",
|
||||
" 'AML_02_resnet_model_weights.ipynb',\n",
|
||||
" '01_DevelopModelDriver.ipynb',\n",
|
||||
" '__pycache__',\n",
|
||||
" 'samples',\n",
|
||||
" 'resnet152_n.py',\n",
|
||||
" '06_SpeedTestWebApp.ipynb',\n",
|
||||
" '03_TestLocally.ipynb',\n",
|
||||
" 'AML_02_Develop_init_run_functions.ipynb',\n",
|
||||
" '220px-Lynx_lynx_poing (1).jpg',\n",
|
||||
" 'AML_02_AKS_deployment_v0.1.65.ipynb',\n",
|
||||
" 'AML_02_AKS_deployment.ipynb',\n",
|
||||
" 'aml_config',\n",
|
||||
" '05_TestWebApp.ipynb',\n",
|
||||
" '04_DeployOnAKS.ipynb',\n",
|
||||
" 'score.py',\n",
|
||||
" 'model_resnet.json',\n",
|
||||
" 'AML_01_trainlocal_v0.1.50.ipynb',\n",
|
||||
" 'AML_00_configuration_v0.1.65.ipynb',\n",
|
||||
" '02_BuildImage.ipynb',\n",
|
||||
" '07_TearDown.ipynb',\n",
|
||||
" 'helpers.py',\n",
|
||||
" 'testing_utilities.py',\n",
|
||||
" '220px-Lynx_lynx_poing.jpg',\n",
|
||||
" 'config',\n",
|
||||
" 'conda_dependencies.yml',\n",
|
||||
" 'resnet152.py',\n",
|
||||
" 'AML_02_AKS_deployment_v0.1.50.ipynb',\n",
|
||||
" 'README.md',\n",
|
||||
" 'environment.yml',\n",
|
||||
" 'sample_projects',\n",
|
||||
" 'AML_01_trainlocal_v0.1.65.ipynb',\n",
|
||||
" '.ipynb_checkpoints']"
|
||||
]
|
||||
},
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"os.listdir(os.getcwd())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Creating image\n",
|
||||
"Running.............................................................\n",
|
||||
"SucceededImage creation operation finished for image myimage1:6, operation \"Succeeded\"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from azureml.core.image import ContainerImage\n",
|
||||
"\n",
|
||||
"image_config = ContainerImage.image_configuration(execution_script = \"score.py\",\n",
|
||||
" runtime = \"python\",\n",
|
||||
" conda_file = \"conda_dependencies.yml\",\n",
|
||||
" description = \"Image for AKS Deployment Tutorial\",\n",
|
||||
" tags = {\"name\":\"AKS\",\"project\":\"AML\"}, \n",
|
||||
" dependencies = [\"resnet152_n.py\"]\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
"image = ContainerImage.create(name = \"myimage1\",\n",
|
||||
" # this is the model object\n",
|
||||
" models = [], \n",
|
||||
" image_config = image_config,\n",
|
||||
" workspace = ws)\n",
|
||||
"\n",
|
||||
"image.wait_for_creation(show_output = True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'myimage1': ContainerImage(workspace=<azureml.core.workspace.Workspace object at 0x7f89b026b860>, name=myimage1, id=myimage1:6, tags={'name': 'AKS', 'project': 'AML'}, properties={}, version=6),\n",
|
||||
" 'my-aci-svc-1': ContainerImage(workspace=<azureml.core.workspace.Workspace object at 0x7f89b026b860>, name=my-aci-svc-1, id=my-aci-svc-1:4, tags={}, properties={}, version=4)}"
|
||||
]
|
||||
},
|
||||
"execution_count": 25,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#list images\n",
|
||||
"images = ws.images()\n",
|
||||
"images"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#for img in ws.images():\n",
|
||||
"# if img.name == 'myimage1': img.delete()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#Provision AKS cluster\n",
|
||||
"# Use the default configuration (can also provide parameters to customize)\n",
|
||||
"prov_config = AksCompute.provisioning_configuration()\n",
|
||||
"\n",
|
||||
"aks_name = 'jaya-aks-4' \n",
|
||||
"# Create the cluster\n",
|
||||
"aks_target = ComputeTarget.create(workspace = ws, \n",
|
||||
" name = aks_name, \n",
|
||||
" provisioning_configuration = prov_config)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Creating................................................................................................................................................................................\n",
|
||||
"SucceededProvisioning operation finished, operation \"Succeeded\"\n",
|
||||
"Succeeded\n",
|
||||
"None\n",
|
||||
"CPU times: user 2.68 s, sys: 139 ms, total: 2.82 s\n",
|
||||
"Wall time: 15min 16s\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%%time\n",
|
||||
"aks_target.wait_for_completion(show_output = True)\n",
|
||||
"print(aks_target.provisioning_state)\n",
|
||||
"print(aks_target.provisioning_errors)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[31mThe Resource 'Microsoft.ContainerService/managedClusters/jaya-aks-4' under resource group 'jayavienna' was not found.\u001b[0m\n",
|
||||
"\u001b[0m"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!az aks get-credentials -n 'jaya-aks-4' -g jayavienna -a -f config"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"No resources found.\r\n",
|
||||
"Error from server (NotAcceptable): unknown (get services)\r\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!kubectl --kubeconfig config get services"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#Deploy web service to AKS\n",
|
||||
"#Set the web service configuration (using default here)\n",
|
||||
"aks_config = AksWebservice.deploy_configuration()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%time\n",
|
||||
"aks_service_name ='jaya-aks-service-4'\n",
|
||||
"\n",
|
||||
"aks_service = Webservice.deploy_from_image(workspace = ws, \n",
|
||||
" name = aks_service_name,\n",
|
||||
" image = image,\n",
|
||||
" deployment_config = aks_config,\n",
|
||||
" deployment_target = aks_target)\n",
|
||||
"aks_service.wait_for_deployment(show_output = True)\n",
|
||||
"print(aks_service.state)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#Debug\n",
|
||||
"\n",
|
||||
"# load workspace from default config file\n",
|
||||
"ws = Workspace.from_config()\n",
|
||||
"\n",
|
||||
"# list all web services in the workspace\n",
|
||||
"for s in ws.webservices():\n",
|
||||
" print(s.name)\n",
|
||||
"\n",
|
||||
"# instantiate the web service object from workspace and service name\n",
|
||||
"svc = Webservice(workspace = ws, name = 'jaya-aks-service-2')\n",
|
||||
"\n",
|
||||
"# print out the Docker log\n",
|
||||
"print(svc.get_logs())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#clean up resources\n",
|
||||
"#aks_target = AksCompute(name='jaya-aks-1',workspace=ws)\n",
|
||||
"#aks_target.delete()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\r",
|
||||
"\u001b[K - Starting ..\r",
|
||||
"\r",
|
||||
"\u001b[K - Finished ..\r",
|
||||
"\r",
|
||||
"\u001b[K\u001b[0m"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#alternate code to clean up resources\n",
|
||||
"!az aks delete --resource-group jayavienna --name jaya-aks-2 --yes"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for s in ws.webservices():\n",
|
||||
" print(s.name)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"s = Webservice(ws, 'jaya-aks-service-2')\n",
|
||||
"s.delete()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from azureml.core import Workspace\n",
|
||||
"from azureml.core.compute import AksCompute, ComputeTarget\n",
|
||||
"\n",
|
||||
"ws = Workspace.from_config()\n",
|
||||
"\n",
|
||||
"for c in ws.compute_targets():\n",
|
||||
" print(c.name)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python [conda env:myenv]",
|
||||
"language": "python",
|
||||
"name": "conda-env-myenv-py"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.6.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
Загрузка…
Ссылка в новой задаче