Skip to content

Commit 02d66bc

Browse files
[ML] Deployment templates bug fixes (#9666)
* dt bug fix * refactoring Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5a4c6e4 commit 02d66bc

4 files changed

Lines changed: 39 additions & 3 deletions

File tree

src/machinelearningservices/CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## Unreleased
2+
3+
### Azure Machine Learning CLI (v2) v 2.43.0
4+
5+
- `az ml deployment-template update`
6+
- Fix KeyError crash when updating a deployment template that has no tags or description.
7+
- `az ml deployment-template list`
8+
- Fix table output (`-o table`) not rendering any data rows.
9+
110
## 2026-02-24
211

312
### Azure Machine Learning CLI (v2) v 2.42.0

src/machinelearningservices/azext_mlv2/manual/_format.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,28 @@ def transform_deployment_list(result):
313313
return transformed
314314

315315

316+
def transform_deployment_template_list(result):
317+
"""Table transformer for 'az ml deployment-template list'."""
318+
transformed = []
319+
for r in result:
320+
# Fields may be at top level or nested under "properties"
321+
props = r.get("properties", r)
322+
entry = OrderedDict(
323+
[
324+
("name", props.get("name")),
325+
("version", props.get("version")),
326+
("stage", props.get("stage")),
327+
("deploymentTemplateType", props.get("deploymentTemplateType")),
328+
("defaultInstanceType", props.get("defaultInstanceType")),
329+
("instanceCount", props.get("instanceCount")),
330+
("description", props.get("description")),
331+
]
332+
)
333+
transformed.append(entry)
334+
335+
return transformed
336+
337+
316338
def transform_endpoint_list(result):
317339
transformed = []
318340
for r in result:

src/machinelearningservices/azext_mlv2/manual/commands.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
transform_data,
2222
transform_datastore,
2323
transform_deployment_list,
24+
transform_deployment_template_list,
2425
transform_endpoint_list,
2526
transform_environment,
2627
transform_environment_list,
@@ -229,7 +230,8 @@ def load_command_table(self, _):
229230
with self.command_group("ml deployment-template", client_factory=cf_ml_cl, is_preview=True) as g:
230231
custom_tmpl = "azext_mlv2.manual.custom.deployment_template#{}"
231232
custom_deployment_template = CliCommandType(operations_tmpl=custom_tmpl)
232-
g.custom_command("list", "ml_deployment_template_list", command_type=custom_deployment_template)
233+
g.custom_command("list", "ml_deployment_template_list", command_type=custom_deployment_template,
234+
table_transformer=transform_deployment_template_list)
233235
g.custom_show_command("show", "ml_deployment_template_show")
234236
g.custom_command("create", "ml_deployment_template_create", supports_no_wait=True,
235237
command_type=custom_deployment_template)

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +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-
deployment_template.description = parameters["description"]
150-
deployment_template.tags = parameters["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")
151154

152155
deployment_template_result = ml_client.deployment_templates.create_or_update(deployment_template)
153156

0 commit comments

Comments
 (0)