feat: support git_config in SourceCode / ModelTrainer (#5571) - #6358
mohamedzeidan2021 wants to merge 2 commits into
Conversation
|
Claude finished @mohamedzeidan2021's task in 2m 38s —— View job Code Review — PR #6358:
|
|
Solid, well-scoped feature — reusing the existing The credential handling is the part that matters most here, and it's handled correctly for the artifact path: A few things worth confirming before merge, since this is the one security-sensitive surface:
Minor: The validation matrix (entry_script required; local/S3/tar.gz |
…urcecode-git-config # Conflicts: # sagemaker-core/src/sagemaker/core/modules/configs.py # sagemaker-core/src/sagemaker/core/training/configs.py # sagemaker-train/tests/unit/train/test_model_trainer.py
|
Claude finished @mohamedzeidan2021's task in 2m 17s —— View job Code Review — PR #6358:
|
Problem
V3
SourceCode/ModelTrainerhad no way to source training code from a Git repository. V2 estimators accepted agit_configdict, but that capability was lost in the v3 redesign even though the clone/auth/validation infrastructure (sagemaker.core.git_utils.git_clone_repo) already exists in sagemaker-core and was simply never wired into sagemaker-train.Fix
git_config: Optional[dict] = Nonefield toSourceCodein bothsagemaker.core.modules.configsandsagemaker.core.training.configs(kept in sync).ModelTrainer._create_training_job_args: whengit_configis set, clone the repo viagit_clone_repoand resolvesource_dir/entry_scriptto the local clone so the code channel and train script use it. The work is done on a deep copy ofsource_code, soself.source_codeis never mutated andtrain()remains re-callable;git_configis dropped from the copy so credentials are never serialized intosource_code.json._validate_source_code:entry_scriptis required whengit_configis set, and a local (absolute) or S3source_dir(or a.tar.gz) is mutually exclusive withgit_config— a relativesource_diris treated as a path within the repo.git_configis validated (must containrepo).migration.md.No new v2 imports; reuses the shared
sagemaker-coregit utility.Testing
Added 9 unit tests in
tests/unit/train/test_model_trainer.pycovering field acceptance (both config modules), cloning + channel wiring, relative vs. resolvedsource_dir, credential non-serialization, mutual-exclusivity (local + S3),entry_scriptrequirement, and missing-repovalidation. All pass; fulltest_model_trainer.pymodule (82 tests) and sagemaker-core config/git-utils suites (72 tests) green.black+flake8clean.Fixes #5571