fix(sagemaker): honor aws_role_name/aws_session_name in embedding()#22663
Open
gustipardo wants to merge 2 commits intoBerriAI:mainfrom
Open
fix(sagemaker): honor aws_role_name/aws_session_name in embedding()#22663gustipardo wants to merge 2 commits intoBerriAI:mainfrom
gustipardo wants to merge 2 commits intoBerriAI:mainfrom
Conversation
Use _load_credentials() in embedding() so aws_role_name/aws_session_name are honored and boto3 runtime client is created with assumed-role credentials. Add regression test for role/session propagation and credentialed client init.
Avoid hard dependency on local boto3/botocore installs by patching sys.modules for boto3 and botocore.credentials. Keeps regression test deterministic across CI and local environments.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThis PR fixes SageMaker
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/llms/sagemaker/completion/handler.py | Replaces manual credential handling in embedding() with _load_credentials(optional_params), matching the pattern already used by completion(). No issues found. |
| tests/test_litellm/llms/sagemaker/test_sagemaker_embedding_auth.py | New mock-only regression test verifying role assumption flows through to boto3 client initialization and auth params are stripped from optional_params. No real network calls. |
Sequence Diagram
sequenceDiagram
participant Caller
participant SagemakerLLM as SagemakerLLM.embedding()
participant LoadCreds as _load_credentials()
participant GetCreds as get_credentials()
participant STS as AWS STS (AssumeRole)
participant Boto3 as boto3.client()
participant SM as SageMaker Runtime
Caller->>SagemakerLLM: embedding(optional_params={aws_role_name, aws_session_name, ...})
SagemakerLLM->>LoadCreds: _load_credentials(optional_params)
LoadCreds->>LoadCreds: Pop aws_* params from optional_params
LoadCreds->>GetCreds: get_credentials(aws_role_name, aws_session_name, ...)
GetCreds->>STS: sts.assume_role(RoleArn, SessionName)
STS-->>GetCreds: Assumed credentials (access_key, secret_key, token)
GetCreds-->>LoadCreds: Credentials object + region
LoadCreds-->>SagemakerLLM: (credentials, aws_region_name)
SagemakerLLM->>Boto3: client(sagemaker-runtime, access_key, secret_key, token, region)
Boto3-->>SagemakerLLM: sagemaker_client
SagemakerLLM->>SM: invoke_endpoint(model, data)
SM-->>SagemakerLLM: embedding response
SagemakerLLM-->>Caller: EmbeddingResponse
Last reviewed commit: 0fd8794
Contributor
|
Hey @gustipardo — just a heads up, I opened #20435 about a month ago which fixes the same issue (#22210) with the same approach (replacing the manual boto3 client creation with |
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.
Summary
_load_credentials(optional_params)in SageMakerembedding()before creating the runtime clientaws_role_name/aws_session_nameare passed into credential resolution (AssumeRole path)_load_credentialspop behaviorboto3.client(...)initializationboto3andbotocore.credentialsviasys.modulesValidation
venv/bin/pytest tests/test_litellm/llms/sagemaker/test_sagemaker_embedding_auth.py -q1 passedCloses #22210