Skip to content

fix(core): place repack dependencies in code root - #6460

Open
lucasjia-aws wants to merge 1 commit into
aws:masterfrom
lucasjia-aws:fix/3491-repack-dependencies
Open

lucasjia-aws wants to merge 1 commit into
aws:masterfrom
lucasjia-aws:fix/3491-repack-dependencies

Conversation

@lucasjia-aws

@lucasjia-aws lucasjia-aws commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Repacked models currently place user dependencies under code/lib, while SageMaker inference toolkits add only code to the Python path. This change copies file and directory dependencies directly into code, matching source-directory packaging and making the dependencies importable at runtime.

The existing collision behavior is preserved: directory conflicts raise FileExistsError, while file dependencies retain shutil.copy2 overwrite semantics.

Testing

  • Added coverage for directory dependencies, single-file dependencies, coexistence with source directories, directory collisions, and file overwrite collisions.
  • Ran the affected helper suite: 10 passed.
  • Black, Flake8, and git diff --check passed.
  • Built the sagemaker-core wheel and source distribution successfully.

Related change

The companion V2 fix is published #6461 .

Fixes #3491

Copy directory and file dependencies alongside inference code so SageMaker inference toolkits can import them without extending sys.path. Preserve the existing copytree collision error and copy2 file overwrite behavior.

Fixes aws#3491

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI code review

This PR changes _create_or_update_code_dir in sagemaker-core so repack dependencies are copied directly into the code root rather than code/lib, matching source-directory packaging and the behavior described in issue #3491 (Source: #3491). The change is minimal and correct: copytree targets code_dir/basename for directories and copy2 targets code_dir for files, preserving the existing collision semantics. New tests cover directory deps, file deps, source-dir coexistence, directory collision, and file overwrite. I found no correctness or test gaps; the PR looks clean.

Reviewed commit 7abcaad. Automated review; verify before acting.

This branch was successfully deployed

1 active deployment
auto-approve — 7abcaade Deployed Oct 13, 2026 by lucasjia-aws via wait-for-approval #2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make sourcedir.tar.gz and repacked model.tar.gz structure consistent

1 participant