Skip to content

Commit fef1649

Browse files
committed
Pm feedback
1 parent fda6ef1 commit fef1649

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

articles/machine-learning/how-to-use-mlflow-cli-runs.md

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ ms.topic: how-to
1313
ms.custom: devx-track-python
1414
---
1515

16-
# Track ML experiments and models with MLflow or Azure Machine Learning CLI (v2) (preview)
16+
# Track ML experiments and models with MLflow Azure Machine Learning CLI (v2) (preview)
1717

18-
[!INCLUDE [preview disclaimer](../../includes/machine-learning-preview-generic-disclaimer.md)]
1918

2019
In this article, learn how to enable MLflow's tracking URI and logging API, collectively known as [MLflow Tracking](https://mlflow.org/docs/latest/quickstart.html#using-the-tracking-api), to connect Azure Machine Learning as the backend of your MLflow experiments. You can accomplish this connection with either the MLflow Python API or the [Azure Machine Learning CLI (v2)](how-to-train-cli.md). You also learn how to use [MLflow's Model Registry](https://mlflow.org/docs/latest/model-registry.html) capabilities with Azure Machine Learning.
2120

22-
[MLflow](https://www.mlflow.org) is an open-source library for managing the lifecycle of your machine learning experiments. MLFlow Tracking is a component of MLflow that logs and tracks your training run metrics and model artifacts, no matter your experiment's environment--locally on your computer, on a remote compute target, a virtual machine, or an [Azure Databricks cluster](how-to-use-mlflow-azure-databricks.md).
21+
[MLflow](https://www.mlflow.org) is an open-source library for managing the lifecycle of your machine learning experiments. MLflow Tracking is a component of MLflow that logs and tracks your training run metrics and model artifacts, no matter your experiment's environment--locally on your computer, on a remote compute target, a virtual machine, or an [Azure Databricks cluster](how-to-use-mlflow-azure-databricks.md).
2322

2423
See [MLflow and Azure Machine Learning](concept-mlflow.md) for all supported MLflow and Azure Machine Learning functionality including MLflow Project support (preview) and model deployment.
2524

@@ -35,18 +34,17 @@ See [MLflow and Azure Machine Learning](concept-mlflow.md) for all supported MLf
3534
* [Create an Azure Machine Learning Workspace](how-to-manage-workspace.md).
3635
* See which [access permissions you need to perform your MLflow operations with your workspace](how-to-assign-roles.md#mlflow-operations).
3736

38-
* Install and [set up CLI (v2)](how-to-configure-cli.md#prerequisites) and make sure you install the ml extension
37+
* Install and [set up CLI (v2)](how-to-configure-cli.md#prerequisites) and make sure you install the ml extension.
38+
[!INCLUDE [preview disclaimer](../../includes/machine-learning-preview-generic-disclaimer.md)]
39+
3940

4041
## Track runs from your local machine
4142

4243
MLflow Tracking with Azure Machine Learning lets you store the logged metrics and artifacts runs that were executed on your local machine into your Azure Machine Learning workspace.
4344

4445
### Set up tracking environment
4546

46-
To track a local run, you need to point your local machine to the Azure Machine Learning MLFlow Tracking URI.
47-
48-
>[!NOTE]
49-
>The tracking URI is valid up to an hour or less. If you restart your script after some idle time, use the get_mlflow_tracking_uri API to get a new URI.
47+
To track a local run, you need to point your local machine to the Azure Machine Learning MLflow Tracking URI.
5048

5149
# [MLflow](#tab/mlflow)
5250

@@ -56,12 +54,21 @@ The following code uses `mlflow` and the [`subprocess`](https://docs.python.org/
5654
import mlflow
5755
import subprocess
5856

59-
#Get MLFLow UI through the Azure ML CLI (v2) and convert to string
57+
#Get MLFLow URI through the Azure ML CLI (v2) and convert to string
6058
MLFLOW_TRACKING_URI = subprocess.run(["az", "ml", "workspace", "show", "--query", "mlflow_tracking_uri", "-o", "tsv"], stdout=subprocess.PIPE, text=True)
59+
6160
MLFLOW_TRACKING_URI = str(MLFLOW_TRACKING_URI.stdout).strip()
61+
62+
## Set the MLFLOW TRACKING URI
63+
mlflow.set_tracking_uri(MLFLOW_TRACKING_URI)
64+
65+
## Make sure the MLFLow URI looks something like this:
66+
## azureml://westus.api.azureml.ms/mlflow/v1.0/subscriptions/<Sub-ID>/resourceGroups/<RG>/providers/Microsoft.MachineLearningServices/workspaces/<WS>
67+
68+
print("MLFlow Tracking URI:",MLFLOW_TRACKING_URI)
6269
```
6370

64-
# [Azure CLI](#tab/azure-cli)
71+
# [Azure CLI (v2)](#tab/azure-cli)
6572

6673
Another option is to set one of the MLflow environment variables [MLFLOW_TRACKING_URI](https://mlflow.org/docs/latest/tracking.html#logging-to-a-tracking-server) directly in your terminal.
6774

@@ -93,9 +100,9 @@ With MLflow you can use the [`mlflow.set_experiment()`](https://mlflow.org/docs/
93100
with mlflow.start_run(experiment_id=experiment_name) as mlflow_run:
94101
mlflow.log_param("hello_param", "world")
95102
```
96-
# [Azure CLI](#tab/azure-cli)
103+
# [Azure CLI (v2)](#tab/azure-cli)
97104

98-
With the Azure CLI, set one of the MLflow environment variables [MLFLOW_EXPERIMENT_NAME or MLFLOW_EXPERIMENT_ID](https://mlflow.org/docs/latest/cli.html#cmdoption-mlflow-run-arg-uri) with the experiment name.
105+
With the Azure CLI (v2), set one of the MLflow environment variables [MLFLOW_EXPERIMENT_NAME or MLFLOW_EXPERIMENT_ID](https://mlflow.org/docs/latest/cli.html#cmdoption-mlflow-run-arg-uri) with the experiment name.
99106

100107
```Azure CLI
101108
# Configure MLflow to communicate with a Azure Machine Learning-hosted tracking server
@@ -120,6 +127,8 @@ with mlflow.start_run() as mlflow_run:
120127

121128
## Track remote runs with Azure Machine Learning CLI (v2) (preview)
122129

130+
[!INCLUDE [preview disclaimer](../../includes/machine-learning-preview-generic-disclaimer.md)]
131+
123132
Remote runs (jobs) let you train your models on more powerful computes, such as GPU enabled virtual machines, or Machine Learning Compute clusters. See [Use compute targets for model training](how-to-set-up-training-targets.md) to learn about different compute options.
124133

125134
MLflow Tracking with Azure Machine Learning lets you store the logged metrics and artifacts from your remote runs into your Azure Machine Learning workspace. Any run with MLflow Tracking code in it logs metrics automatically to the workspace.
@@ -151,7 +160,7 @@ if __name__ == "__main__":
151160
main()
152161
```
153162

154-
Use the [Azure Machine Learning CLI (v2)](how-to-train-cli.md) to submit a run. When using the Azure Machine Learning CLI (v2), the MLflow tracking URI and experiment name are set automatically and directs the logging from MLflow to your workspace. Learn more about [logging Azure Machine Learning CLI (v2) experiments with MLflow](how-to-train-cli.md#model-tracking-with-mlflow)
163+
Use the [Azure Machine Learning CLI (v2)](how-to-train-cli.md) to submit a remote run. When using the Azure Machine Learning CLI (v2), the MLflow tracking URI and experiment name are set automatically and directs the logging from MLflow to your workspace. Learn more about [logging Azure Machine Learning CLI (v2) experiments with MLflow](how-to-train-cli.md#model-tracking-with-mlflow)
155164

156165
Create a YAML file with your job definition in a `job.yml` file. This file should be created outside the `src` directory. Copy this code into the file:
157166

@@ -179,10 +188,11 @@ az ml job create -f job.yml --web
179188

180189
The metrics and artifacts from MLflow logging are tracked in your workspace. To view them anytime, navigate to your workspace and find the experiment by name in your workspace in [Azure Machine Learning studio](https://ml.azure.com). Or run the below code.
181190

182-
Retrieve run metric using MLFlow [get_run()](https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.get_run).
191+
Retrieve run metric using MLflow [get_run()](https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.get_run).
183192

184193
```Python
185194
from mlflow.tracking import MlflowClient
195+
186196
# Use MlFlow to retrieve the run that was just completed
187197
client = MlflowClient()
188198
run_id = mlflow_run.info.run_id
@@ -211,7 +221,8 @@ client.download_artifacts(run_id, "helloworld.txt", ".")
211221

212222
### Compare and query
213223

214-
To compare and query all MLFlow runs in your Azure Machine Learning Workspace
224+
Compare and query all MLflow runs in your Azure Machine Learning Workspace with the following code.
225+
[Learn more about how to query runs with MLflow](how-to-train-cli.md#query-metrics-with-mlflow).
215226

216227
```Python
217228
from mlflow.entities import ViewType
@@ -257,7 +268,7 @@ To register and view a model from a run, use the following steps:
257268

258269
## Example notebooks
259270

260-
[Use MLFlow and CLI (v2)](https://github.com/Azure/azureml-examples/blob/main/cli/jobs/basics/hello-mlflow.yml)
271+
[Use MLflow and CLI (v2)](https://github.com/Azure/azureml-examples/blob/main/cli/jobs/basics/hello-mlflow.yml)
261272

262273
## Next steps
263274

0 commit comments

Comments
 (0)