From af52a2344dd41e68b810af8adecac40301269b51 Mon Sep 17 00:00:00 2001 From: kshitij-microsoft Date: Tue, 9 Dec 2025 02:12:43 +0530 Subject: [PATCH 1/3] model integration with DT --- .../azext_mlv2/manual/_params/_model_params.py | 5 +++++ .../azext_mlv2/manual/custom/model.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py b/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py index 95f75c708f6..0d2d4b2e351 100644 --- a/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py +++ b/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py @@ -61,6 +61,11 @@ def load_model_params(self): "The default type is custom_model.", ) add_description_param(c, help_message="Description of the model.") + c.argument( + "default_deployment_template", + options_list=["--default-deployment-template"], + help="Default deployment template for the model.", + ) with self.argument_context("ml model show") as c: add_common_params(c) diff --git a/src/machinelearningservices/azext_mlv2/manual/custom/model.py b/src/machinelearningservices/azext_mlv2/manual/custom/model.py index 1294726dcea..ad4cb0f1b47 100644 --- a/src/machinelearningservices/azext_mlv2/manual/custom/model.py +++ b/src/machinelearningservices/azext_mlv2/manual/custom/model.py @@ -35,6 +35,7 @@ def ml_model_create( registry_name=None, params_override=None, datastore=None, + default_deployment_template=None, no_wait=None, # pylint: disable=unused-argument ): ml_client, debug = get_ml_client( @@ -81,6 +82,7 @@ def ml_model_create( stage=stage, type=type, datastore=datastore, + default_deployment_template=default_deployment_template, ) if model and model.type: model_info.model_type = model.type From 62ec524aaa702ebe710f988dece1a84158890d82 Mon Sep 17 00:00:00 2001 From: kshitij-microsoft Date: Tue, 9 Dec 2025 19:46:29 +0530 Subject: [PATCH 2/3] model integration with DT - revised --- src/machinelearningservices/CHANGELOG.rst | 6 ++++++ .../azext_mlv2/manual/_help/_model_help.py | 2 ++ .../azext_mlv2/manual/_params/_model_params.py | 3 ++- .../azext_mlv2/manual/custom/model.py | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/machinelearningservices/CHANGELOG.rst b/src/machinelearningservices/CHANGELOG.rst index 567af97f4b9..fb0f5d767a1 100644 --- a/src/machinelearningservices/CHANGELOG.rst +++ b/src/machinelearningservices/CHANGELOG.rst @@ -1,3 +1,9 @@ +## 2025-12-19 + +### Azure Machine Learning CLI (v2) v 2.41.0 +- `az ml model create` + - Add support for `default_deployment_template` parameter to associate a deployment template with a model. + ## 2025-11-04 ### Azure Machine Learning CLI (v2) v 2.40.0 diff --git a/src/machinelearningservices/azext_mlv2/manual/_help/_model_help.py b/src/machinelearningservices/azext_mlv2/manual/_help/_model_help.py index 71297db0eba..b9606c249d2 100644 --- a/src/machinelearningservices/azext_mlv2/manual/_help/_model_help.py +++ b/src/machinelearningservices/azext_mlv2/manual/_help/_model_help.py @@ -40,6 +40,8 @@ def get_model_help(): text: az ml model create --name my-model --version 1 --path azureml://jobs/c42d2507-4953-4a7c-a4c1-2b5bfe0ac64e/outputs/artifacts/paths/model/ --resource-group my-resource-group --workspace-name my-workspace - name: Create a model from a datastore 'azureml://datastores//paths/' using command options text: az ml model create --name my-model --version 1 --path azureml://datastores/myblobstore/paths/models/cifar10/cifar.pt --resource-group my-resource-group --workspace-name my-workspace + - name: Create a model from a YAML file and override the default deployment template + text: az ml model create --registry-name my-registry --resource-group my-resource-group --file model.yaml --set default_deployment_template.asset_id="azureml://registries/my-registry/deploymenttemplates/my-template/versions/1" --version 3 """ helps[ "ml model show" diff --git a/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py b/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py index 0d2d4b2e351..36003d5cb5c 100644 --- a/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py +++ b/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py @@ -64,7 +64,8 @@ def load_model_params(self): c.argument( "default_deployment_template", options_list=["--default-deployment-template"], - help="Default deployment template for the model.", + help="Default deployment template for the model. Can be overridden using --set with the format: " + "--set default_deployment_template.asset_id=\"azureml://registries//deploymenttemplates//versions/\"", ) with self.argument_context("ml model show") as c: diff --git a/src/machinelearningservices/azext_mlv2/manual/custom/model.py b/src/machinelearningservices/azext_mlv2/manual/custom/model.py index ad4cb0f1b47..d6f58a214b9 100644 --- a/src/machinelearningservices/azext_mlv2/manual/custom/model.py +++ b/src/machinelearningservices/azext_mlv2/manual/custom/model.py @@ -62,6 +62,8 @@ def ml_model_create( params_override.append({"stage": stage}) if datastore: params_override.append({"datastore": datastore}) + if default_deployment_template: + params_override.append({"default_deployment_template": default_deployment_template}) model_info = ModelInfo() try: From 35556b3460cbe2c14c30d93024901edb918011e2 Mon Sep 17 00:00:00 2001 From: kshitij-microsoft Date: Thu, 11 Dec 2025 15:19:28 +0530 Subject: [PATCH 3/3] style and lint fixes --- .../azext_mlv2/manual/_help/_model_help.py | 4 ++-- .../azext_mlv2/manual/_params/_deployment_template_params.py | 4 +++- .../azext_mlv2/manual/_params/_model_params.py | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/machinelearningservices/azext_mlv2/manual/_help/_model_help.py b/src/machinelearningservices/azext_mlv2/manual/_help/_model_help.py index b9606c249d2..333c051b79e 100644 --- a/src/machinelearningservices/azext_mlv2/manual/_help/_model_help.py +++ b/src/machinelearningservices/azext_mlv2/manual/_help/_model_help.py @@ -28,7 +28,7 @@ def get_model_help(): short-summary: Create a model. long-summary: > Models can be created from a local file, local directory, datastore or job outputs. The created model will be - tracked in the workspace/registry under the specified name and version. If you are using a registry, replace `--workspace-name my-workspace` with the `--registry-name ` option. + tracked in the workspace/registry under the specified name and version. If you are using a registry, replace `--workspace-name my-workspace` with the `--registry-name my-registry` option. examples: - name: Create a model from a YAML specification file text: az ml model create --file model.yml --resource-group my-resource-group --workspace-name my-workspace @@ -85,7 +85,7 @@ def get_model_help(): type: command short-summary: Update a model in a workspace/registry. long-summary: > - The 'description', and 'tags' properties can be updated. If you are using a registry, replace `--workspace-name my-workspace` with the `--registry-name ` option. + The 'description', and 'tags' properties can be updated. If you are using a registry, replace `--workspace-name my-workspace` with the `--registry-name my-registry` option. examples: - name: Update a model's flavors text: az ml model update --name my-model --version 1 --set flavors.python_function.python_version=3.8 --resource-group my-resource-group --workspace-name my-workspace diff --git a/src/machinelearningservices/azext_mlv2/manual/_params/_deployment_template_params.py b/src/machinelearningservices/azext_mlv2/manual/_params/_deployment_template_params.py index fa004fc7ea6..613901a36bf 100644 --- a/src/machinelearningservices/azext_mlv2/manual/_params/_deployment_template_params.py +++ b/src/machinelearningservices/azext_mlv2/manual/_params/_deployment_template_params.py @@ -8,6 +8,8 @@ # regenerated. # -------------------------------------------------------------------------- +from azure.ai.ml.constants._common import YAMLRefDocLinks + from ._common_params import ( add_common_params, add_description_param, @@ -60,7 +62,7 @@ def load_deployment_template_params(self): # Optional for create since they can come from file add_deployment_template_common_param(c, name_required=False, version_required=False) add_lro_param(c) - add_file_param(c, "deployment-template", "https://aka.ms/ml-cli-v2-deployment-template-yaml") + add_file_param(c, "deployment-template", YAMLRefDocLinks.DEPLOYMENT_TEMPLATE) add_override_param(c) c.argument( "registry_name", diff --git a/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py b/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py index 36003d5cb5c..0ae8680cf3e 100644 --- a/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py +++ b/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py @@ -63,9 +63,10 @@ def load_model_params(self): add_description_param(c, help_message="Description of the model.") c.argument( "default_deployment_template", - options_list=["--default-deployment-template"], + options_list=["--default-deployment-template", "-d"], help="Default deployment template for the model. Can be overridden using --set with the format: " - "--set default_deployment_template.asset_id=\"azureml://registries//deploymenttemplates//versions/\"", + "--set default_deployment_template.asset_id=" + "\"azureml://registries/my-registry/deploymenttemplates/template-name/versions/version\"", ) with self.argument_context("ml model show") as c: