Repository navigation
fix(serve): let ModelBuilder.register() omit content and response types - #6486
Closed
Thanatos9404 wants to merge 1 commit into
Closed
Thanatos9404 wants to merge 1 commit into
Thanatos9404 wants to merge 1 commit into
Conversation
register() stores content_types and response_types on the builder only when they are passed, but always reads self.content_types and self.response_types when it builds the model package arguments. A call that leaves either one out (both are optional) raised AttributeError. Default both attributes to None in _initialize_defaults, next to framework and framework_version, which register() reads the same way. get_model_package_args already leaves None values out of the request, and values passed to an earlier register() call are still reused. Fixes aws#6480
Thanatos9404
requested a deployment
to
manual-approval
October 15, 2026 22:13 — with
GitHub Actions
Waiting
Thanatos9404
requested a deployment
to
manual-approval
October 15, 2026 22:14 — with
GitHub Actions
Waiting
Thanatos9404
requested a deployment
to
manual-approval
October 15, 2026 22:14 — with
GitHub Actions
Waiting
Author
This branch is waiting to be deployed
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.
Issue #, if available: Fixes #6480
Description of changes:
ModelBuilder.register()takescontent_typesandresponse_typesas optional arguments (defaultNone). It setsself.content_typesandself.response_typesonly when they are passed, but always reads both attributes forget_model_package_args(), so leaving either one out raisedAttributeError: 'ModelBuilder' object has no attribute 'content_types'(or'response_types').This change defaults both attributes to
Nonein_initialize_defaults(), next toframeworkandframework_version, whichregister()reads the same way and which were defaulted there for #5391 (#5424).get_model_package_args()already leavesNonevalues out, so the request has noSupportedContentTypesorSupportedResponseMIMETypeswhen the types are not given. Both fields are optional inCreateModelPackage(InferenceSpecificationrequires onlyContainers).register()itself is unchanged, so types passed to an earlierregister()call are still reused by a later call that leaves them out, as the issue asks.Testing:
sagemaker-serve/tests/unit/test_model_builder_register.py:register()with neither argument, with onlycontent_types, and with onlyresponse_types(all 3 fail onmasterwith theAttributeErrorand pass with this change), plus a check that a second call reuses the types passed to the first.PipelineSessionwith dummy credentials, no AWS calls): onmasterit raises theAttributeError; with this change the capturedCreateModelPackagerequest has noSupportedContentTypesorSupportedResponseMIMETypes.pytest tests/unit -m "not slow_test"insagemaker-serve(Python 3.12, run before rebasing onto fix(serve): restore JumpStart default instance type from model spec #6045): no new failures compared withmaster; the only differences are the 3 new cases, which fail onmaster. After the rebase, the new tests andTestRegisterReturnsArngive 36 passed.black --checkandflake8pass on the changed files,pydocstylepasses onmodel_builder.py, andpylintwith the repo.pylintrcreports the same messages formodel_builder.pybefore and after the change.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.