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..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 @@ -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" @@ -83,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 95f75c708f6..0ae8680cf3e 100644 --- a/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py +++ b/src/machinelearningservices/azext_mlv2/manual/_params/_model_params.py @@ -61,6 +61,13 @@ 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", "-d"], + help="Default deployment template for the model. Can be overridden using --set with the format: " + "--set default_deployment_template.asset_id=" + "\"azureml://registries/my-registry/deploymenttemplates/template-name/versions/version\"", + ) 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..d6f58a214b9 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( @@ -61,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: @@ -81,6 +84,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