Skip to content

Commit 5d0586d

Browse files
authored
Update how-to-deploy-mlflow-models.md
1 parent c097003 commit 5d0586d

File tree

1 file changed

+42
-113
lines changed

1 file changed

+42
-113
lines changed

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

Lines changed: 42 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ms.devlang: azurecli
2121
> * [v1](./v1/how-to-deploy-mlflow-models.md)
2222
> * [v2 (current version)](how-to-deploy-mlflow-models.md)
2323
24-
In this article, learn how to deploy your [MLflow](https://www.mlflow.org) model to Azure ML for both real-time and batch inference. Azure Machine Learning supports no-code deployment of models created and logged with MLflow. This means that you don't have to provide a scoring script or an environment.
24+
In this article, learn how to deploy your [MLflow](https://www.mlflow.org) model to Azure ML for both real-time and batch inference. Azure ML supports no-code deployment of models created and logged with MLflow. This means that you don't have to provide a scoring script or an environment.
2525

2626
For no-code-deployment, Azure Machine Learning
2727

@@ -34,7 +34,7 @@ For no-code-deployment, Azure Machine Learning
3434
> [!IMPORTANT]
3535
> If you are used to deploying models using scoring scripts and custom environments and you are looking to know how to achieve the same functionality using MLflow models, we recommend reading [Using MLflow models for no-code deployment](how-to-log-mlflow-models.md).
3636
37-
> [!WARNING]
37+
> [!NOTE]
3838
> For information about inputs format and limitation in 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).
3939
4040
## Deployment tools
@@ -92,7 +92,7 @@ The MLflow plugin [azureml-mlflow](https://pypi.org/project/azureml-mlflow/) can
9292

9393
2. Deployments can be generated using both the Python SDK for MLflow or MLflow CLI. In both cases, a JSON configuration file can be indicated with the details of the deployment you want to achieve. If not indicated, then a default deployment is done using Azure Container Instances (ACI) and a minimal configuration.
9494

95-
# [Online endpoints](#tab/mir)
95+
# [Managed endpoints](#tab/mir)
9696

9797
```json
9898
{
@@ -137,7 +137,7 @@ The MLflow plugin [azureml-mlflow](https://pypi.org/project/azureml-mlflow/) can
137137
138138
3. Save the deployment configuration to a file:
139139

140-
# [Online endpoints](#tab/mir)
140+
# [Managed endpoints](#tab/mir)
141141

142142
```python
143143
import json
@@ -226,32 +226,20 @@ This example shows how you can deploy an MLflow model to an online endpoint usin
226226
> For MLflow no-code-deployment, **[testing via local endpoints](how-to-deploy-managed-online-endpoints.md#deploy-and-debug-locally-by-using-local-endpoints)** is currently not supported.
227227
228228
1. Create a YAML configuration file for your endpoint. The following example configures the name and authentication mode of the endpoint:
229-
230-
# [Online endpoints](#tab/mir)
231-
232-
__create-endpoint.yaml__
233229

234-
:::code language="yaml" source="~/azureml-examples-main/cli/endpoints/online/mlflow/create-endpoint.yaml":::
235-
236-
# [Batch endpoints](#tab/batch)
237-
238-
__create-endpoint.yaml__
230+
__create-endpoint.yaml__
239231

240-
:::code language="yaml" source="~/azureml-examples-main/cli/endpoints/batch/batch-endpoint.yml":::
241-
242-
---
232+
:::code language="yaml" source="~/azureml-examples-main/cli/endpoints/online/mlflow/create-endpoint.yaml":::
243233

244234
1. To create a new endpoint using the YAML configuration, use the following command:
245235

246-
```bash
247-
az ml batch-endpoint create --name $ENDPOINT_NAME -f endpoints/batch/batch-endpoint.yaml
248-
```
236+
:::code language="azurecli" source="~/azureml-examples-main/cli/deploy-managed-online-endpoint-mlflow.sh" ID="create_endpoint":::
249237

250-
1. Register the model you want to deploy.
238+
1. Create a YAML configuration file for the deployment.
251239

252240
# [From a training job](#tab/fromjob)
253241

254-
The following example register a model `sample-sklearn-mlflow-model` from a job previously run:
242+
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:
255243

256244
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.
257245

@@ -262,87 +250,48 @@ This example shows how you can deploy an MLflow model to an online endpoint usin
262250
b. Register the model in the registry.
263251

264252
```bash
265-
az ml model create --name "sample-sklearn-mlflow-model" \
253+
az ml model create --name "mir-sample-sklearn-mlflow-model" \
266254
--type "mlflow_model" \
267255
--path "azureml://jobs/$JOB_NAME/outputs/artifacts/model"
268256
```
269257

270-
> [!IMPORTANT]
271-
> 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).
272-
273-
# [From a local model](#tab/fromlocal)
274-
275-
The following example register a model `sample-sklearn-mlflow-model` using a local MLflow model:
276-
277-
```bash
278-
az ml model create --name "sample-sklearn-mlflow-model" \
279-
--type "mlflow_model" \
280-
--path "sklearn-diabetes/model"
281-
```
282-
283-
> [!IMPORTANT]
284-
> 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).
285-
286-
1. Create the deployment `YAML` file:
287-
288-
# [Online endpoints](#tab/mir)
258+
c. Create the deployment `YAML` file:
289259

290260
__sklearn-deployment.yaml__
291261

292262
```yaml
293263
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineDeployment.schema.json
294264
name: sklearn-deployment
295265
endpoint_name: my-endpoint
296-
model: azureml:sample-sklearn-mlflow-model@latest
266+
model: azureml:mir-sample-sklearn-mlflow-model@latest
297267
instance_type: Standard_DS2_v2
298268
instance_count: 1
299269
```
300270
301-
# [Batch endpoints](#tab/batch)
271+
> [!IMPORTANT]
272+
> 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).
273+
274+
# [From a local model](#tab/fromlocal)
302275

303-
__mlflow-deployment.yaml__
276+
The following example configures a deployment `sklearn-diabetes` to the endpoint created in the previous step using the local MLflow model:
304277

305-
```yaml
306-
$schema: https://azuremlschemas.azureedge.net/latest/batchDeployment.schema.json
307-
name: mlflowdp
308-
endpoint_name: mybatchedp
309-
model: azureml:sample-sklearn-mlflow-model@latest
310-
compute: azureml:batch-cluster
311-
```
278+
__sklearn-deployment.yaml__
312279

313-
1. To create the deployment using the YAML configuration, use the following command:
280+
:::code language="yaml" source="~/azureml-examples-main/cli/endpoints/online/mlflow/sklearn-deployment.yaml":::
281+
282+
> [!IMPORTANT]
283+
> 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).
314284

315-
# [Online endpoints](#tab/mir)
316-
317-
:::code language="azurecli" source="~/azureml-examples-main/cli/deploy-managed-online-endpoint-mlflow.sh" ID="create_sklearn_deployment":::
318-
319-
To see how to submit request to the resulting endpoint see [Creating requests](#creating-requests) section.
320-
321-
# [Batch endpoints](#tab/batch)
322-
323-
a. Azure Machine Learning Batch Endpoints runs on Compute Clusters. You will need to have a compute cluster created where the batch endpoints will get deployed. The cluster is only utilized when jobs are submitted, so you can utilize the same cluster for multiple deployments if needed. The following sample creates a cluster called `batch-cluster` with a minimum of zero nodes and a maximum of 3 nodes of `Standard_DS2_v2`. If you already have a cluster, you can skip this step.
324-
325-
```bash
326-
az ml compute create -n batch-cluster --type amlcompute --min-instances 0 --max-instances 2 --size Standard_DS2_v2
327-
```
328-
329-
b. Create the deployment on the created cluster:
330-
331-
__mlflow-deployment.yaml__
285+
1. To create the deployment using the YAML configuration, use the following command:
332286

333-
```bash
334-
az ml batch-deployment create --name sklearn-deployment \
335-
--endpoint $ENDPOINT_NAME \
336-
-f endpoints/batch/mlflow-deploymen.yaml
337-
```
287+
:::code language="azurecli" source="~/azureml-examples-main/cli/deploy-managed-online-endpoint-mlflow.sh" ID="create_sklearn_deployment":::
338288

339-
c. To see how to submit a job to the resulting endpoint see [Submitting jobs to batch endpoints](#creating-requests) section.
340-
341289
## Deploy using Azure Machine Learning studio
342290

343-
You can use [Azure Machine Learning studio](https://ml.azure.com) to deploy models to both Online and Batch Endpoints. 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.
291+
You can use [Azure Machine Learning studio](https://ml.azure.com) to deploy models to Managed Online Endpoints.
344292

345-
### Steps
293+
> [!IMPORTANT]
294+
> 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.
346295

347296
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:
348297

@@ -359,53 +308,31 @@ You can use [Azure Machine Learning studio](https://ml.azure.com) to deploy mode
359308
:::image type="content" source="./media/how-to-manage-models/register-model-as-asset.png" alt-text="Screenshot of the UI to register a model." lightbox="./media/how-to-manage-models/register-model-as-asset.png":::
360309

361310
2. From [studio](https://ml.azure.com), select your workspace and then use either the __endpoints__ or __models__ page to create the endpoint deployment:
362-
363-
# [Online endpoints](#tab/mir)
364311

365-
1. From the __Endpoints__ page, y the __Batch endpoints__ section, select **+Create**.
312+
# [Endpoints page](#tab/endpoint)
366313

367-
:::image type="content" source="media/how-to-deploy-mlflow-models-online-endpoints/create-from-endpoints.png" lightbox="media/how-to-deploy-mlflow-models-online-endpoints/create-from-endpoints.png" alt-text="Screenshot showing create option on the Endpoints UI page.":::
314+
1. From the __Endpoints__ page, Select **+Create**.
368315

369-
1. Provide a name for the endpoint, and then select __Next__.
370-
1. When selecting a model, select the MLflow model registered previously. Select __Next__ to continue.
316+
:::image type="content" source="media/how-to-deploy-mlflow-models-online-endpoints/create-from-endpoints.png" lightbox="media/how-to-deploy-mlflow-models-online-endpoints/create-from-endpoints.png" alt-text="Screenshot showing create option on the Endpoints UI page.":::
371317

372-
1. When you select a model registered in MLflow format, in the Environment step of the wizard, you don't need a scoring script or an environment.
318+
1. Provide a name and authentication type for the endpoint, and then select __Next__.
319+
1. When selecting a model, select the MLflow model registered previously. Select __Next__ to continue.
373320

374-
:::image type="content" source="media/how-to-deploy-mlflow-models-online-endpoints/ncd-wizard.png" lightbox="media/how-to-deploy-mlflow-models-online-endpoints/ncd-wizard.png" alt-text="Screenshot showing no code and environment needed for MLflow models.":::
321+
1. When you select a model registered in MLflow format, in the Environment step of the wizard, you don't need a scoring script or an environment.
375322

376-
1. Complete the wizard to deploy the model to the endpoint.
323+
:::image type="content" source="media/how-to-deploy-mlflow-models-online-endpoints/ncd-wizard.png" lightbox="media/how-to-deploy-mlflow-models-online-endpoints/ncd-wizard.png" alt-text="Screenshot showing no code and environment needed for MLflow models.":::
377324

378-
:::image type="content" source="media/how-to-deploy-mlflow-models-online-endpoints/review-screen-ncd.png" lightbox="media/how-to-deploy-mlflow-models-online-endpoints/review-screen-ncd.png" alt-text="Screenshot showing NCD review screen.":::
379-
380-
# [Batch endpoints](#tab/batch)
381-
382-
1. From the __Endpoints__ page, Select **+Create**.
325+
1. Complete the wizard to deploy the model to the endpoint.
383326

384-
:::image type="content" source="media/how-to-deploy-mlflow-models/create-batch-endpoint.png" lightbox="media/how-to-deploy-mlflow-models/create-from-endpoints.png" alt-text="Screenshot showing create option on the Endpoints UI page.":::
327+
:::image type="content" source="media/how-to-deploy-mlflow-models-online-endpoints/review-screen-ncd.png" lightbox="media/how-to-deploy-mlflow-models-online-endpoints/review-screen-ncd.png" alt-text="Screenshot showing NCD review screen.":::
385328

386-
1. Provide a name and authentication type for the endpoint, and then select __Next__.
387-
1. When selecting a model, select the MLflow model registered previously. Select __Next__ to continue.
388-
1. When you select a model registered in MLflow format, in the Environment step of the wizard, you don't need a scoring script or an environment.
329+
# [Models page](#tab/models)
389330

390-
:::image type="content" source="media/how-to-deploy-mlflow-models-online-endpoints/ncd-wizard.png" lightbox="media/how-to-deploy-mlflow-models-online-endpoints/ncd-wizard.png" alt-text="Screenshot showing no code and environment needed for MLflow models.":::
391-
392-
1. Create your default deployment in your endpoint. For that provide the following values and then clic on __Next__:
393-
394-
* __Deployment name:__ Name of the default deployment you want.
395-
* __Output action:__ Use __Append__ to output the predictions generated by the model in your output.
396-
* __Output file name:__ The output file name with all the predictions your model produced.
397-
* __Mini batch size:__ The amount of samples each worker will recieve in a single call for scoring.
398-
* __Scoring timeout:__ The number of seconds each worker has on each call to produce the predictions corresponding to 1 minibatch. Indicate higher valuer for more expensive models.
399-
* __Max retires:__ The number of times a worker will retry to score a given mini batch processing has failed.
400-
* __Max concurrency per instance:__ The number of workers each instance will have available. If you cluster has 2 nodes and you indicate __Max concurrency per instance__ = 2, then 4 workers will be available to you. Each of them will process __Mini batch size__ samples at a time.
331+
1. Select the MLflow model, and then select __Deploy__. When prompted, select __Deploy to real-time endpoint__.
401332

402-
1. For environment, you don't have to specify anything for MLflow models.
333+
:::image type="content" source="media/how-to-deploy-mlflow-models-online-endpoints/deploy-from-models-ui.png" lightbox="media/how-to-deploy-mlflow-models-online-endpoints/deploy-from-models-ui.png" alt-text="Screenshot showing how to deploy model from Models UI.":::
403334

404-
1. Configure the cluster the jobs will run on and the number of instances it will be utilized from it. Azure Machine Learning Batch Endpoints runs on Compute Clusters. You will need to have a compute cluster created where the batch endpoints will get deployed. The cluster is only utilized when jobs are submitted, so you can utilize the same cluster for multiple deployments if needed.
405-
406-
:::image type="content" source="media/how-to-deploy-mlflow-models/create-batch-endpoint-2.png" lightbox="media/how-to-deploy-mlflow-models/create-batch-endpoint-2.png" alt-text="Screenshot showing cluster configuration.":::
407-
408-
1. Complete the wizard to deploy the model to the endpoint.
335+
1. Complete the wizard to deploy the model to the endpoint.
409336

410337

411338
## Considerations when deploying to real time inference
@@ -476,6 +403,8 @@ Your inputs should be submitted inside a JSON payload containing a dictionary wi
476403

477404
### Limitations
478405

406+
The following limitations apply to real time inference deployments:
407+
479408
> [!NOTE]
480409
> Consider the following limitations when deploying MLflow models to Azure Machine Learning:
481410
> - Spark flavor is not supported at the moment for deployment.

0 commit comments

Comments
 (0)