Fix batchendpoint defaults serialisation#47497
Open
ayushhgarg-work wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression in azure-ai-ml where BatchEndpoint.defaults supplied as a user dict was being sent to the service with snake_case keys (e.g., deployment_name) instead of the expected wire-format camelCase (deploymentName), causing begin_create_or_update to fail or silently no-op in some cases.
Changes:
- Wrap
BatchEndpoint.defaultsdicts into the generated REST model during_to_rest_batch_endpointserialization so the model emits correct camelCase on the wire. - Normalize REST → entity deserialization to expose
BatchEndpoint.defaultsconsistently as a snake_case dict. - Add regression unit tests and document the fix in the changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| sdk/ml/azure-ai-ml/azure/ai/ml/entities/_endpoint/batch_endpoint.py | Converts defaults dicts to/from generated REST model to ensure correct wire casing and consistent public shape. |
| sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_endpoint/batch/batch_endpoint_defaults.py | Adjusts schema post-load to return a plain dict (snake_case) instead of a REST model instance. |
| sdk/ml/azure-ai-ml/tests/batch_online_common/unittests/test_endpoint_entity.py | Adds unit tests validating wire camelCase serialization and snake_case round-trip behavior. |
| sdk/ml/azure-ai-ml/CHANGELOG.md | Adds a bugfix entry documenting the regression and behavior change. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Description
Since
azure-ai-ml1.33.0, setting the default deployment on a batch endpoint failed:Root cause: the TypeSpec-generated client stores raw dicts verbatim, so the snake_case key reached the wire instead of
deploymentName. When the endpoint had no prior defaults, the call silently no-op'd.Fix
entities/_endpoint/batch_endpoint.py— wrap dict intoBatchEndpointDefaults(**...)in_to_rest_batch_endpoint; unwrap back to a snake_case dict in_from_rest_object._schema/_endpoint/batch/batch_endpoint_defaults.py— YAML@post_loadreturns a plain snake_case dict for consistency.tests/batch_online_common/unittests/test_endpoint_entity.py— 3 regression tests (camelCase on wire,NonestaysNone, round-trip stays snake_case).CHANGELOG.md— entry under 1.34.0.Validation
121 passed, 2 skippedin batch unit tests.sdkv2-20250424-ws:before: None→after: {'deployment_name': 'test-deployment-8'}.