Skip to content

Commit 7bcb288

Browse files
Merge pull request #231438 from santiagxf/santiagxf/mlflow-models-fix
Update how-to-manage-models-mlflow.md
2 parents e8566b4 + f5150cd commit 7bcb288

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

articles/machine-learning/how-to-manage-models-mlflow.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ ms.custom: how-to, devx-track-python
1515

1616
# Manage models registries in Azure Machine Learning with MLflow
1717

18-
Azure Machine Learning supports MLflow for model management. This represents a convenient way to support the entire model lifecycle for users familiar with the MLFlow client. The following article describes the different capabilities and how it compares with other options.
18+
Azure Machine Learning supports MLflow for model management. Such approach represents a convenient way to support the entire model lifecycle for users familiar with the MLFlow client. The following article describes the different capabilities and how it compares with other options.
1919

2020
### Prerequisites
2121

2222
[!INCLUDE [mlflow-prereqs](../../includes/machine-learning-mlflow-prereqs.md)]
2323

24-
* Some operations may be executed directly using the MLflow fluent API (`mlflow.<method>`). However, others may require to create an MLflow client, which allows to communicate with Azure Machine Learning in the MLflow protocol. You can create an `MlflowClient` object as follows. This tutorial will use the object `client` to refer to such MLflow client.
24+
* Some operations may be executed directly using the MLflow fluent API (`mlflow.<method>`). However, others may require to create an MLflow client, which allows to communicate with Azure Machine Learning in the MLflow protocol. You can create an `MlflowClient` object as follows. This tutorial uses the object `client` to refer to such MLflow client.
2525

2626
```python
2727
using mlflow
@@ -31,9 +31,11 @@ Azure Machine Learning supports MLflow for model management. This represents a c
3131

3232
## Registering new models in the registry
3333

34+
The models registry offer a convenient and centralized way to manage models in a workspace. Each workspace has its own independent models registry. The following section explains multiple ways to register models in the registry using MLflow SDK.
35+
3436
### Creating models from an existing run
3537

36-
If you have an MLflow model logged inside of a run and you want to register it in a registry, you can do that by using the run ID and the path where the model was logged. See [Manage experiments and runs with MLflow](how-to-track-experiments-mlflow.md) to know how to query this information if you don't have it.
38+
If you have an MLflow model logged inside of a run and you want to register it in a registry, use the run ID and the path where the model was logged. See [Manage experiments and runs with MLflow](how-to-track-experiments-mlflow.md) to know how to query this information if you don't have it.
3739

3840
```python
3941
mlflow.register_model(f"runs:/{run_id}/{artifact_path}", model_name)
@@ -72,6 +74,8 @@ mlflow.register_model(f"file://{model_local_path}", "local-model-test")
7274

7375
## Querying model registries
7476

77+
You can use the MLflow SDK to query and search for models registered in the registry. The following section explains multiple ways to achieve it.
78+
7579
### Querying all the models in the registry
7680

7781
You can query all the registered models in the registry using the MLflow client. The following sample prints all the model's names:
@@ -81,12 +85,18 @@ for model in client.search_registered_models():
8185
print(f"{model.name}")
8286
```
8387

88+
Use `order_by` to order by a specific property like `name`, `version`, `creation_timestamp`, and `last_updated_timestamp`:
89+
90+
```python
91+
client.search_registered_models(order_by=["name ASC"])
92+
```
93+
8494
> [!NOTE]
8595
> __MLflow 2.0 advisory:__ In older versions of Mlflow (<2.0), use method `MlflowClient.list_registered_models()` instead.
8696
8797
### Getting specific versions of the model
8898

89-
The command above will retrieve the model object which contains all the model versions. However, if you want to get the last registered model version of a given model, you can use `get_registered_model`:
99+
The `search_registered_models()` command retrieves the model object, which contains all the model versions. However, if you want to get the last registered model version of a given model, you can use `get_registered_model`:
90100

91101
```python
92102
client.get_registered_model(model_name)
@@ -114,7 +124,7 @@ You can load models directly from the registry to restore the models objects tha
114124
MLflow supports model's stages to manage model's lifecycle. Model's version can transition from one stage to another. Stages are assigned to a model's version (instead of models) which means that a given model can have multiple versions on different stages.
115125

116126
> [!IMPORTANT]
117-
> Stages can only be accessed using the MLflow SDK. They don't show up in the [Azure Machine Learning Studio portal](https://ml.azure.com) and can't be retrieved using neither Azure Machine Learning SDK, Azure Machine Learning CLI, or Azure Machine Learning REST API. Creating deployment from a given model's stage is not supported by the moment.
127+
> Stages can only be accessed using the MLflow SDK. They don't show up in the [Azure ML Studio portal](https://ml.azure.com) and can't be retrieved using neither Azure ML SDK, Azure ML CLI, or Azure ML REST API. Creating deployment from a given model's stage is not supported by the moment.
118128
119129
### Querying model stages
120130

@@ -144,7 +154,7 @@ Transitioning a model's version to a particular stage can be done using the MLfl
144154
client.transition_model_version_stage(model_name, version=3, stage="Staging")
145155
```
146156

147-
By default, if there were an existing model version in that particular stage, it will remain there. Hence, it won't be replaced as multiple model's versions can be in the same stage at the same time. Alternatively, you can indicate `archive_existing_versions=True` to tell MLflow to move the existing model's version to the stage `Archived`.
157+
By default, if there were an existing model version in that particular stage, it remains there. Hence, it isn't replaced as multiple model's versions can be in the same stage at the same time. Alternatively, you can indicate `archive_existing_versions=True` to tell MLflow to move the existing model's version to the stage `Archived`.
148158

149159
```python
150160
client.transition_model_version_stage(
@@ -162,7 +172,7 @@ model = mlflow.pyfunc.load_model(f"models:/{model_name}/Staging")
162172

163173
## Editing and deleting models
164174

165-
Editing registered models is supported in both Mlflow and Azure Machine Learning. However, there are some differences important to be noticed:
175+
Editing registered models is supported in both Mlflow and Azure ML. However, there are some differences important to be noticed:
166176

167177
> [!WARNING]
168178
> Renaming models is not supported in Azure Machine Learning as model objects are immmutable.
@@ -200,15 +210,15 @@ client.delete_model_version(model_name, version="2")
200210
201211
## Support matrix for managing models with MLflow
202212

203-
The MLflow client exposes several methods to retrieve and manage models. The following table shows which of those methods are currently supported in MLflow when connected to Azure Machine Learning. It also compares it with other models management capabilities in Azure Machine Learning.
213+
The MLflow client exposes several methods to retrieve and manage models. The following table shows which of those methods are currently supported in MLflow when connected to Azure ML. It also compares it with other models management capabilities in Azure ML.
204214

205-
| Feature | MLflow | Azure Machine Learning with MLflow | Azure Machine Learning CLIv2 | Azure Machine Learning Studio |
215+
| Feature | MLflow | Azure ML with MLflow | Azure ML CLIv2 | Azure ML Studio |
206216
| :- | :-: | :-: | :-: | :-: |
207217
| Registering models in MLflow format | **&check;** | **&check;** | **&check;** | **&check;** |
208218
| Registering models not in MLflow format | | | **&check;** | **&check;** |
209219
| Registering models from runs outputs/artifacts | **&check;** | **&check;**<sup>1</sup> | **&check;**<sup>2</sup> | **&check;** |
210220
| Registering models from runs outputs/artifacts in a different tracking server/workspace | **&check;** | | **&check;**<sup>5</sup> | **&check;**<sup>5</sup> |
211-
| Listing registered models | **&check;** | **&check;** | **&check;** | **&check;** |
221+
| Search/list registered models | **&check;** | **&check;** | **&check;** | **&check;** |
212222
| Retrieving details of registered model's versions | **&check;** | **&check;** | **&check;** | **&check;** |
213223
| Editing registered model's versions description | **&check;** | **&check;** | **&check;** | **&check;** |
214224
| Editing registered model's versions tags | **&check;** | **&check;** | **&check;** | **&check;** |
@@ -223,8 +233,8 @@ The MLflow client exposes several methods to retrieve and manage models. The fol
223233
> [!NOTE]
224234
> - <sup>1</sup> Use URIs with format `runs:/<ruin-id>/<path>`.
225235
> - <sup>2</sup> Use URIs with format `azureml://jobs/<job-id>/outputs/artifacts/<path>`.
226-
> - <sup>3</sup> Registered models are immutable objects in Azure Machine Learning.
227-
> - <sup>4</sup> Use search box in Azure Machine Learning Studio. Partial match supported.
236+
> - <sup>3</sup> Registered models are immutable objects in Azure ML.
237+
> - <sup>4</sup> Use search box in Azure ML Studio. Partial match supported.
228238
> - <sup>5</sup> Use [registries](how-to-manage-registries.md).
229239
230240
## Next steps

0 commit comments

Comments
 (0)