Skip to content

Commit 09fc146

Browse files
committed
Update code and text
1 parent e9794a4 commit 09fc146

File tree

2 files changed

+60
-54
lines changed

2 files changed

+60
-54
lines changed

articles/machine-learning/how-to-use-mlflow-configure-tracking.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ You need the following prerequisites to follow this tutorial:
3131

3232
[!INCLUDE [mlflow-prereqs](includes/machine-learning-mlflow-prereqs.md)]
3333

34+
## Configure the MLflow tracking URI
3435

35-
## Configure MLflow tracking URI
36-
37-
To connect MLflow to an Azure Machine Learning workspace, you need the tracking URI for the workspace. Each workspace has its own tracking URI and it has the protocol `azureml://`.
36+
To connect MLflow to an Azure Machine Learning workspace, you need the tracking URI of the workspace. Each workspace has its own tracking URI, which starts with the protocol `azureml://`.
3837

3938
[!INCLUDE [mlflow-configure-tracking](includes/machine-learning-mlflow-configure-tracking.md)]
4039

articles/machine-learning/includes/machine-learning-mlflow-configure-tracking.md

Lines changed: 58 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ ms.author: fasantia
1212

1313
[!INCLUDE [cli v2](machine-learning-cli-v2.md)]
1414

15-
1. Login and configure your workspace:
15+
1. Sign in and configure your workspace:
1616

1717
```bash
1818
az account set --subscription <subscription>
1919
az configure --defaults workspace=<workspace> group=<resource-group> location=<location>
2020
```
2121

22-
1. You can get the tracking URI using the `az ml workspace` command:
22+
1. Get the tracking URI by using the `az ml workspace` command:
2323

2424
```bash
2525
az ml workspace show --query mlflow_tracking_uri
@@ -29,93 +29,99 @@ ms.author: fasantia
2929

3030
[!INCLUDE [sdk v2](machine-learning-sdk-v2.md)]
3131

32-
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 compute you are using. The following sample gets the unique MLFLow tracking URI associated with your workspace.
32+
You can use the [Azure Machine Learning SDK v2 for Python](../concept-v2.md) to get the Azure Machine Learning MLflow tracking URI. Ensure that the `azure-ai-ml` library is installed in your compute instance. Then use the following code to get the unique MLFLow tracking URI that's associated with your workspace.
3333
34-
1. Login into your workspace using the `MLClient`. The easier way to do that is by using the workspace config file:
34+
1. Use an instance of `MLClient` to sign in to your workspace. There are two options for signing in:
3535
36-
```python
37-
from azure.ai.ml import MLClient
38-
from azure.identity import DefaultAzureCredential
36+
- The easiest way is to use the workspace configuration file:
3937
40-
ml_client = MLClient.from_config(credential=DefaultAzureCredential())
41-
```
38+
```python
39+
from azure.ai.ml import MLClient
40+
from azure.identity import DefaultAzureCredential
4241
43-
> [!TIP]
44-
> You can download the workspace configuration file by:
45-
> 1. Navigate to [Azure ML studio](https://ml.azure.com)
46-
> 2. Click on the upper-right corner of the page -> Download config file.
47-
> 3. Save the file `config.json` in the same directory where you are working on.
42+
ml_client = MLClient.from_config(credential=DefaultAzureCredential())
43+
```
4844
49-
1. Alternatively, you can use the subscription ID, resource group name and workspace name to get it:
45+
> [!TIP]
46+
>
47+
> You can download the workspace configuration file by taking the following steps:
48+
>
49+
> 1. Go to [Azure Machine Learning studio](https://ml.azure.com).
50+
> 1. In the upper right corner, select the name of your workspace.
51+
> 1. In the Directory + Subscription + Workspace window, select __Download config file__.
52+
> 3. Save the *config.json* file in the directory that you are working in.
5053
51-
```python
52-
from azure.ai.ml import MLClient
53-
from azure.identity import DefaultAzureCredential
54-
55-
#Enter details of your AzureML workspace
56-
subscription_id = '<SUBSCRIPTION_ID>'
57-
resource_group = '<RESOURCE_GROUP>'
58-
workspace_name = '<WORKSPACE_NAME>'
59-
60-
ml_client = MLClient(credential=DefaultAzureCredential(),
61-
subscription_id=subscription_id,
62-
resource_group_name=resource_group,
63-
workspace_name=workspace_name)
64-
```
54+
- Alternatively, you can use your subscription ID, resource group name, and workspace name to sign in:
55+
56+
```python
57+
from azure.ai.ml import MLClient
58+
from azure.identity import DefaultAzureCredential
59+
60+
# Enter information about your Azure Machine Learning workspace.
61+
subscription_id = '<subscription-ID>'
62+
resource_group = '<resource-group-name>'
63+
workspace_name = '<workspace-name>'
6564
66-
> [!IMPORTANT]
67-
> `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` or any other method available in [`azure.identity`](https://pypi.org/project/azure-identity/) package.
65+
ml_client = MLClient(credential=DefaultAzureCredential(),
66+
subscription_id=subscription_id,
67+
resource_group_name=resource_group,
68+
workspace_name=workspace_name)
69+
```
6870
69-
1. Get the Azure Machine Learning Tracking URI:
71+
> [!IMPORTANT]
72+
> The `DefaultAzureCredential` method tries to pull credentials from the available context. But you might want to specify credentials in a different way, for instance by using the web browser in an interactive way. In these cases, you can use `InteractiveBrowserCredential` or any other method available in the [`azure.identity`](https://pypi.org/project/azure-identity/) package.
73+
74+
1. Get the Azure Machine Learning tracking URI:
7075
7176
```python
7277
mlflow_tracking_uri = ml_client.workspaces.get(ml_client.workspace_name).mlflow_tracking_uri
7378
```
7479
7580
# [Studio](#tab/studio)
7681
77-
Use the Azure Machine Learning portal to get the tracking URI:
82+
Use Azure Machine Learning studio to get the tracking URI:
7883
79-
1. Open the [Azure Machine Learning studio portal](https://ml.azure.com) and log in using your credentials.
80-
81-
1. In the upper right corner, click on the name of your workspace to show the __Directory + Subscription + Workspace__ blade.
82-
83-
1. Click on __View all properties in Azure Portal__.
84+
1. Open [Azure Machine Learning studio](https://ml.azure.com) and use your credentials to sign in.
8485
85-
1. On the __Essentials__ section, you will find the property __MLflow tracking URI__.
86+
1. In the upper right corner, select the name of your workspace.
8687
88+
1. In the Directory + Subscription + Workspace window, select __View all properties in Azure Portal__. The resource page for your workspace opens in the Azure portal.
89+
90+
1. Under __Essentials__, copy the __MLflow tracking URI__ value.
8791
8892
# [Manually](#tab/manual)
8993
90-
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:
94+
You can construct the Azure Machine Learning tracking URI manually. You need your subscription ID, the region your workspace is deployed in, your resource group name, and your workspace name. To get the URI, enter those values into the following code:
9195
9296
> [!WARNING]
93-
> If you are working in a private link-enabled workspace, the MLflow endpoint will also use a private link to communicate with Azure Machine Learning. As a consequence, the tracking URI will look different as proposed here. You need to get the tracking URI using the Azure ML SDK or CLI v2 on those cases.
97+
> If you use a private link-enabled workspace, the MLflow endpoint also uses a private link to communicate with Azure Machine Learning. As a result, the tracking URI uses a format that's different from the one in this article. In this case, you need to use the Azure Machine Learning SDK for Python or the Azure Machine Learning CLI v2 to get the tracking URI.
9498

9599
```python
96-
region = "<LOCATION>"
97-
subscription_id = '<SUBSCRIPTION_ID>'
98-
resource_group = '<RESOURCE_GROUP>'
99-
workspace_name = '<AML_WORKSPACE_NAME>'
100+
region = "<region>"
101+
subscription_id = '<subscription-ID>'
102+
resource_group = '<resource-group-name>'
103+
workspace_name = '<workspace-name>'
100104
101105
mlflow_tracking_uri = f"azureml://{region}.api.azureml.ms/mlflow/v1.0/subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.MachineLearningServices/workspaces/{workspace_name}"
102106
```
103107

104-
1. Configuring the tracking URI:
108+
---
109+
110+
1. Configure the tracking URI:
105111

106-
# [Using MLflow SDK](#tab/mlflow)
112+
# [MLflow SDK](#tab/mlflow)
107113

108-
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.
114+
Use the [`set_tracking_uri()`](https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.set_tracking_uri) method to set the MLflow tracking URI to the tracking URI of your workspace.
109115

110116
```python
111117
import mlflow
112118
113119
mlflow.set_tracking_uri(mlflow_tracking_uri)
114120
```
115121

116-
# [Using environment variables](#tab/environ)
122+
# [Environment variables](#tab/environ)
117123

118-
You can set the MLflow environment variables [MLFLOW_TRACKING_URI](https://mlflow.org/docs/latest/tracking.html#logging-to-a-tracking-server) in your compute to make any interaction with MLflow in that compute to point by default to Azure Machine Learning.
124+
In your compute instance, use the following code to set the [MLFLOW_TRACKING_URI](https://mlflow.org/docs/latest/tracking.html#logging-to-a-tracking-server) MLflow environment variable to the tracking URI of your workspace. This assignment makes all interactions with MLflow in that compute instance point to Azure Machine Learning by default.
119125

120126
```bash
121127
MLFLOW_TRACKING_URI=$(az ml workspace show --query mlflow_tracking_uri | sed 's/"//g')
@@ -124,4 +130,5 @@ ms.author: fasantia
124130
---
125131

126132
> [!TIP]
127-
> When working on shared environments, like an Azure Databricks cluster, Azure Synapse Analytics cluster, or similar, it is useful to set the environment variable `MLFLOW_TRACKING_URI` at the cluster level to automatically configure the MLflow tracking URI to point to Azure Machine Learning for all the sessions running in the cluster rather than to do it on a per-session basis.
133+
>
134+
> Some scenarios involve working in a shared environment like an Azure Databricks cluster or an Azure Synapse Analytics cluster. In these cases, it's useful to set the `MLFLOW_TRACKING_URI` environment variable at the cluster level rather than for each session. Setting the variable at the cluster level automatically configures the MLflow tracking URI to point to Azure Machine Learning for all sessions in the cluster.

0 commit comments

Comments
 (0)