Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,25 @@ def _ml_deployment_template_update(
)

try:
deployment_template = ml_client.deployment_templates.get(name=parameters["name"], version=parameters["version"])

# Only update optional fields if they are explicitly present in parameters
deployment_template = ml_client.deployment_templates.get(
name=parameters["name"], version=parameters["version"]
)

# Detect if user tried to update immutable fields
original = deployment_template._to_dict() # pylint: disable=protected-access
Comment thread
PratibhaShrivastav18 marked this conversation as resolved.
mutable_fields = {"tags", "description"}
for key, value in parameters.items():
if key not in mutable_fields and key in original and original[key] != value:
raise ValueError(
f"Field '{key}' is immutable and cannot be updated. "
"Only 'tags' and 'description' can be modified."
Comment thread
PratibhaShrivastav18 marked this conversation as resolved.
)
Comment thread
PratibhaShrivastav18 marked this conversation as resolved.

# Apply mutable field changes
if "description" in parameters:
deployment_template.description = parameters.get("description")
deployment_template.description = parameters["description"]
if "tags" in parameters:
deployment_template.tags = parameters.get("tags")
deployment_template.tags = parameters["tags"]

deployment_template_result = ml_client.deployment_templates.create_or_update(deployment_template)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ interactions:
response:
body:
string: '{"type": "deploymenttemplates", "name": "test-deployment-template",
"stage": "Archived", "version": "1", "description": "Updated_description_for_deployment_template_testing",
"stage": "Development", "version": "1", "description": "Updated_description_for_deployment_template_testing",
"createdBy": {"userObjectId": "e7ae4769-61f9-4372-8392-79c1757a70b0", "userTenantId":
"72f988bf-86f1-41af-91ab-2d7cd011db47", "userName": "Kshitij Chawla"}, "capabilities":
[], "createdTime": "2025-11-07T07:25:14.9461737+00:00", "modifiedTime": "2025-11-07T16:40:14.7312037+00:00",
Expand Down Expand Up @@ -443,7 +443,7 @@ interactions:
code: 200
message: OK
- request:
body: '{"stage": "Archived", "description": "Updated_description_for_deployment_template_testing",
body: '{"stage": "Development", "description": "Updated_description_for_deployment_template_testing",
"tags": {"stage": "Open", "environment": "test", "updated": "True"}, "deploymentTemplateType":
"Managed", "environmentId": "azureml://registries/kchawla-reg/environments/kchawla-environment/versions/1",
"environmentVariables": {"MODEL_BASE_PATH": "/var/azureml-app/azureml-models/tfs-model1/1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ interactions:
response:
body:
string: '{"type": "deploymenttemplates", "name": "test-deployment-template",
"stage": "Archived", "version": "1", "description": "Updated_description_for_deployment_template_testing",
"stage": "Development", "version": "1", "description": "Updated_description_for_deployment_template_testing",
"createdBy": {"userObjectId": "e7ae4769-61f9-4372-8392-79c1757a70b0", "userTenantId":
"72f988bf-86f1-41af-91ab-2d7cd011db47", "userName": "Kshitij Chawla"}, "capabilities":
[], "createdTime": "2025-11-07T07:25:14.9461737+00:00", "modifiedTime": "2025-11-07T16:40:14.7312037+00:00",
Expand Down Expand Up @@ -443,7 +443,7 @@ interactions:
code: 200
message: OK
- request:
body: '{"stage": "Archived", "description": "Updated_description_for_deployment_template_testing",
body: '{"stage": "Development", "description": "Updated_description_for_deployment_template_testing",
"tags": {"stage": "Open", "environment": "test", "updated": "True", "author":
"test-automation", "project": "cli-testing", "iteration": "second-update", "validated":
"True"}, "deploymentTemplateType": "Managed", "environmentId": "azureml://registries/kchawla-reg/environments/kchawla-environment/versions/1",
Expand Down
Loading