Skip to content

Commit a639d07

Browse files
refactoring
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 68e7adb commit a639d07

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/machinelearningservices/azext_mlv2/manual/custom/deployment_template.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ def _ml_deployment_template_update(
146146
try:
147147
deployment_template = ml_client.deployment_templates.get(name=parameters["name"], version=parameters["version"])
148148

149-
# Use .get() instead of [] to avoid KeyError when optional fields like
150-
# "tags" or "description" are absent from the parameters dict
151-
deployment_template.description = parameters.get("description")
152-
deployment_template.tags = parameters.get("tags")
149+
# Only update optional fields if they are explicitly present in parameters
150+
if "description" in parameters:
151+
deployment_template.description = parameters.get("description")
152+
if "tags" in parameters:
153+
deployment_template.tags = parameters.get("tags")
153154

154155
deployment_template_result = ml_client.deployment_templates.create_or_update(deployment_template)
155156

0 commit comments

Comments
 (0)