Repository navigation
fix: pass the configured session to Model.get in ModelBuilder.build - #6470
Closed
WeAreResilience wants to merge 1 commit into
Closed
WeAreResilience wants to merge 1 commit into
WeAreResilience wants to merge 1 commit into
Conversation
ModelBuilder created the model with self.sagemaker_session but reloaded it with Model.get() using only the region, so the describe call went through the default boto session. When that session points at a different account, the describe fails because the model does not exist there. Fixes #6459
WeAreResilience
requested a deployment
to
manual-approval
October 14, 2026 03:27 — with
GitHub Actions
Waiting
WeAreResilience
requested a deployment
to
manual-approval
October 14, 2026 03:27 — with
GitHub Actions
Waiting
WeAreResilience
requested a deployment
to
manual-approval
October 14, 2026 03:27 — with
GitHub Actions
Waiting
Author
|
Thanks @mohamedzeidan2021, #6487 covers this and also handles the other Model reloads, so I'm closing this one in favor of it. Glad to see #6459 fixed. |
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: #6459
Description of changes:
_create_sagemaker_modelcreates the model throughself.sagemaker_session, then reloads it withModel.get(model_name=..., region=...). With no session, the describe goes through the default boto session, so if that session points at a different account the call fails because the model only exists in the target account.The fix passes
session=self.sagemaker_session.boto_sessiontoModel.get, the same wayTransformeralready does in sagemaker-core. The PipelineSession early return is unchanged.Added
tests/unit/test_model_builder_model_get_session.py, which checks thatModel.getreceives the configured boto session. It fails on master and passes with the fix.Testing: in sagemaker-serve,
tox -e flake8,black-check,docstyle,pylintpasses, and so does the new test. The fulltests/unitrun gave 2076 passed and 65 failed, and the same 65 tests also fail on master in my environment, so the fix doesn't add any failures. I didn't reproduce this against two real AWS accounts._get_model_from_endpointand_find_reusable_modelcallModel.getwithout the session as well. I kept them out of this change to stay within the issue, but I can follow up on them if you'd like.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.