Skip to content
43 changes: 16 additions & 27 deletions tutorials/get-started-notebooks/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -255,31 +255,20 @@
" # Registering the model to the workspace\n",
" print(\"Registering the model via MLFlow\")\n",
"\n",
" # pin numpy\n",
" conda_env = {\n",
" 'name': 'mlflow-env',\n",
" 'channels': ['conda-forge'],\n",
" 'dependencies': [\n",
" 'python=3.10.15',\n",
" 'pip<=21.3.1',\n",
" {\n",
" 'pip': [\n",
" 'mlflow==2.17.0',\n",
" 'cloudpickle==2.2.1',\n",
" 'pandas==1.5.3',\n",
" 'psutil==5.8.0',\n",
" 'scikit-learn==1.5.2',\n",
" 'numpy==1.26.4',\n",
" ]\n",
" }\n",
" ],\n",
" }\n",
"\n",
" mlflow.sklearn.log_model(\n",
" sk_model=clf,\n",
" registered_model_name=args.registered_model_name,\n",
" artifact_path=args.registered_model_name,\n",
" conda_env=conda_env,\n",
" # Save model locally, remove conda.yaml to avoid Docker build failure,\n",
" # then log artifacts and register (AzureML Docker template uses\n",
" # deprecated conda info --root in newer conda versions)\n",
" model_local_path = \"model_output\"\n",
" mlflow.sklearn.save_model(sk_model=clf, path=model_local_path)\n",
" for fname in [\"conda.yaml\", \"requirements.txt\"]:\n",
" fp = os.path.join(model_local_path, fname)\n",
" if os.path.exists(fp):\n",
" os.remove(fp)\n",
" mlflow.log_artifacts(model_local_path, artifact_path=args.registered_model_name)\n",
" run_id = mlflow.active_run().info.run_id\n",
" mlflow.register_model(\n",
" f\"runs:/{run_id}/{args.registered_model_name}\",\n",
" args.registered_model_name,\n",
" )\n",
"\n",
" # Saving the model to a file\n",
Expand Down Expand Up @@ -353,7 +342,7 @@
" registered_model_name=registered_model_name,\n",
" ),\n",
" code=\"./src/\", # location of source code\n",
" command=\"python main.py --data ${{inputs.data}} --test_train_ratio ${{inputs.test_train_ratio}} --learning_rate ${{inputs.learning_rate}} --registered_model_name ${{inputs.registered_model_name}}\",\n",
" command=\"pip install mlflow==2.17.0 && python main.py --data ${{inputs.data}} --test_train_ratio ${{inputs.test_train_ratio}} --learning_rate ${{inputs.learning_rate}} --registered_model_name ${{inputs.registered_model_name}}\",\n",
" environment=\"azureml://registries/azureml/environments/sklearn-1.5/labels/latest\",\n",
" display_name=\"credit_default_prediction\",\n",
")"
Expand Down Expand Up @@ -721,4 +710,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}
Loading