Skip to content

Commit 3f4339a

Browse files
authored
Merge pull request #203666 from santiagxf/santiagxf/aml-mlflow-review
Update MLflow general guidance
2 parents 7661551 + fe2008c commit 3f4339a

File tree

2 files changed

+77
-22
lines changed

2 files changed

+77
-22
lines changed

articles/machine-learning/concept-mlflow.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ With MLflow Tracking you can connect Azure Machine Learning as the backend of yo
4848

4949
Azure Machine Learning uses MLflow Tracking for metric logging and artifact storage for your experiments, whether you created the experiment via the Azure Machine Learning Python SDK, Azure Machine Learning CLI or the Azure Machine Learning studio. Learn more at [Track experiments with MLflow](how-to-use-mlflow-cli-runs.md).
5050

51+
> [!IMPORTANT]
52+
> - MLflow in R support is limited to tracking experiment's metrics and parameters on Azure Machine Learning jobs. RStudio or Jupyter Notebooks with R kernels are not supported. View the following [R example about using the MLflow tracking client with Azure Machine Learning](https://github.com/Azure/azureml-examples/tree/main/cli/jobs/single-step/r).
53+
> - MLflow in Java support is limited to tracking experiment's metrics and parameters on Azure Machine Learning jobs. View the following [Java example about using the MLflow tracking client with the Azure Machine Learning](https://github.com/Azure/azureml-examples/tree/main/cli/jobs/single-step/java/iris).
54+
5155
## Model Registries with MLflow
5256

5357
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.
@@ -68,7 +72,6 @@ You can submit training jobs to Azure Machine Learning using [MLflow Projects](h
6872

6973
Learn more at [Train ML models with MLflow projects and Azure Machine Learning (preview)](how-to-train-mlflow-projects.md).
7074

71-
7275
## MLflow SDK, Azure ML v2 and Azure ML Studio capabilities
7376

7477
The following table shows which operations are supported by each of the tools available in the ML lifecycle.
@@ -82,19 +85,27 @@ The following table shows which operations are supported by each of the tools av
8285
| Submit training pipelines | | **✓** | |
8386
| Manage experiments runs | **&check;**<sup>1</sup> | **&check;** | **&check;** |
8487
| Manage MLflow models | **&check;**<sup>3</sup> | **&check;** | **&check;** |
85-
| Manage non-MLflow models | **&check;**<sup>4</sup> | **&check;** | **&check;** |
86-
| Deploy MLflow models to Azure Machine Learning | **&check;**<sup>5</sup> | **&check;** | **&check;** |
88+
| Manage non-MLflow models | | **&check;** | **&check;** |
89+
| Deploy MLflow models to Azure Machine Learning | **&check;**<sup>4</sup> | **&check;** | **&check;** |
8790
| Deploy non-MLflow models to Azure Machine Learning | | **&check;** | **&check;** |
8891

8992
> [!NOTE]
9093
> - <sup>1</sup> View [Manage experiments and runs with MLflow](how-to-track-experiments-mlflow.md) for details.
9194
> - <sup>2</sup> Only artifacts and models can be downloaded.
9295
> - <sup>3</sup> View [Manage models registries in Azure Machine Learning with MLflow](how-to-manage-models-mlflow.md) for details.
93-
> - <sup>4</sup> Loading models using the syntax `models:/model-name/version` is not supported for non-MLflow models.
94-
> - <sup>5</sup> View [Deploy MLflow models to Azure Machine Learning](how-to-deploy-mlflow-models.md) for details. Deployment of MLflow models to batch inference using the MLflow SDK is not possible by the moment.
95-
96-
97-
## Next steps
98-
* [Track ML models with MLflow and Azure Machine Learning CLI v2](how-to-use-mlflow-cli-runs.md)
99-
* [Convert your custom model to MLflow model format for no code deployments](how-to-convert-custom-model-to-mlflow.md)
100-
* [Deploy MLflow models](how-to-deploy-mlflow-models.md)
96+
> - <sup>4</sup> View [Deploy MLflow models to Azure Machine Learning](how-to-deploy-mlflow-models.md) for details. Deployment of MLflow models to batch inference using the MLflow SDK is not possible by the moment.
97+
98+
## Example notebooks
99+
100+
If you are getting started with MLflow in Azure Machine Learning, we recommend you to explore the [notebooks examples about how to user MLflow](https://github.com/Azure/azureml-examples/blob/main/notebooks/using-mlflow/readme.md):
101+
102+
* [Training and tracking a classifier with MLflow](https://github.com/Azure/azureml-examples/blob/main/notebooks/using-mlflow/train-with-mlflow/xgboost_classification_mlflow.ipynb): Demonstrates how to track experiments using MLflow, log models and combine multiple flavors into pipelines.
103+
* [Training and tracking a classifier with MLflow using Service Principal authentication](https://github.com/Azure/azureml-examples/blob/main/notebooks/using-mlflow/train-with-mlflow/xgboost_service_principal.ipynb): Demonstrate how to track experiments using MLflow from compute that is running outside Azure ML and how to authenticate against Azure ML services using a Service Principal.
104+
* [Hyper-parameters optimization using child runs with MLflow and HyperOpt optimizer](https://github.com/Azure/azureml-examples/blob/main/notebooks/using-mlflow/train-with-mlflow/xgboost_nested_runs.ipynb): Demonstrate how to use child runs in MLflow to do hyper-parameter optimization for models using the popular library HyperOpt. It shows how to transfer metrics, params and artifacts from child runs to parent runs.
105+
* [Logging models instead of assets with MLflow](https://github.com/Azure/azureml-examples/blob/main/notebooks/using-mlflow/logging-models/logging_model_with_mlflow.ipynb): Demonstrates how to use the concept of models instead of artifacts with MLflow, including how to construct custom models.
106+
* [Manage experiments and runs with MLflow](https://github.com/Azure/azureml-examples/blob/main/notebooks/using-mlflow/run-history/run_history.ipynb): Demonstrates how to query experiments, runs, metrics, parameters and artifacts from Azure ML using MLflow.
107+
* [Manage models registries with MLflow](https://github.com/Azure/azureml-examples/blob/main/notebooks/using-mlflow/model-management/model_management.ipynb): Demonstrates how to manage models in registries using MLflow.
108+
* [No-code deployment with MLflow](https://github.com/Azure/azureml-examples/blob/main/notebooks/using-mlflow/no-code-deployment/deploying_with_mlflow.ipynb): Demonstrates how to deploy models in MLflow format to the different deployment target in Azure ML.
109+
* [Training models in Azure Databricks and deploying them on Azure ML with MLflow](https://github.com/Azure/azureml-examples/blob/main/notebooks/using-mlflow/no-code-deployment/track_with_databricks_deploy_aml.ipynb): Demonstrates how to train models in Azure Databricks and deploy them in Azure ML. It also includes how to handle cases where you also want to track the experiments with the MLflow instance in Azure Databricks.
110+
* [Migrating models with scoring scripts to MLflow format](https://github.com/Azure/azureml-examples/blob/main/notebooks/using-mlflow/migrating-scoring-to-mlflow/scoring_to_mlmodel.ipynb): Demonstrates how to migrate models with scoring scripts to no-code-deployment with MLflow.
111+
* [Using MLflow REST with Azure ML](https://github.com/Azure/azureml-examples/blob/main/notebooks/using-mlflow/using-rest-api/using_mlflow_rest_api.ipynb): Demonstrates how to work with MLflow REST API when connected to Azure ML.

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

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ For no-code-deployment, Azure Machine Learning
3939
> - Data type `mlflow.types.DataType.Binary` is not supported as column type in signatures. For models that work with images, we suggest you to use or (a) tensors inputs using the [TensorSpec input type](https://mlflow.org/docs/latest/python_api/mlflow.types.html#mlflow.types.TensorSpec), or (b) `Base64` encoding schemes with a `mlflow.types.DataType.String` column type, which is commonly used when there is a need to encode binary data that needs be stored and transferred over media.
4040
> - Signatures with tensors with unspecified shapes (`-1`) is only supported at the batch size by the moment. For instance, a signature with shape `(-1, -1, -1, 3)` is not supported but `(-1, 300, 300, 3)` is.
4141
42-
For more information about how to specify requests to online endpoints, view [Considerations when deploying to real-time inference](#considerations-when-deploying-to-real-time-inference). FOr more information about the supported file types in batch endpoints, view [Considerations when deploying to batch inference](#considerations-when-deploying-to-batch-inference).
42+
For more information about how to specify requests to online endpoints, view [Considerations when deploying to real-time inference](#considerations-when-deploying-to-real-time-inference). For more information about the supported file types in batch endpoints, view [Considerations when deploying to batch inference](#considerations-when-deploying-to-batch-inference).
4343

4444
## Deployment tools
4545

@@ -49,7 +49,7 @@ There are three workflows for deploying MLflow models to Azure Machine Learning:
4949
- [Deploy using Azure ML CLI (v2)](#deploy-using-azure-ml-cli-v2)
5050
- [Deploy using Azure Machine Learning studio](#deploy-using-azure-machine-learning-studio)
5151

52-
Each workflows has different capabilities, particularly around which type of compute they can target. The following table shows them:
52+
Each workflow has different capabilities, particularly around which type of compute they can target. The following table shows them:
5353

5454
| Scenario | MLflow SDK | Azure ML CLI/SDK v2 | Azure ML studio |
5555
| :- | :-: | :-: | :-: |
@@ -160,25 +160,31 @@ The MLflow plugin [azureml-mlflow](https://pypi.org/project/azureml-mlflow/) can
160160

161161
```python
162162
import json
163-
from mlflow.deployments import get_deploy_client
164163

165-
# Create the deployment configuration.
166164
deploy_config = {"computeType": "aks", "computeTargetName": "aks-mlflow" }
165+
166+
deployment_config_path = "deployment_config.json"
167+
with open(deployment_config_path, "w") as outfile:
168+
outfile.write(json.dumps(deploy_config))
167169
```
168170

169171
# [ACI](#tab/aci)
170172

171173
```python
172174
import json
173-
from mlflow.deployments import get_deploy_client
174175

175-
# Create the deployment configuration.
176176
deploy_config = {"computeType": "aci"}
177+
178+
deployment_config_path = "deployment_config.json"
179+
with open(deployment_config_path, "w") as outfile:
180+
outfile.write(json.dumps(deploy_config))
177181
```
178182

179183
4. Create a deployment client using the Azure Machine Learning Tracking URI.
180184

181185
```python
186+
from mlflow.deployments import get_deploy_client
187+
182188
# Set the tracking uri in the deployment client.
183189
client = get_deploy_client("<azureml-mlflow-tracking-url>")
184190
```
@@ -233,14 +239,52 @@ This example shows how you can deploy an MLflow model to an online endpoint usin
233239

234240
:::code language="azurecli" source="~/azureml-examples-main/cli/deploy-managed-online-endpoint-mlflow.sh" ID="create_endpoint":::
235241

236-
1. Create a YAML configuration file for the deployment. The following example configures a deployment of the `sklearn-diabetes` model to the endpoint created in the previous step:
237-
238-
> [!IMPORTANT]
239-
> For MLflow no-code-deployment (NCD) to work, setting **`type`** to **`mlflow_model`** is required, `type: mlflow_model​`. For more information, see [CLI (v2) model YAML schema](reference-yaml-model.md).
242+
1. Create a YAML configuration file for the deployment.
243+
244+
# [From a training job](#tab/fromjob)
245+
246+
The following example configures a deployment `sklearn-diabetes` to the endpoint created in the previous step. The model is registered from a job previously run:
247+
248+
a. Get the job name of the training job. In this example we are assuming the job you want is the last one submitted to the platform.
249+
250+
```bash
251+
JOB_NAME=$(az ml job list --query "[0].name" | tr -d '"')
252+
```
253+
254+
b. Register the model in the registry.
255+
256+
```bash
257+
az ml model create --name "mir-sample-sklearn-mlflow-model" \
258+
--type "mlflow_model" \
259+
--path "azureml://jobs/$JOB_NAME/outputs/artifacts/model"
260+
```
261+
262+
c. Create the deployment `YAML` file:
263+
264+
__sklearn-deployment.yaml__
265+
266+
```yaml
267+
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineDeployment.schema.json
268+
name: sklearn-deployment
269+
endpoint_name: my-endpoint
270+
model: azureml:mir-sample-sklearn-mlflow-model@latest
271+
instance_type: Standard_DS2_v2
272+
instance_count: 1
273+
```
274+
275+
> [!IMPORTANT]
276+
> For MLflow no-code-deployment (NCD) to work, setting **`type`** to **`mlflow_model`** is required, `type: mlflow_model​`. For more information, see [CLI (v2) model YAML schema](reference-yaml-model.md).
277+
278+
# [From a local model](#tab/fromlocal)
279+
280+
The following example configures a deployment `sklearn-diabetes` to the endpoint created in the previous step using the local MLflow model:
240281

241282
__sklearn-deployment.yaml__
242283

243284
:::code language="yaml" source="~/azureml-examples-main/cli/endpoints/online/mlflow/sklearn-deployment.yaml":::
285+
286+
> [!IMPORTANT]
287+
> For MLflow no-code-deployment (NCD) to work, setting **`type`** to **`mlflow_model`** is required, `type: mlflow_model​`. For more information, see [CLI (v2) model YAML schema](reference-yaml-model.md).
244288

245289
1. To create the deployment using the YAML configuration, use the following command:
246290

@@ -251,7 +295,7 @@ This example shows how you can deploy an MLflow model to an online endpoint usin
251295
You can use [Azure Machine Learning studio](https://ml.azure.com) to deploy models to Managed Online Endpoints.
252296

253297
> [!IMPORTANT]
254-
> Although deploying to ACI or AKS with [Azure Machine Learning studio](https://ml.azure.com) is possible. no-code deployment feature is not available for these compute targets. We recommend the use of [managed online endpoints](concept-endpoints.md) as it provides a superior set of features.
298+
> Although deploying to ACI or AKS with [Azure Machine Learning studio](https://ml.azure.com) is possible, no-code deployment feature is not available for these compute targets. We recommend the use of [managed online endpoints](concept-endpoints.md) as it provides a superior set of features.
255299

256300
1. Ensure your model is registered in the Azure Machine Learning registry. Deployment of unregistered models is not supported in Azure Machine Learning. You can register models from files in the local file system or from the output of a job:
257301

0 commit comments

Comments
 (0)