Skip to content

Commit 84d31d9

Browse files
Merge pull request #219326 from santiagxf/santiagxf/azureml-batch-mlflow-fix
Update how-to-mlflow-batch.md
2 parents fc8f087 + c99fbe0 commit 84d31d9

File tree

1 file changed

+40
-16
lines changed

1 file changed

+40
-16
lines changed

articles/machine-learning/batch-inference/how-to-mlflow-batch.md

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Follow these steps to deploy an MLflow model to a batch endpoint for running bat
5858

5959
# [Azure CLI](#tab/cli)
6060

61-
```bash
61+
```azurecli
6262
az account set --subscription <subscription>
6363
az configure --defaults workspace=<workspace> group=<resource-group> location=<location>
6464
```
@@ -91,7 +91,7 @@ Follow these steps to deploy an MLflow model to a batch endpoint for running bat
9191

9292
# [Azure CLI](#tab/cli)
9393

94-
```bash
94+
```azurecli
9595
MODEL_NAME='heart-classifier'
9696
az ml model create --name $MODEL_NAME --type "mlflow_model" --path "heart-classifier-mlflow/model"
9797
```
@@ -126,7 +126,7 @@ Follow these steps to deploy an MLflow model to a batch endpoint for running bat
126126
127127
Create the compute using the following command:
128128
129-
```bash
129+
```azurecli
130130
az ml compute create -f cpu-cluster.yml
131131
```
132132

@@ -156,9 +156,9 @@ Follow these steps to deploy an MLflow model to a batch endpoint for running bat
156156
157157
Then, create the endpoint with the following command:
158158
159-
```bash
159+
```azurecli
160160
ENDPOINT_NAME='heart-classifier-batch'
161-
az ml batch-endpoint create -f endpoint.yml
161+
az ml batch-endpoint create -n $ENDPOINT_NAME -f endpoint.yml
162162
```
163163

164164
# [Python](#tab/sdk)
@@ -170,6 +170,11 @@ Follow these steps to deploy an MLflow model to a batch endpoint for running bat
170170
name="heart-classifier-batch",
171171
description="A heart condition classifier for batch inference",
172172
)
173+
```
174+
175+
Then, create the endpoint with the following command:
176+
177+
```python
173178
ml_client.batch_endpoints.begin_create_or_update(endpoint)
174179
```
175180

@@ -201,14 +206,14 @@ Follow these steps to deploy an MLflow model to a batch endpoint for running bat
201206
202207
Then, create the deployment with the following command:
203208
204-
```bash
209+
```azurecli
205210
DEPLOYMENT_NAME="classifier-xgboost-mlflow"
206-
az ml batch-deployment create -f endpoint.yml
211+
az ml batch-deployment create -n $DEPLOYMENT_NAME -f endpoint.yml
207212
```
208213

209214
# [Python](#tab/sdk)
210215

211-
To create a new deployment under the created endpoint, use the following script:
216+
To create a new deployment under the created endpoint, first define the deployment:
212217

213218
```python
214219
deployment = BatchDeployment(
@@ -225,6 +230,11 @@ Follow these steps to deploy an MLflow model to a batch endpoint for running bat
225230
retry_settings=BatchRetrySettings(max_retries=3, timeout=300),
226231
logging_level="info",
227232
)
233+
```
234+
235+
Then, create the deployment with the following command:
236+
237+
```python
228238
ml_client.batch_deployments.begin_create_or_update(deployment)
229239
```
230240
---
@@ -236,13 +246,14 @@ Follow these steps to deploy an MLflow model to a batch endpoint for running bat
236246

237247
# [Azure CLI](#tab/cli)
238248

239-
```bash
249+
```azurecli
240250
az ml batch-endpoint update --name $ENDPOINT_NAME --set defaults.deployment_name=$DEPLOYMENT_NAME
241251
```
242252

243253
# [Python](#tab/sdk)
244254

245255
```python
256+
endpoint = ml_client.batch_endpoints.get(endpoint.name)
246257
endpoint.defaults.deployment_name = deployment.name
247258
ml_client.batch_endpoints.begin_create_or_update(endpoint)
248259
```
@@ -257,7 +268,7 @@ For testing our endpoint, we are going to use a sample of unlabeled data located
257268

258269
# [Azure CLI](#tab/cli)
259270

260-
Create a data asset definition in `YAML`:
271+
a. Create a data asset definition in `YAML`:
261272

262273
__heart-dataset-unlabeled.yml__
263274
```yaml
@@ -268,14 +279,16 @@ For testing our endpoint, we are going to use a sample of unlabeled data located
268279
path: heart-classifier-mlflow/data
269280
```
270281
271-
Then, create the data asset:
282+
b. Create the data asset:
272283
273-
```bash
284+
```azurecli
274285
az ml data create -f heart-dataset-unlabeled.yml
275286
```
276287

277288
# [Python](#tab/sdk)
278289

290+
a. Create a data asset definition:
291+
279292
```python
280293
data_path = "heart-classifier-mlflow/data"
281294
dataset_name = "heart-dataset-unlabeled"
@@ -286,14 +299,25 @@ For testing our endpoint, we are going to use a sample of unlabeled data located
286299
description="An unlabeled dataset for heart classification",
287300
name=dataset_name,
288301
)
302+
```
303+
304+
b. Create the data asset:
305+
306+
```python
289307
ml_client.data.create_or_update(heart_dataset_unlabeled)
290308
```
291309

310+
c. Refresh the object to reflect the changes:
311+
312+
```python
313+
heart_dataset_unlabeled = ml_client.data.get(name=dataset_name)
314+
```
315+
292316
2. Now that the data is uploaded and ready to be used, let's invoke the endpoint:
293317

294318
# [Azure CLI](#tab/cli)
295319

296-
```bash
320+
```azurecli
297321
JOB_NAME = $(az ml batch-endpoint invoke --name $ENDPOINT_NAME --input azureml:heart-dataset-unlabeled@latest | jq -r '.name')
298322
```
299323

@@ -318,7 +342,7 @@ For testing our endpoint, we are going to use a sample of unlabeled data located
318342

319343
# [Azure CLI](#tab/cli)
320344

321-
```bash
345+
```azurecli
322346
az ml job show --name $JOB_NAME
323347
```
324348

@@ -346,7 +370,7 @@ You can download the results of the job by using the job name:
346370

347371
To download the predictions, use the following command:
348372

349-
```bash
373+
```azurecli
350374
az ml job download --name $JOB_NAME --output-name score --download-path ./
351375
```
352376

@@ -535,7 +559,7 @@ Use the following steps to deploy an MLflow model with a custom scoring script.
535559
536560
Then, create the deployment with the following command:
537561
538-
```bash
562+
```azurecli
539563
az ml batch-deployment create -f deployment.yml
540564
```
541565

0 commit comments

Comments
 (0)