You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 submit training jobs with [MLflow Projects](https://www.mlflow.org/docs/latest/projects.html) and Azure Machine Learning backend support. You can submit jobs locally with Azure Machine Learning tracking or migrate your runs to the cloud like via an [Azure Machine Learning Compute](./how-to-create-attach-compute-cluster.md).
@@ -33,37 +30,104 @@ In this article, learn how to enable MLflow's tracking URI and logging API, coll
33
30
## Prerequisites
34
31
35
32
* Install the `azureml-mlflow` package.
36
-
* This package automatically brings in `azureml-core` of the [The Azure Machine Learning Python SDK](/python/api/overview/azure/ml/install), which provides the connectivity for MLflow to access your workspace.
37
33
*[Create an Azure Machine Learning Workspace](quickstart-create-resources.md).
38
34
* See which [access permissions you need to perform your MLflow operations with your workspace](how-to-assign-roles.md#mlflow-operations).
35
+
* Configure MLflow for tracking in Azure Machine Learning, as explained in the next section.
39
36
40
-
## Train MLflow Projects on local compute
37
+
### Set up tracking environment
38
+
39
+
To configure MLflow for working with Azure Machine Learning, you need to point your MLflow environment to the Azure Machine Learning MLflow Tracking URI.
40
+
41
+
> [!NOTE]
42
+
> When running on Azure Compute (Azure Notebooks, Jupyter Notebooks hosted on Azure Compute Instances or Compute Clusters) you don't have to configure the tracking URI. It's automatically configured for you.
You can get the Azure ML MLflow tracking URI using the [Azure Machine Learning SDK v2 for Python](concept-v2.md). Ensure you have the library `azure-ai-ml` installed in the cluster you are using. The following sample gets the unique MLFLow tracking URI associated with your workspace. Then the method [`set_tracking_uri()`](https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.set_tracking_uri) points the MLflow tracking URI to that URI.
49
+
50
+
1. Using the workspace configuration file:
51
+
52
+
```Python
53
+
from azure.ai.ml import MLClient
54
+
from azure.identity import DefaultAzureCredential
55
+
import mlflow
41
56
42
-
This example shows how to submit MLflow projects locally with Azure Machine Learning tracking.
Install the `azureml-mlflow` package to use MLflow Tracking with Azure Machine Learning on your experiments locally. Your experiments can run via a Jupyter Notebook or code editor.
62
+
> [!TIP]
63
+
> You can download the workspace configuration file by:
64
+
>1. Navigate to [Azure ML studio](https://ml.azure.com)
65
+
>2. Click on the uper-right corner of the page -> Download config file.
66
+
>3. Save the file`config.json`in the same directory where you are working on.
45
67
46
-
```shell
47
-
pip install azureml-mlflow
68
+
1. Using the subscription ID, resource group name and workspace name:
>`DefaultAzureCredential` will try to pull the credentials from the available context. If you want to specify credentials in a different way, for instance using the web browser in an interactive way, you can use `InteractiveBrowserCredential`orany other method available in`azure.identity` package.
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.
96
+
97
+
```Azure CLI
98
+
export MLFLOW_TRACKING_URI=$(az ml workspace show --query mlflow_tracking_uri | sed 's/"//g')
48
99
```
49
100
50
-
Import the `mlflow` and [`Workspace`](/python/api/azureml-core/azureml.core.workspace%28class%29) classes to access MLflow's tracking URI and configure your workspace.
101
+
>[!IMPORTANT]
102
+
> Make sure you are logged in to your Azure account on your local machine, otherwise the tracking URI returns an empty string. If you are using any Azure ML compute the tracking environment and experiment name is already configured.
103
+
104
+
# [Building the MLflow tracking URI](#tab/build)
51
105
52
-
```Python
106
+
The Azure Machine Learning Tracking URI can be constructed using the subscription ID, region of where the resource is deployed, resource group name and workspace name. The following code sample shows how:
Set the MLflow experiment name with `set_experiment()` and start your training run with `start_run()`. Then, use `log_metric()` to activate the MLflow logging API and begin logging your training run metrics.
120
+
> [!NOTE]
121
+
> You can also get this URL by:
122
+
>1. Navigate to [Azure ML studio](https://ml.azure.com)
123
+
>2. Click on the uper-right corner of the page -> View all properties in Azure Portal -> MLflow tracking URI.
124
+
>3. Copy the URIand use it with the method `mlflow.set_tracking_uri`.
This example shows how to submit MLflow projects locally with Azure Machine Learning.
67
131
68
132
Create the backend configuration object to store necessary information for the integration such as, the compute target and which type of managed environment to use.
This example shows how to submit MLflow projects on a remote compute with Azure Machine Learning tracking.
108
172
109
-
Install the `azureml-mlflow` package to use MLflow Tracking with Azure Machine Learning on your experiments locally. Your experiments can run via a Jupyter Notebook or code editor.
110
-
111
-
```shell
112
-
pip install azureml-mlflow
113
-
```
114
-
115
-
Import the `mlflow` and [`Workspace`](/python/api/azureml-core/azureml.core.workspace%28class%29) classes to access MLflow's tracking URI and configure your workspace.
Set the MLflow experiment name with `set_experiment()` and start your training run with `start_run()`. Then, use `log_metric()` to activate the MLflow logging API and begin logging your training run metrics.
Create the backend configuration object to store necessary information for the integration such as, the compute target and which type of managed environment to use.
134
174
135
175
The integration accepts "COMPUTE"and"USE_CONDA"as parameters where "COMPUTE"isset to the name of your remote compute cluster and"USE_CONDA" which creates a new environment for the project from the environment configuration file. If "COMPUTE"is present in the object, the project will be automatically submitted to the remote compute and ignore "USE_CONDA". MLflow accepts a dictionary objector a JSONfile.
0 commit comments