update samples from Release-139 as a part of 1.0.55 SDK release

This commit is contained in:
vizhur
2019-08-05 18:39:19 +00:00
parent e4d9a2b4c5
commit c0dae0c645
69 changed files with 6879 additions and 1147 deletions

View File

@@ -68,7 +68,7 @@
"from azureml.core import Workspace\n",
"\n",
"ws = Workspace.from_config()\n",
"print(ws.name, ws.resource_group, ws.location, ws.subscription_id, sep = '\\n')"
"print(ws.name, ws.resource_group, ws.location, ws.subscription_id, sep='\\n')"
]
},
{
@@ -99,11 +99,31 @@
"source": [
"from azureml.core.model import Model\n",
"\n",
"model = Model.register(model_path = \"sklearn_regression_model.pkl\",\n",
" model_name = \"sklearn_regression_model.pkl\",\n",
" tags = {'area': \"diabetes\", 'type': \"regression\"},\n",
" description = \"Ridge regression model to predict diabetes\",\n",
" workspace = ws)"
"model = Model.register(model_path=\"sklearn_regression_model.pkl\",\n",
" model_name=\"sklearn_regression_model.pkl\",\n",
" tags={'area': \"diabetes\", 'type': \"regression\"},\n",
" description=\"Ridge regression model to predict diabetes\",\n",
" workspace=ws)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create Environment"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.conda_dependencies import CondaDependencies\n",
"from azureml.core.environment import Environment\n",
"\n",
"environment = Environment(\"LocalDeploy\")\n",
"environment.python.conda_dependencies = CondaDependencies(\"myenv.yml\")"
]
},
{
@@ -121,9 +141,8 @@
"source": [
"from azureml.core.model import InferenceConfig\n",
"\n",
"inference_config = InferenceConfig(runtime= \"python\", \n",
" entry_script=\"score.py\",\n",
" conda_file=\"myenv.yml\")"
"inference_config = InferenceConfig(entry_script=\"score.py\",\n",
" environment=environment)"
]
},
{
@@ -138,15 +157,10 @@
"\n",
"NOTE:\n",
"\n",
"we require docker running with linux container. If you are running Docker for Windows, you need to ensure the Linux Engine is running\n",
"The Docker image runs as a Linux container. If you are running Docker for Windows, you need to ensure the Linux Engine is running:\n",
"\n",
" powershell command to switch to linux engine\n",
" & 'C:\\Program Files\\Docker\\Docker\\DockerCli.exe' -SwitchLinuxEngine\n",
"\n",
"and c drive is shared https://docs.docker.com/docker-for-windows/#shared-drives\n",
"sometimes you have to reshare c drive as docker \n",
"\n",
"<img src=\"./dockerSharedDrive.JPG\" align=\"left\"/>"
" # PowerShell command to switch to Linux engine\n",
" & 'C:\\Program Files\\Docker\\Docker\\DockerCli.exe' -SwitchLinuxEngine"
]
},
{
@@ -157,7 +171,7 @@
"source": [
"from azureml.core.webservice import LocalWebservice\n",
"\n",
"#this is optional, if not provided we choose random port\n",
"# This is optional, if not provided Docker will choose a random unused port.\n",
"deployment_config = LocalWebservice.deploy_configuration(port=6789)\n",
"\n",
"local_service = Model.deploy(ws, \"test\", [model], inference_config, deployment_config)\n",
@@ -221,7 +235,7 @@
"\n",
"sample_input = bytes(sample_input, encoding='utf-8')\n",
"\n",
"print(local_service.run(input_data=sample_input))"
"local_service.run(input_data=sample_input)"
]
},
{
@@ -282,9 +296,8 @@
"local_service.reload()\n",
"print(\"--------------------------------------------------------------\")\n",
"\n",
"# after reload now if you call run this will return updated return message\n",
"\n",
"print(local_service.run(input_data=sample_input))"
"# After calling reload(), run() will return the updated message.\n",
"local_service.run(input_data=sample_input)"
]
},
{
@@ -296,10 +309,9 @@
"If you want to change your model(s), Conda dependencies, or deployment configuration, call `update()` to rebuild the Docker image.\n",
"\n",
"```python\n",
"\n",
"local_service.update(models = [SomeOtherModelObject],\n",
" deployment_config = local_config,\n",
" inference_config = inference_config)\n",
"local_service.update(models=[SomeOtherModelObject],\n",
" inference_config=inference_config,\n",
" deployment_config=local_config)\n",
"```"
]
},
@@ -323,7 +335,7 @@
"metadata": {
"authors": [
{
"name": "raymondl"
"name": "keriehm"
}
],
"kernelspec": {