Repository navigation
Conversation
There was a problem hiding this comment.
🤖 AI code review
This PR fixes BedrockModelBuilder._extract_tar_gz_to_s3 so tar member names (e.g. from tar -C <dir> . producing ./config.json) are normalized into clean relative S3 keys, and rejects absolute/drive-letter/.. member paths. The new _tar_member_relative_key helper and its behavior are consistent with the SDK's existing tar-safety conventions (PR #6195), and the added unit tests cover normalization, rejection of unsafe paths, the empty-result error, and the existing-prefix short-circuit. The change looks correct and well-tested; I found no blocking issues.
Reviewed commit f854161. Automated review; verify before acting.
This branch was successfully 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.
Summary
When
BedrockModelBuilder.deploy()imports an OSS model whose artifacts are amodel.tar.gz,_extract_tar_gz_to_s3uploads each archive member to a siblingextracted/prefix. Destination keys were built by appending the raw tar member name. Archives created withtar -C <dir> .therefore produced keys likeextracted/./config.json, which don't line up with theconfig.json/checkpoints/hf*/lookups done right after extraction.This change normalizes member names into clean relative keys before upload.
Changes
sagemaker-serve/src/sagemaker/serve/bedrock_model_builder.py:_tar_member_relative_key(), which strips leading./and empty segments (for example,./checkpoints//hf/config.jsonbecomescheckpoints/hf/config.json)...segments) are skipped with a warning. This matches howcustom_extractall_tarfilefilters members elsewhere in the SDK.RuntimeErroris still raised if nothing is extracted.Testing
TestTarMemberRelativeKeyandTestExtractTarGzToS3tosagemaker-serve/tests/unit/test_bedrock_model_builder.py. These use real in-memory.tar.gzarchives with a mocked S3 client to check:./-prefixed memberstests/unit/test_bedrock_model_builder.pypasses (123 tests).blackandflake8are clean on the changed files.