You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ModelTrainer (v3) exposed no way to get the S3 location of a completed training job's output data archive (output.tar.gz — the non-model output under .../output/, distinct from the model artifact model.tar.gz). Users had to reach into the private _latest_training_job resource and hand-compose the path.
Fix
Adds a read-only output_data property to ModelTrainer that returns the fully-qualified S3 URI {s3_output_path}/{training_job_name}/output/output.tar.gz. The S3 output path is resolved from the latest training job's output_data_config, falling back to the trainer's own output_data_config. Raises a clear ValueError when no training job exists yet or no output path can be resolved. The layout matches the repo's canonical build_nova_output_tar_gz_s3_uri. No banned v2 patterns; backward-compatible (net-new, first @property on the class).
Testing
6 new unit tests in tests/unit/train/test_model_trainer.py covering the derived URI, trailing-slash normalization (both job-config and fallback paths), the trainer-config fallback, and both ValueError guards. Full module: 79 passed. black/flake8 clean. Negative control confirmed the tests bind to the change.
Verdict: looks good. The change is correct, backward-compatible (net-new read-only property), well-documented, and thoroughly tested. No banned v2 patterns. A couple of optional notes below — nothing blocking.
Correctness ✅
The path layout {s3_output_path}/{training_job_name}/output/output.tar.gz matches SageMaker's convention (the job's s3_output_path is the base; SageMaker appends {job_name}/output/…) and the repo's canonical build_nova_output_tar_gz_s3_uri helper.
The falsy checks (if job_output_config: / if not s3_output_path) correctly handle sagemaker-core's Unassigned sentinel — I confirmed Unassigned.__bool__ returns False (sagemaker-core/src/sagemaker/core/utils/utils.py:306), so both an Unassigned config and an Unassigneds3_output_path fall through to the trainer-config fallback as intended.
rstrip("/") is only reached after the if not s3_output_path guard, so there's no risk of calling it on None/Unassigned.
Both ValueError guards (no job / no resolvable path) are reasonable and clearly messaged.
Optional suggestions (non-blocking)
Reuse the existing helper.sagemaker-core/src/sagemaker/core/training/utils.py:122 already implements exactly this path composition:
The final two lines of the property duplicate it. Reusing it would keep the two in sync if the layout ever changes. The counter-argument is the helper's nova-specific name, so this is a judgment call — if you don't reuse it, the duplication is at least worth a comment cross-referencing the helper so they don't drift.
Naming consistency. Consider whether a companion accessor for the model artifact (model.tar.gz) is expected alongside this; if so, aligning names now (e.g. output_data / model_data) avoids churn later. Not needed for this PR.
Tests ✅
The 6 new tests in tests/unit/train/test_model_trainer.py cover the derived URI, trailing-slash normalization on both the job-config and fallback paths, the trainer-config fallback, and both ValueError guards. Good coverage for the behavior added.
Security / performance
No concerns — pure string derivation from already-loaded config, no I/O, no credential handling.
Note: the inline-comment tool wasn't available in this environment, so the file/line references are inlined above.
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
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.
Problem
ModelTrainer(v3) exposed no way to get the S3 location of a completed training job's output data archive (output.tar.gz— the non-model output under.../output/, distinct from the model artifactmodel.tar.gz). Users had to reach into the private_latest_training_jobresource and hand-compose the path.Fix
Adds a read-only
output_dataproperty toModelTrainerthat returns the fully-qualified S3 URI{s3_output_path}/{training_job_name}/output/output.tar.gz. The S3 output path is resolved from the latest training job'soutput_data_config, falling back to the trainer's ownoutput_data_config. Raises a clearValueErrorwhen no training job exists yet or no output path can be resolved. The layout matches the repo's canonicalbuild_nova_output_tar_gz_s3_uri. No banned v2 patterns; backward-compatible (net-new, first@propertyon the class).Testing
6 new unit tests in
tests/unit/train/test_model_trainer.pycovering the derived URI, trailing-slash normalization (both job-config and fallback paths), the trainer-config fallback, and bothValueErrorguards. Full module: 79 passed.black/flake8clean. Negative control confirmed the tests bind to the change.Fixes #1936