Repository navigation
fix: local mode fails when an S3 input channel points to a single file - #6430
Open
ankitdhandharia wants to merge 1 commit into
Open
ankitdhandharia wants to merge 1 commit into
ankitdhandharia wants to merge 1 commit into
Conversation
ankitdhandharia
requested a deployment
to
manual-approval
October 11, 2026 17:40 — with
GitHub Actions
Waiting
ankitdhandharia
requested a deployment
to
manual-approval
October 11, 2026 17:40 — with
GitHub Actions
Waiting
ankitdhandharia
requested a deployment
to
manual-approval
October 11, 2026 17:40 — with
GitHub Actions
Waiting
This branch is waiting to be 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.
Issue #, if available: Fixes #5033
Description of changes:
With
ModelTrainer(training_mode=Mode.LOCAL_CONTAINER), an S3 input channel that points to a single object (for examples3://bucket/train.csv) fails before the container starts:_LocalContainer._get_data_source_local_pathpicks the download directory withTemporaryDirectory(prefix=...).name. Nothing holds on to theTemporaryDirectoryobject, so it is finalized right away and deletes the directory. Only the path string is kept. Prefix inputs still work because_download_files_under_prefixrunsos.makedirsfor every object. The single-object branch ofdownload_folderwrites straight intotarget, which no longer exists.Changes:
_get_data_source_local_pathin bothsagemaker-train(sagemaker/train/local/local_container.py) andsagemaker-core(sagemaker/core/modules/local_core/local_container.py) now creates a real directory withtempfile.mkdtemp(dir=container_root). The directory is still recorded in_temporary_folders, andtrain()already removes those with_rmtreewhen the job finishes.download_foldercreatestargetbefore downloading a single object, so the single-file branch matches the prefix branch for any caller.Testing done:
cd sagemaker-core && python -m pytest tests/unit/modules/local_core/test_local_container.py:test_get_data_source_local_path_s3_single_file_dir_existsfailed withAssertionError: Target directory does not exist(2 failed, 39 passed).cd sagemaker-core && python -m pytest tests/unit/test_common_utils.py -k 'DownloadFolder or download_folder':test_download_folder_single_file_creates_missing_targetfailed withFileNotFoundError: [Errno 2] No such file or directory(1 failed, 3 passed).cd sagemaker-train && python -m pytest tests/unit/train/local/test_local_container.py:test_get_data_source_local_path_s3_single_file_dir_existsfailed withAssertionError: Target directory does not exist(1 failed, 13 passed).cd sagemaker-core && python -m pytest tests/unit/modules/local_core/test_local_container.py -q -p no:cacheprovider: 41 passedcd sagemaker-core && python -m pytest tests/unit/test_common_utils.py -q -k 'DownloadFolder or download_folder': 4 passed (259 deselected)cd sagemaker-core && python -m pytest tests/unit/test_common_utils.py -q: 263 passedcd sagemaker-train && python -m pytest tests/unit/train/local/test_local_container.py -q: 14 passedcd sagemaker-train && python -m pytest tests/unit/train/test_model_trainer.py -q -k 'local': 3 passed (85 deselected)cd sagemaker-core && python -m pytest tests/unit/local/ -q: 176 passedcd sagemaker-train && python -m pytest tests/unit/train/local/test_data.py tests/unit/train/local/test_entities.py -q: 43 passed (6 skipped)black --check -l 100passed on all modified filesflake8passed with 0 errors on all modified filesMerge Checklist
General
Tests
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.