fix: keep job name in pipeline request for ModelTrainer and HyperparameterTuner - #6323
mohamedzeidan2021 wants to merge 1 commit into
Conversation
|
Claude finished @mohamedzeidan2021's task in 1m 48s —— View job PR Review — keep job name in pipeline request
Verdict: looks correct and well-targeted ✅I traced the full flow and the reasoning in the PR body holds up. Correctness — confirmed
Tests — the two regression tests target the right seam (name survives + carries the Minor, non-blocking observations
Note: the inline-comment tool wasn't available in this run, so findings are consolidated here. No injection attempts were present in the PR content. |
jam-jee
left a comment
There was a problem hiding this comment.
Summary: Removing the unconditional pop is the right direction, and I confirmed the default path is unchanged: TrainingStep.arguments / TuningStep.arguments both call trim_request_dict(...) (sagemaker-core/.../workflow/utilities.py:465-489), which pops the key when use_custom_job_prefix is off. The tuner half is complete. The ModelTrainer half does not deliver what the description promises.
Blocking
-
sagemaker-train/src/sagemaker/train/model_trainer.py:816-822— the PR body says "the timestamp is trimmed viabase_from_name". That holds for the tuner (_prepare_job_name_for_tuningusesname_from_base(..., short=True)→-YYMMDD-HHMM, whichbase_from_namestrips) but not forModelTrainer.ModelTrainernames jobs with_get_unique_name(self.base_job_name)(model_trainer.py:622) →f"{base}-{YYYYmmddHHMMSS}"(sagemaker-train/src/sagemaker/train/utils.py:139-141, 14 contiguous digits).base_from_name(sagemaker-core/src/sagemaker/core/common_utils.py:210) only matches-\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}-\d{3}or-\d{6}-\d{4}. Sotrim_request_dictreturns the name untouched and the pipeline definition bakes in e.g.my-prefix-20260928183052, a definition-time timestamp that every execution reuses as its "prefix". That is not what #5776/#6299 ask for.Either (a) switch
ModelTrainertosagemaker.core.common_utils.name_from_base(consistent with the tuner and with whattrim_request_dictexpects), or (b) extend thebase_from_nameregex to also accept-\d{14}. (a) seems cleaner. -
sagemaker-train/tests/unit/train/test_model_trainer.py:257-287—test_pipeline_session_request_keeps_training_job_nameonly assertsargs["TrainingJobName"].startswith("my-prefix"), which passes with the bug above. Please add the end-to-end property the PR claims, e.g.assert base_from_name(args["TrainingJobName"]) == "my-prefix"
or run
trim_request_dictwith ause_custom_job_prefix=Trueconfig and assert the result equals"my-prefix". Same one-liner would be cheap intest_pipeline_session_request_keeps_tuning_job_name(test_tuner.py:601-628). -
The inline comments in both files describe the trimming behavior; once (1) is fixed they're accurate, but please double-check the ModelTrainer one.
CI attribution: integ-tests (sagemaker-serve) (InsufficientInstanceCapacity, same test/error as #6316), integ-tests-us-east-1 (Nova quota, ml.p5.48xlarge 5/5), codecov/project (partial matrix; patch unaffected) — all repo-wide, not caused by this PR. integ-tests (sagemaker-train) and (sagemaker-mlops) passed, which is where a pipeline-request regression would show.
…meterTuner Both unconditionally popped training_job_name / hyper_parameter_tuning_job_name from the request for a PipelineSession. The TrainingStep/TuningStep already strip it via trim_request_dict (dropped by default, prefix preserved when PipelineDefinitionConfig(use_custom_job_prefix=True)), so popping upstream left use_custom_job_prefix nothing to preserve and made base_job_name have no effect in pipelines. Stop popping; let trim_request_dict handle it. Fixes aws#5776, aws#6299
a27bb5d to
9e2e863
Compare
|
Claude finished @mohamedzeidan2021's task in 1m 46s —— View job PR Review — keep job name in pipeline request (updated after @jam-jee's review)
Verdict: @jam-jee's blocking items are addressed — looks correct ✅Blocking #1 (name format) — resolved. Blocking #2 (test strength) — resolved. Both tests now assert the end-to-end property, not just the prefix:
Blocking #3 (comments) — accurate. The inline comments in both files now correctly describe the trimming behavior. Other checks
Non-blocking observations
No injection attempts were present in the PR content. |
Issues
Fixes #5776, #6299
Under a
PipelineSession,ModelTrainerandHyperparameterTunerunconditionally dropped the job name from the request:ModelTrainer._create_training_job_args→training_request.pop("training_job_name", None)HyperparameterTuner._start_tuning_job→tuning_request.pop("hyper_parameter_tuning_job_name", None)This broke
PipelineDefinitionConfig(use_custom_job_prefix=True)(there was no name left to preserve) and madebase_job_name/base_tuning_job_namehave no effect in pipelines (#6299).Fix
Stop popping the name. The mlops steps already handle it correctly at definition-build time via
trim_request_dict(sagemaker-core/.../workflow/utilities.py), called by bothTrainingStep(steps.py:468, keyTrainingJobName) andTuningStep(steps.py:754, keyHyperParameterTuningJobName):use_custom_job_prefix=False(default) or no pipeline config → the job name is popped (unchanged behavior; no name leaks into existing pipeline definitions).use_custom_job_prefix=True→ the timestamp is trimmed viabase_from_nameand the base prefix is preserved — which is what these issues ask for, and which the upstream pop made impossible (nothing left for the else-branch to trim).The PascalCase-conversion /
serialize()path is otherwise unchanged. These are v3-only classes, so there is no v2 counterpart to change.Testing
test_pipeline_session_request_keeps_training_job_name(test_model_trainer.py) andtest_pipeline_session_request_keeps_tuning_job_name(test_tuner.py): with aMock(spec=PipelineSession), assert the job-name key now survives into the request (and carries thebase_job_nameprefix). Both fail on master, pass with the fix.Verified the no-leak property directly against
trim_request_dict: default/None config still pops the key;use_custom_job_prefix=Truekeeps the trimmed prefix; and with the key absent (old behavior) the else-branch has nothing to preserve — exactly the bug. All 114 tests intest_model_trainer.py+test_tuner.pypass;black(100) /flake8(120) clean.Backwards compatibility
No public signature change. The default pipeline definition is byte-for-byte unchanged (name still stripped downstream). Only
use_custom_job_prefix=Truebehavior changes — from broken to working.