Skip to content

Instantly share code, notes, and snippets.

@ezwiefel
Last active November 2, 2020 22:49
Show Gist options
  • Save ezwiefel/db6b60133ba8ae547236702bfd9494b0 to your computer and use it in GitHub Desktop.
Save ezwiefel/db6b60133ba8ae547236702bfd9494b0 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Upgrading AzureML SDK on Compute Instance\n",
"\n",
"To upgrade the Azure ML SDK, we'll do the following steps, in order:\n",
"\n",
"1. Create a variable named `REQUIREMENTS_FILE` which is uniquely named on your compute instance. Here we're including part of a generated UUID to prevent accidently overwriting one of your files. \n",
"1. Generate a requirements.txt file including all of the Azure ML packages that are out of date using the command `%pip list -o | grep azureml | awk '{ print $1\"==\"$3 }' > {REQUIREMENTS_FILE}` This command has 4 parts.\n",
" 1. __`pip list -o`:__ Will list outdated PIP packages in the format:\n",
" ```\n",
" Package Version Latest Type\n",
" -------------------- ------------------- ------- -----\n",
" absl-py 0.10.0 0.11.0 wheel\n",
" adal 1.2.4 1.2.5 wheel\n",
" azure-core 1.8.0 1.8.2 wheel\n",
" azure-identity 1.2.0 1.4.1 wheel\n",
" azure-mgmt-keyvault 2.2.0 8.0.0 wheel\n",
" azure-mgmt-resource 10.2.0 15.0.0 wheel\n",
" azure-mgmt-storage 11.2.0 16.0.0 wheel\n",
" azure-storage-blob 12.4.0 12.5.0 wheel\n",
" cffi 1.14.2 1.14.3 wheel\n",
" configparser 3.7.4 5.0.1 wheel\n",
" cryptography 3.1 3.2.1 wheel\n",
" debugpy 1.0.0rc2 1.1.0 wheel\n",
" ```\n",
" 1. __`grep azureml`:__ Will filter the results above to give us only the lines containing `azureml`\n",
" 1. __`awk '{ print $1\"==\"$3 }'`:__ Will create a string from each line with the 1st column, ==, and the 3rd\n",
" 1. __`> {REQUIREMENTS_FILE}`:__ Will create or overwrite a file with the same name as our REQUIREMENTS_FILE variable.\n",
"1. Install the requirements from the `REQUIREMENTS_FILE`\n",
"1. List out the newly install packages and then remove the `REQUIREMENTS_FILE`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from uuid import uuid4\n",
"UUID_PART = str(uuid4()).split('-')[-1]\n",
"REQUIREMENTS_FILE= \"aml_requirements_{0}.txt\".format(UUID_PART)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip list -o | grep azureml | awk '{ print $1\"==\"$3 }' > {REQUIREMENTS_FILE}\n",
"%pip install -r {REQUIREMENTS_FILE}\n",
"%pip list | grep azureml && rm {REQUIREMENTS_FILE}"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.6 - AzureML",
"language": "python",
"name": "python3-azureml"
},
"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.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment