Skip to content

Commit 2a933c8

Browse files
committed
fix
1 parent 6c96c9d commit 2a933c8

File tree

2 files changed

+90
-12
lines changed

2 files changed

+90
-12
lines changed

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

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ The workspace is the top-level resource for Azure Machine Learning, providing a
7979
```python
8080
import json
8181
import mlflow
82+
import urllib.request
8283
from mlflow.deployments import get_deploy_client
8384
```
8485

@@ -339,6 +340,74 @@ So far, the endpoint is empty. There are no deployments on it. Let's create the
339340
)
340341
```
341342
343+
1. Create a sample input to test the deployment
344+
345+
# [Azure CLI](#tab/cli)
346+
347+
__sample.yml__
348+
349+
```yml
350+
{
351+
"input_data": {
352+
"columns": [
353+
"age",
354+
"sex",
355+
"cp",
356+
"trestbps",
357+
"chol",
358+
"fbs",
359+
"restecg",
360+
"thalach",
361+
"exang",
362+
"oldpeak",
363+
"slope",
364+
"ca",
365+
"thal"
366+
],
367+
"data": [
368+
[ 48, 0, 3, 130, 275, 0, 0, 139, 0, 0.2, 1, 0, "normal" ]
369+
]
370+
}
371+
}
372+
```
373+
374+
# [Python (Azure ML SDK)](#tab/sdk)
375+
376+
The following code samples 5 observations from the training dataset, removes the `target` column (as the model will predict it), and creates a request in the file `sample.json` that can be used with the model deployment.
377+
378+
```python
379+
samples = (
380+
pd.read_csv("data/heart.csv")
381+
.sample(n=5)
382+
.drop(columns=["target"])
383+
.reset_index(drop=True)
384+
)
385+
386+
with open("sample.json", "w") as f:
387+
f.write(
388+
json.dumps(
389+
{"input_data": json.loads(samples.to_json(orient="split", index=False))}
390+
)
391+
)
392+
```
393+
394+
# [Python (MLflow SDK)](#tab/mlflow)
395+
396+
The following code samples 5 observations from the training dataset, removes the `target` column (as the model will predict it), and creates a request.
397+
398+
```python
399+
samples = (
400+
pd.read_csv("data/heart.csv")
401+
.sample(n=5)
402+
.drop(columns=["target"])
403+
.reset_index(drop=True)
404+
)
405+
406+
sample_request = json.dumps(
407+
{"input_data": json.loads(samples.to_json(orient="split", index=False))}
408+
)
409+
```
410+
342411
1. Test the deployment
343412
344413
# [Azure CLI](#tab/cli)
@@ -357,17 +426,31 @@ So far, the endpoint is empty. There are no deployments on it. Let's create the
357426
```
358427
359428
# [Python (MLflow SDK)](#tab/mlflow)
429+
430+
Get the scoring URI:
431+
432+
```python
433+
scoring_uri = deployment_client.get_endpoint(endpoint=endpoint_name)["properties"]["scoringUri"]
434+
```
360435
361-
Let's create the authentication header:
436+
Let's create the headers:
362437
363438
```python
364-
authentication_header = f"'Authorization: Bearer {endpoint_secret_key}'"
439+
headers = {
440+
'Content-Type':'application/json',
441+
'Authorization':('Bearer '+ endpoint_secret_key),
442+
'azureml-model-deployment': 'default'
443+
}
365444
```
366445
367446
Call the endpoint and its default deployment:
368447
369448
```python
370-
449+
req = urllib.request.Request(scoring_uri, sample_request, headers)
450+
response = urllib.request.urlopen(req)
451+
452+
result = response.read()
453+
print(result)
371454
```
372455
373456
### Create a green deployment under the endpoint

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Each workflow has different capabilities, particularly around which type of comp
5353
| Scenario | MLflow SDK | Azure ML CLI/SDK | Azure ML studio |
5454
| :- | :-: | :-: | :-: |
5555
| Deploy to managed online endpoints | [See example](how-to-deploy-mlflow-models-online-progressive.md)<sup>1</sup> | [See example](how-to-deploy-mlflow-models-online-endpoints.md)<sup>1</sup> | [See example](how-to-deploy-mlflow-models-online-endpoints.md?tabs=studio)<sup>1</sup> |
56-
| Deploy to managed online endpoints (with a scoring script) | | [See example](how-to-deploy-mlflow-models-online-endpoints.md#customizing-mlflow-model-deployments) | Not supported |
56+
| Deploy to managed online endpoints (with a scoring script) | | [See example](how-to-deploy-mlflow-models-online-endpoints.md#customizing-mlflow-model-deployments) | |
5757
| Deploy to batch endpoints | | [See example](how-to-mlflow-batch.md) | [See example](how-to-mlflow-batch.md?tab=studio) |
5858
| Deploy to batch endpoints (with a scoring script) | | [See example](how-to-mlflow-batch.md#customizing-mlflow-models-deployments-with-a-scoring-script) | |
5959
| Deploy to web services (ACI/AKS) | Legacy support<sup>2</sup> | <sup>2</sup> | <sup>2</sup> |
@@ -224,11 +224,6 @@ If you want to customize how inference is executed for MLflow models (or opt-out
224224

225225
To learn more, review these articles:
226226

227-
- [Deploy models with REST](how-to-deploy-with-rest.md)
228-
- [Create and use online endpoints in the studio](how-to-use-managed-online-endpoint-studio.md)
229-
- [Safe rollout for online endpoints](how-to-safely-rollout-online-endpoints.md)
230-
- [How to autoscale managed online endpoints](how-to-autoscale-endpoints.md)
231-
- [Use batch endpoints for batch scoring](batch-inference/how-to-use-batch-endpoint.md)
232-
- [View costs for an Azure Machine Learning managed online endpoint](how-to-view-online-endpoints-costs.md)
233-
- [Access Azure resources with an online endpoint and managed identity](how-to-access-resources-from-endpoints-managed-identities.md)
234-
- [Troubleshoot online endpoint deployment](how-to-troubleshoot-managed-online-endpoints.md)
227+
- [Deploy MLflow models to online endpoints](how-to-deploy-mlflow-models-online-endpoints.md)
228+
- [Progressive rollout of MLflow models](how-to-deploy-mlflow-models-online-progressive.md)
229+
- [Deploy MLflow models to Batch Endpoints](how-to-mlflow-batch.md)

0 commit comments

Comments
 (0)