Skip to content

Fix BatchEndpoint.defaults regression: restore attribute-access object from get()#47813

Merged
ayushhgarg-work merged 4 commits into
Azure:mainfrom
ayushhgarg-work:ayushhgarg/fix-batch-defaults-attr-regression
Jul 6, 2026
Merged

Fix BatchEndpoint.defaults regression: restore attribute-access object from get()#47813
ayushhgarg-work merged 4 commits into
Azure:mainfrom
ayushhgarg-work:ayushhgarg/fix-batch-defaults-attr-regression

Conversation

@ayushhgarg-work

Copy link
Copy Markdown
Member

What

Follow-up to #47497. That PR fixed BatchEndpoint.defaults snake_case serialization, but
also changed batch_endpoints.get() to return endpoint.defaults as a dict/None instead
of a BatchEndpointDefaults object. This broke the published batch sample notebooks, which
do:

endpoint = ml_client.batch_endpoints.get(name)
endpoint.defaults.deployment_name = deployment.name
ml_client.batch_endpoints.begin_create_or_update(endpoint).result()

On an endpoint with no defaults, endpoint.defaults became None, so
endpoint.defaults.deployment_name = ... raised:
AttributeError: 'NoneType' object has no attribute 'deployment_name'.
8 batch-endpoint samples failed on the release branch.

Fix

Tests

  • Replaced the test that asserted the dict/None behavior with two regression guards:
    attribute access from get(), and the full sample flow (mutate .deployment_name → re-serialize
    → asserts {"deploymentName": ...}).
  • 11 passed in tests/batch_online_common/unittests/test_endpoint_entity.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 addresses a regression in azure-ai-ml where ml_client.batch_endpoints.get() could return BatchEndpoint.defaults as None/dict, breaking existing sample and user code that relies on attribute access (e.g., endpoint.defaults.deployment_name = ...). The intent is to restore an attribute-accessible defaults object while keeping correct camelCase serialization on the wire.

Changes:

  • Restores BatchEndpoint.defaults to be an attribute-accessible object after _from_rest_object (instead of dict/None).
  • Updates the batch endpoint defaults marshmallow schema to return a BatchEndpointDefaults object post-load.
  • Replaces the prior dict/None test assertion with regression tests for attribute access and camelCase round-tripping.

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 Changes _from_rest_object behavior for defaults to preserve attribute access.
sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_endpoint/batch/batch_endpoint_defaults.py Adjusts schema post-load to construct a BatchEndpointDefaults object.
sdk/ml/azure-ai-ml/tests/batch_online_common/unittests/test_endpoint_entity.py Updates unit tests to guard attribute access + correct camelCase serialization round-trip.
sdk/ml/azure-ai-ml/CHANGELOG.md Updates changelog entry to reflect the restored attribute-access behavior for get().

Comment thread sdk/ml/azure-ai-ml/azure/ai/ml/entities/_endpoint/batch_endpoint.py
@ayushhgarg-work ayushhgarg-work enabled auto-merge (squash) July 6, 2026 05:20
@ayushhgarg-work ayushhgarg-work merged commit 658f1d0 into Azure:main Jul 6, 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.

BatchEndpoint defaults serialization regression - deployment_name not converted to camelCase on wire

5 participants