Skip to content

Commit c95fc9f

Browse files
Merge pull request #232488 from fkriti/patch-1
Update how-to-share-models-pipelines-across-workspaces-with-registrie…
2 parents 633b77e + d70b55c commit c95fc9f

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

articles/machine-learning/how-to-share-models-pipelines-across-workspaces-with-registries.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,9 @@ ml_client_registry.models.create_or_update(mlflow_model)
484484
485485
---
486486
487-
### Copy a model from workspace to registry
487+
### Share a model from workspace to registry
488488
489-
In this workflow, you'll first create the model in the workspace and then copy it to the registry. This workflow is useful when you want to test the model in the workspace before sharing it. For example, deploy it to endpoints, try out inference with some test data and then copy the model to a registry if everything looks good. This workflow may also be useful when you're developing a series of models using different techniques, frameworks or parameters and want to promote just one of them to the registry as a production candidate.
489+
In this workflow, you'll first create the model in the workspace and then share it to the registry. This workflow is useful when you want to test the model in the workspace before sharing it. For example, deploy it to endpoints, try out inference with some test data and then copy the model to a registry if everything looks good. This workflow may also be useful when you're developing a series of models using different techniques, frameworks or parameters and want to promote just one of them to the registry as a production candidate.
490490
491491
# [Azure CLI](#tab/cli)
492492
@@ -505,17 +505,17 @@ az ml model create --name nyc-taxi-model --version 1 --type mlflow_model --path
505505
506506
Note down the model name and version. You can validate if the model is registered in the workspace by browsing it in the Studio UI or using `az ml model show --name nyc-taxi-model --version $model_version` command.
507507
508-
Next, you'll now copy the model from the workspace to the registry. Note now the `--path` parameter is referring to the model with the workspace with the `azureml://subscriptions/<subscription-id-of-workspace>/resourceGroups/<resource-group-of-workspace>/workspaces/<workspace-name>/models/<model-name>/versions/<model-version>` syntax.
508+
Next, you'll now share the model from the workspace to the registry.
509509
510510
511511
```azurecli
512-
# copy model registered in workspace to registry
513-
az ml model create --registry-name <registry-name> --path azureml://subscriptions/<subscription-id-of-workspace>/resourceGroups/<resource-group-of-workspace>/workspaces/<workspace-name>/models/nyc-taxi-model/versions/1
512+
# share model registered in workspace to registry
513+
az ml model share --name nyc-taxi-model --version 1 --registry-name <registry-name> --share-with-name <new-name> --share-with-version <new-version>
514514
```
515515
516516
> [!TIP]
517517
> * Make sure to use the right model name and version if you changed it in the `az ml model create` command.
518-
> * The above command creates the model in the registry with the same name and version. You can provide a different name or version with the `--name` or `--version` parameters.
518+
> * The above command has two optional parameters "--share-with-name" and "--share-with-version". If these are not provided the new model will have the same name and version as the model that is being shared.
519519
Note down the `name` and `version` of the model from the output of the `az ml model create` command and use them with `az ml model show` commands as follows. You'll need the `name` and `version` in the next section when you deploy the model to an online endpoint for inference.
520520
521521
```azurecli
@@ -556,22 +556,15 @@ ml_client_workspace.models.create_or_update(mlflow_model)
556556
557557
Note down the model name and version. You can validate if the model is registered in the workspace by browsing it in the Studio UI or fetching it using `ml_client_workspace.model.get()` method.
558558
559-
Next, you'll now copy the model from the workspace to the registry. Construct the path to the model with the workspace using the `azureml://subscriptions/<subscription-id-of-workspace>/resourceGroups/<resource-group-of-workspace>/workspaces/<workspace-name>/models/<model-name>/versions/<model-version>` syntax.
560-
559+
Next, you'll now share the model from the workspace to the registry.
561560
562561
```python
563-
# fetch the model from workspace
564-
model_in_workspace = ml_client_workspace.models.get(name="nyc-taxi-model", version=version)
565-
print(model_in_workspace )
566-
# change the format such that the registry understands the model (when you print the model_ready_to_copy object, notice the asset id
567-
model_ready_to_copy = ml_client_workspace.models._prepare_to_copy(model_in_workspace)
568-
print(model_ready_to_copy)
569-
# copy the model from registry to workspace
570-
ml_client_registry.models.create_or_update(model_ready_to_copy)
562+
# share the model from registry to workspace
563+
ml_client.models.share(name="nyc-taxi-model", version=1, registry_name=<registry_name>, share_with_name=<new-name>, share_with_version=<new-version>)
571564
```
572565
573566
> [!TIP]
574-
> Make sure to use the right model name and version if you changed it in the `ml_client_workspace.model.create_or_update()` method used to create the model in workspace.
567+
> The above code has two optional parameters "share-with-name" and "share-with-version". If these are not provided the new model will have the same name and version as the model that is being shared.
575568
576569
Note down the `name` and `version` of the model from the output and use them with `ml_client_workspace.model.get()` commands as follows. You'll need the `name` and `version` in the next section when you deploy the model to an online endpoint for inference.
577570

0 commit comments

Comments
 (0)