fix(sagemaker-core): use caller session for sagemaker control-plane c… - #6107
fix(sagemaker-core): use caller session for sagemaker control-plane c…#6107lucasjia-aws wants to merge 1 commit into
Conversation
…lient SageMakerClient.__init__ built the "sagemaker" control-plane client from a fresh default botocore session (botocore.session.get_session()) instead of the caller-provided session. The custom data loader for the pre-GA Job APIs needs a botocore session to attach to, and the new session it created silently dropped the caller's credentials/profile. Since SageMakerClient is a singleton, that default-credential client was reused process-wide, so control-plane calls went out under the ambient default AWS profile. When the execution role lived in a different account than the default profile, CreateTrainingJob failed with "RoleArn: Cross-account pass role is not allowed". This regressed V2 behavior and was introduced in the MTRL launch (aws#5919, first shipped in v3.13.0). Register the custom data loader on the caller session's underlying botocore session (session._session) and build the sagemaker client from that session, so it keeps the caller's credentials while still loading the custom service model. The other clients already used the passed session and are unchanged.
|
Claude finished @lucasjia-aws's task in 1m 32s —— View job Code Review — PR #6107
SummaryThe change is correct and well-targeted. Building the The comment block added (lines 386–391, 404) clearly documents the rationale, which is valuable given the non-obvious Observations1. Side effect on the caller's session (minor, worth a note) 2. Accessing the private 3. No test covers the changed behavior Nothing blocking. LGTM aside from the optional test suggestion. |
|
related to issue #6069 |
…lient
SageMakerClient.init built the "sagemaker" control-plane client from a fresh default botocore session (botocore.session.get_session()) instead of the caller-provided session. The custom data loader for the pre-GA Job APIs needs a botocore session to attach to, and the new session it created silently dropped the caller's credentials/profile.
Since SageMakerClient is a singleton, that default-credential client was reused process-wide, so control-plane calls went out under the ambient default AWS profile. When the execution role lived in a different account than the default profile, CreateTrainingJob failed with "RoleArn: Cross-account pass role is not allowed". This regressed V2 behavior and was introduced in the MTRL launch (#5919, first shipped in v3.13.0).
Register the custom data loader on the caller session's underlying botocore session (session._session) and build the sagemaker client from that session, so it keeps the caller's credentials while still loading the custom service model. The other clients already used the passed session and are unchanged.
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.