Skip to content

Commit fe9632b

Browse files
committed
edits
1 parent c6bd6b2 commit fe9632b

File tree

1 file changed

+33
-35
lines changed

1 file changed

+33
-35
lines changed

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

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ You learn how to:
3333
- An Azure subscription with a free or paid version of Azure Machine Learning. If you don't have an Azure subscription, [create a free account](https://azure.microsoft.com/free/) before you begin.
3434
- An [Azure Machine Learning workspace](quickstart-create-resources.md#create-the-workspace).
3535

36-
To run the code samples in this article, or work with the Azure Machine Learning V2 CLI or Python Azure Machine Learning V2 SDK:
36+
To run the code samples in this article, or work with the Azure Machine Learning V2 CLI or Python Azure Machine Learning V2 SDK, you also need:
3737

3838
# [Azure CLI](#tab/cli)
3939

@@ -55,14 +55,14 @@ To run the code samples in this article, or work with the Azure Machine Learning
5555
---
5656

5757
> [!NOTE]
58-
> You can still use model assets from the v1 SDK or CLI. V2 provides full backward compatibility. All models registered with the v1 CLI or SDK are assigned the type `custom`.
58+
> V2 provides full backward compatibility. You can still use model assets from the v1 SDK or CLI. All models registered with the v1 CLI or SDK are assigned the type `custom`.
5959
6060
<a name="create-a-model-in-the-model-registry"></a>
6161
## Model registration
6262

6363
[Model registration](concept-model-management-and-deployment.md) lets you store and version your models in your workspace in the Azure cloud. The model registry helps you organize and keep track of your trained models. You can register models as assets in Azure Machine Learning by using the Azure CLI, the Python SDK, or the Machine Learning studio UI.
6464

65-
### Supported paths
65+
### Supported URI formats
6666

6767
To register a model, you need to specify a path that points to the data or job location. The following table shows the various data locations Azure Machine Learning supports, and the syntax for the `path` parameter:
6868

@@ -77,7 +77,7 @@ To register a model, you need to specify a path that points to the data or job l
7777

7878
### Supported modes
7979

80-
When you run a job with model inputs or outputs, you can specify which of the following *modes* to use. For example, you can specify whether the model should be read-only mounted or downloaded to the compute target.
80+
When you use models for inputs or outputs, you can specify one of the following *modes*. For example, you can specify whether the model should be read-only mounted or downloaded to the compute target.
8181

8282
- `ro_mount`: Mount the data to the compute target as read-only.
8383
- `rw_mount`: Read-write mount the data.
@@ -134,10 +134,10 @@ The following code snippets cover how to register a model as an asset in Azure M
134134

135135
The workspace is the top-level resource for Azure Machine Learning, providing a centralized place to work with all the artifacts you create when you use Azure Machine Learning. In this section, you connect to your Azure Machine Learning workspace to create the registered model.
136136

137-
In the following code snippets, replace `<subscription-id>`, `<resource-group>`, `<workspace-name>`, and `<location>` placeholders with the values for your environment.
138-
139137
# [Azure CLI](#tab/cli)
140138

139+
In the following commands, replace `<subscription-id>`, `<workspace-name>`, `<resource-group>`, and `<location>` placeholders with the values for your environment.
140+
141141
```azurecli
142142
az account set --subscription <subscription-id>
143143
az configure --defaults workspace=<workspace-name> group=<resource-group> location=<location>
@@ -154,7 +154,7 @@ az configure --defaults workspace=<workspace-name> group=<resource-group> locati
154154
from azure.identity import DefaultAzureCredential
155155
```
156156

157-
1. Configure workspace details and get a handle to the workspace:
157+
1. Configure workspace details and get a handle to the workspace. In the following code snippet, replace the `<subscription-id>`, `<resource-group>`, and `<workspace-name>` placeholders with the values for your environment.
158158

159159
```python
160160
subscription_id = "<subscription-id>"
@@ -168,27 +168,27 @@ az configure --defaults workspace=<workspace-name> group=<resource-group> locati
168168

169169
### Create the registered model
170170

171-
To create a registered model, use the following code, depending on whether the model you want to register is on your local computer, on an Azure Machine Learning datastore, or from an Azure Machine Learning job.
171+
To create the registered model, use the following instructions, depending on whether the model you want to register is on your local computer, on an Azure Machine Learning datastore, or from an Azure Machine Learning job.
172172

173173
#### Local file or folder
174174

175175
# [Azure CLI](#tab/cli)
176176

177-
1. Create a YAML file *\<yaml-filename>.yml*. In the file, provide a name for your registered model, a path to the local model file, and a description. For example:
177+
1. Create a YAML file *\<file-name>.yml*. In the file, provide a name for your registered model, a path to the local model file, and a description. For example:
178178

179179
:::code language="yaml" source="~/azureml-examples-main/cli/assets/model/local-file.yml":::
180180

181181
1. Run the following command, using the name of your YAML file:
182182

183183
```azurecli
184-
az ml model create -f <yaml-filename>.yml
184+
az ml model create -f <file-name>.yml
185185
```
186186

187187
For a complete example, see the [model YAML](https://github.com/Azure/azureml-examples/tree/main/cli/assets/model).
188188

189189
# [Python SDK](#tab/python)
190190

191-
For example:
191+
The following example shows creating a registered model from a local file.
192192

193193
[!Notebook-python[] (~/azureml-examples-main/sdk/python/assets/model/model.ipynb?name=file_model)]
194194

@@ -229,8 +229,6 @@ If your model data comes from a job output, you have two options. You can use th
229229

230230
Format: `runs:/<run-id>/<path-to-model-relative-to-the-root-of-the-artifact-location>`
231231

232-
Example: `runs:/<run-id>/<path>/`
233-
234232
# [Azure CLI](#tab/cli)
235233

236234
```azurecli
@@ -256,24 +254,25 @@ If your model data comes from a job output, you have two options. You can use th
256254
---
257255
- **azureml://jobs URI format**
258256

259-
The `azureml://jobs` reference URI option lets you register a model from artifacts in any of the job's outputs. This format aligns with the `azureml://datastores` reference URI format, and also supports referencing artifacts from named outputs other than the default artifact location.
257+
The `azureml://jobs` reference URI option lets you register a model from artifacts in any of the job's output paths. This format aligns with the `azureml://datastores` reference URI format, and also supports referencing artifacts from named outputs other than the default artifact location.
260258

261259
If you didn't directly register your model within the training script by using MLflow, you can use this option to establish a lineage between a registered model and the job it was trained from.
262260

263261
Format: `azureml://jobs/<job-name>/outputs/<output-name>/paths/<path-to-model>`
264262

265-
For example:
266263
- Default artifact location: `azureml://jobs/<run-id>/outputs/artifacts/paths/<path-to-model>/`. This location is equivalent to MLflow `runs:/<run-id>/<model>/`.
267264
- Named output folder: `azureml://jobs/<run-id>/outputs/<named-output-folder>`
268265
- Specific file within the named output folder: `azureml://jobs/<run-id>/outputs/<named-output-folder>/paths/<model-filename>`
269266
- Specific folder path within the named output folder: `azureml://jobs/<run-id>/outputs/<named-output-folder>/paths/<model-folder-name>/`
270267

268+
For example:
269+
271270
# [Azure CLI](#tab/cli)
272271

273272
Save a model from a named output folder:
274273

275274
```azurecli
276-
az ml model create --name <registered-model-name> --version 1 --path azureml://jobs/<run-id>/outputs/<model-folder-name>
275+
az ml model create --name run-model-example --version 1 --path azureml://jobs/<job_name>/outputs/artifacts/paths/model/
277276
```
278277

279278
For a complete example, see the [CLI reference](/cli/azure/ml/model).
@@ -350,7 +349,7 @@ print(model_example)
350349
Update mutable properties of a specific model:
351350

352351
> [!IMPORTANT]
353-
> For models, only `description` and `tags` can be updated. All other properties are immutable. If you need to change any of those properties, you should create a new version of the model.
352+
> For models, only `description` and `tags` can be updated. All other properties are immutable, and if you need to change them, you should create a new version of the model.
354353

355354
# [Azure CLI](#tab/cli)
356355

@@ -408,21 +407,21 @@ ml_client.models.archive(name="run-model-example", version="1")
408407

409408
The v2 Azure CLI and Python SDK also let you use models as inputs or outputs in training jobs.
410409

411-
### Use a model as input in a job
410+
### Use a model as input in a training job
412411

413412
# [Azure CLI](#tab/cli)
414413

415-
1. Create a job specification YAML file, *\<filename>.yml*. In the `inputs` section of the job, specify:
414+
1. Create a job specification YAML file, *\<file-name>.yml*. In the `inputs` section of the job, specify:
416415

417-
- The model `type`, which can be `mlflow_model`,`custom_model`, or `triton_model`.
418-
- The `path` where your data is located, which can be any of the paths listed in the comment of the following example.
416+
- The model `type`, which can be `mlflow_model`, `custom_model`, or `triton_model`.
417+
- The `path` where your model is located, which can be any of the paths listed in the comment of the following example.
419418

420419
:::code language="yaml" source="~/azureml-examples-main/cli/jobs/basics/hello-model-as-input.yml":::
421420

422421
1. Run the following command, substituting your YAML filename.
423422

424423
```azurecli
425-
az ml job create -f <filename>.yml
424+
az ml job create -f <file-name>.yml
426425
```
427426

428427
For a complete example, see the [model GitHub repo](https://github.com/Azure/azureml-examples/tree/main/cli/assets/model).
@@ -432,17 +431,17 @@ For a complete example, see the [model GitHub repo](https://github.com/Azure/azu
432431
The `Input` class allows you to define:
433432

434433
- The model asset type, which can be one of the following values:
435-
- `AssetTypes.mlflow_model`
436-
- `AssetTypes.custom_model`
434+
- `AssetTypes.MLFLOW_MODEL`
435+
- `AssetTypes.CUSTOM_MODEL`
437436

438437
- The `path` to your model data, which can be one of the following locations:
439-
- Local path: `<model-folder>/<model-filename>.pkl`
438+
- Local path: `<model-folder>/<model-filename>`
440439
- Azure Machine Learning datastore: `azureml://datastores/<datastore-name>/paths/<path_on_datastore>`
441440
- MLflow run: `runs:/<run-id>/<path-to-model-relative-to-the-root-of-the-artifact-location>`
442441
- Job: `azureml://jobs/<job-name>/outputs/<output-name>/paths/<path-to-model-relative-to-the-named-output-location>`
443442
- Model asset: `azureml:<my_model>:<version>`
444443

445-
Run the following code, substituting your model asset type and path for the `Input` placeholders.
444+
The following example inputs an MLflow model from a local folder.
446445

447446
```python
448447
from azure.ai.ml import command
@@ -452,7 +451,7 @@ from azure.ai.ml.constants import AssetTypes
452451
from azure.ai.ml import MLClient
453452

454453
my_job_inputs = {
455-
"input_model": Input(type=AssetTypes.<input-model-asset-type>, path="<input-model-path>")
454+
"input_model": Input(type=AssetTypes.MLFLOW_MODEL, path="mlflow-model")
456455
}
457456

458457
job = command(
@@ -476,7 +475,7 @@ Your job can write a model to your cloud-based storage by using *outputs*.
476475

477476
# [Azure CLI](#tab/cli)
478477

479-
1. Create a job specification YAML file *<file-name>.yml*. Populate the `outputs` section with the output model type and path.
478+
1. Create a job specification YAML file *\<file-name>.yml*. Populate the `outputs` section with the output model type and path.
480479

481480
:::code language="yaml" source="~/azureml-examples-main/cli/jobs/basics/hello-model-as-output.yml":::
482481

@@ -492,8 +491,8 @@ For a complete example, see the [model GitHub repo](https://github.com/Azure/azu
492491
The `Output` class allows you to define:
493492

494493
- The model asset type, which can be one of the following values:
495-
- `AssetTypes.mlflow_model`
496-
- `AssetTypes.custom_model`
494+
- `AssetTypes.MLFLOW_MODEL`
495+
- `AssetTypes.CUSTOM_MODEL`
497496

498497
- The `path` for your model data, which can be one of the following locations:
499498
- Local path: `mlflow-model/model.pkl`
@@ -502,7 +501,7 @@ The `Output` class allows you to define:
502501
- Job: `azureml://jobs/<job-name>/outputs/<output-name>/paths/<path-to-model-relative-to-the-named-output-location>`
503502
- Model asset: `azureml:<my_model>:<version>`
504503

505-
Run the following code, substituting your input and output asset types and paths for the placeholders.
504+
The following code creates an output that mounts your AzureML default datastore in read-write mode. The code simply loads the local MLflow model as input and exports the same model as an output of the job saved in the mounted datastore.
506505

507506
```python
508507
from azure.ai.ml import command
@@ -511,12 +510,11 @@ from azure.ai.ml import Input, Output
511510
from azure.ai.ml.constants import AssetTypes
512511

513512
my_job_inputs = {
514-
"input_model": Input(type=AssetTypes.<input-model-asset-type>, path="<input-model-path>"),
515-
"input_data": Input(type=AssetTypes.uri_file, path="<input-data-path>")
516-
}
513+
"input_model": Input(type=AssetTypes.MLFLOW_MODEL, path="mlflow-model"),
514+
"input_data": Input(type=AssetTypes.URI_FILE, path="./mlflow-model/input_example.json"),}
517515

518516
my_job_outputs = {
519-
"output_folder": Output(type=AssetTypes.<output-model-asset-type>)
517+
"output_folder": Output(type=AssetTypes.CUSTOM_MODEL)
520518
}
521519

522520
job = command(

0 commit comments

Comments
 (0)