Skip to content

[azure-ai-ml] Fix deployment_templates.list(name=...) crashing on stringified settings#47945

Merged
swarupecenits merged 4 commits into
Azure:mainfrom
swarupecenits:fix/deployment-template-list-request-settings
Jul 9, 2026
Merged

[azure-ai-ml] Fix deployment_templates.list(name=...) crashing on stringified settings#47945
swarupecenits merged 4 commits into
Azure:mainfrom
swarupecenits:fix/deployment-template-list-request-settings

Conversation

@swarupecenits

@swarupecenits swarupecenits commented Jul 8, 2026

Copy link
Copy Markdown
Member

Notes

  • Fixes internal bug #5402672: deployment_templates.list(name=...) raised AttributeError: 'str' object has no attribute 'request_timeout' and never returned any versions.
  • Root cause: get() and list() return different shapes. In the list() response, requestSettings / livenessProbe / readinessProbe arrive as stringified dicts nested under properties, whereas get() returns typed objects at the top level. _from_rest_object passed those raw strings straight to the attribute-based converters (OnlineRequestSettings._from_rest_object / ProbeSettings._from_rest_object), which then failed on settings.request_timeout.
  • Fix: added a small _coerce_rest_settings(value, rest_cls) helper that parses the stringified dict and wraps it into the typed REST model before conversion. Already-typed values (the get() shape) short-circuit unchanged, so that path is untouched. Applied to request_settings, liveness_probe, and readiness_probe.
  • This mirrors the existing "parse stringified properties" handling already present in _from_rest_object for tags / environment_variables / allowed_instance_types, and brings list() to parity with models.list() / environments.list().

Testing

  • Added test_deployment_template_from_rest_object_list_shape_stringified_settings - feeds the real list() shape (stringified requestSettings / livenessProbe / readinessProbe) and asserts they are parsed (e.g. request_timeout_ms == 90000, probe thresholds populated).
  • Added test_deployment_template_from_rest_object_get_shape_typed_settings - asserts the already-working get() shape (typed settings object) still converts correctly.
  • Verified live against the azure-huggingface registry: deployment_templates.list(name=...) now returns the template versions (parity with models.list()), and the reporter's suggested acceptance test passes.
  • Full deployment_template unit tests pass; black and isort clean.

Description

Fixes internal bug #5402672. deployment_templates.list(name=...) no longer raises AttributeError: 'str' object has no attribute 'request_timeout' and now returns an iterable of DeploymentTemplate versions, consistent with models.list() / environments.list(). The list response nests settings (requestSettings / livenessProbe / readinessProbe) as stringified dicts under properties; these are now parsed and wrapped into the typed REST models before conversion, while the get() path (already-typed objects) is left unchanged.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

Verification

All checks below were run against the live azure-huggingface registry (and the in-repo unit tests), on the branch with this fix.

1. Repro - the crash is gone, list(name=...) now returns versions

deployment_templates.list(name=...) previously raised AttributeError: 'str' object has no attribute 'request_timeout'. It now returns the template versions (v5, v3, v2), with models.list() shown as the working control for parity.
Screenshot 2026-07-08 161130

2. Reporter's suggested acceptance test - passing

The acceptance test from the bug report passes: test_list_by_name_returns_versions and test_list_by_name_parity_with_models.

Screenshot 2026-07-08 161221

3. In-repo unit tests - passing

The deployment_template unit test suite passes, including the added coverage for the list() (stringified settings) and get() (typed settings) shapes.

Screenshot 2026-07-08 181727

Testing Guidelines

  • Pull request includes test coverage for the included changes.

…ingified settings

In the list() response, requestSettings / livenessProbe / readinessProbe arrive as stringified dicts nested under properties (get() returns typed objects at the top level), so _from_rest_object raised 'str' object has no attribute 'request_timeout'. Parse and wrap those values into the typed REST models before conversion, giving list() parity with models.list() / environments.list(). Adds unit tests for both the list() and get() shapes. Verified live against the azure-huggingface registry. Fixes bug #5402672.
…-python into fix/deployment-template-list-request-settings

# Conflicts:
#	sdk/ml/azure-ai-ml/CHANGELOG.md
#	sdk/ml/azure-ai-ml/tests/deployment_template/unittests/test_deployment_template.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes internal bug #5402672 where deployment_templates.list(name=...) in azure-ai-ml raised AttributeError: 'str' object has no attribute 'request_timeout' and returned no versions. The root cause is that the list() response nests requestSettings / livenessProbe / readinessProbe as stringified dicts under properties, while get() returns typed objects at the top level. The fix adds a _coerce_rest_settings helper that parses the stringified dict and wraps it into the typed REST model before the existing attribute-based converters run, bringing list() to parity with models.list() / environments.list().

Changes:

  • Added _coerce_rest_settings(value, rest_cls) helper and applied it to request_settings, liveness_probe, and readiness_probe in DeploymentTemplate._from_rest_object, short-circuiting already-typed (get()) values unchanged.
  • Added regression tests for both the list() (stringified) and get() (typed) shapes.
  • Added a CHANGELOG entry describing the bug fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
sdk/ml/azure-ai-ml/azure/ai/ml/entities/_deployment/deployment_template.py Adds _coerce_rest_settings helper and coerces settings into typed REST models before conversion
sdk/ml/azure-ai-ml/tests/deployment_template/unittests/test_deployment_template.py Adds regression tests for list/get shapes; contains duplicated test method definitions that shadow each other
sdk/ml/azure-ai-ml/CHANGELOG.md Documents the deployment_templates.list(name=...) bug fix

Address PR review (Copilot): test_deployment_template_from_rest_object_list_shape_stringified_settings and _get_shape_typed_settings were each defined twice after the merge, so the earlier pair was dead code shadowed by the later definitions. Removed the duplicate first pair; the later (executing) definitions are kept.
Build Analyze (cspell) flagged 'azureaiassetsv' (from the azureaiassetsv20240401 import path) in deployment_template.py:14 and :17. Added the word to the package cspell.json ignore list, consistent with how 'restclient' from the same _restclient import path is already handled. Verified locally with the root .vscode/cspell.json config: 0 issues.
@swarupecenits swarupecenits merged commit 0afbc13 into Azure:main Jul 9, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants