[azure-ai-ml] Fix deployment_templates.list(name=...) crashing on stringified settings#47945
Merged
swarupecenits merged 4 commits intoJul 9, 2026
Conversation
…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
Contributor
There was a problem hiding this comment.
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 torequest_settings,liveness_probe, andreadiness_probeinDeploymentTemplate._from_rest_object, short-circuiting already-typed (get()) values unchanged. - Added regression tests for both the
list()(stringified) andget()(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.
saanikaguptamicrosoft
approved these changes
Jul 9, 2026
achauhan-scc
approved these changes
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Notes
deployment_templates.list(name=...)raisedAttributeError: 'str' object has no attribute 'request_timeout'and never returned any versions.get()andlist()return different shapes. In thelist()response,requestSettings/livenessProbe/readinessProbearrive as stringified dicts nested underproperties, whereasget()returns typed objects at the top level._from_rest_objectpassed those raw strings straight to the attribute-based converters (OnlineRequestSettings._from_rest_object/ProbeSettings._from_rest_object), which then failed onsettings.request_timeout._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 (theget()shape) short-circuit unchanged, so that path is untouched. Applied torequest_settings,liveness_probe, andreadiness_probe._from_rest_objectfortags/environment_variables/allowed_instance_types, and bringslist()to parity withmodels.list()/environments.list().Testing
test_deployment_template_from_rest_object_list_shape_stringified_settings- feeds the reallist()shape (stringifiedrequestSettings/livenessProbe/readinessProbe) and asserts they are parsed (e.g.request_timeout_ms == 90000, probe thresholds populated).test_deployment_template_from_rest_object_get_shape_typed_settings- asserts the already-workingget()shape (typed settings object) still converts correctly.azure-huggingfaceregistry:deployment_templates.list(name=...)now returns the template versions (parity withmodels.list()), and the reporter's suggested acceptance test passes.deployment_templateunit tests pass;blackandisortclean.Description
Fixes internal bug #5402672.
deployment_templates.list(name=...)no longer raisesAttributeError: 'str' object has no attribute 'request_timeout'and now returns an iterable ofDeploymentTemplateversions, consistent withmodels.list()/environments.list(). The list response nests settings (requestSettings/livenessProbe/readinessProbe) as stringified dicts underproperties; these are now parsed and wrapped into the typed REST models before conversion, while theget()path (already-typed objects) is left unchanged.All SDK Contribution checklist:
Verification
All checks below were run against the live
azure-huggingfaceregistry (and the in-repo unit tests), on the branch with this fix.1. Repro - the crash is gone,
list(name=...)now returns versionsdeployment_templates.list(name=...)previously raisedAttributeError: 'str' object has no attribute 'request_timeout'. It now returns the template versions (v5, v3, v2), withmodels.list()shown as the working control for parity.2. Reporter's suggested acceptance test - passing
The acceptance test from the bug report passes:
test_list_by_name_returns_versionsandtest_list_by_name_parity_with_models.3. In-repo unit tests - passing
The
deployment_templateunit test suite passes, including the added coverage for thelist()(stringified settings) andget()(typed settings) shapes.Testing Guidelines