fix: [Bug] Pipeline parameters (ParameterInteger, ParameterString) fail in ModelTrain (5504)#5724
Conversation
…il in ModelTrain (5504)
sagemaker-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review
This PR fixes a bug where PipelineVariable objects (ParameterInteger, ParameterString) cause TypeError in safe_serialize when used as hyperparameter values. The fix adds PipelineVariable handling to sagemaker-core's safe_serialize to match the existing pattern in sagemaker-train. The code change is minimal and correct, and tests are comprehensive. A few minor issues worth addressing.
sagemaker-core/tests/unit/core/modules/test_utils_safe_serialize.py
Outdated
Show resolved
Hide resolved
sagemaker-train/tests/unit/train/test_model_trainer_pipeline_variable.py
Show resolved
Hide resolved
🤖 Iteration #1 — Review Comments AddressedDescriptionFix ProblemWhen Pipeline parameters are used as hyperparameter values in
The Fix
Changes
Comments reviewed: 7
|
sagemaker-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review
This PR fixes a bug where PipelineVariable objects (ParameterInteger, ParameterString) cause TypeError in safe_serialize within sagemaker-core. The fix mirrors the existing pattern in sagemaker-train. The code change is minimal and correct, with good test coverage. A few minor issues worth addressing.
sagemaker-train/tests/unit/train/test_model_trainer_pipeline_variable.py
Outdated
Show resolved
Hide resolved
sagemaker-train/tests/unit/train/test_model_trainer_pipeline_variable.py
Show resolved
Hide resolved
🤖 Iteration #2 — Review Comments AddressedDescriptionFix ProblemWhen Pipeline parameters are used as hyperparameter values in
The Fix
Changes
Comments reviewed: 12
|
sagemaker-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review
This PR fixes a bug where PipelineVariable objects (ParameterInteger, ParameterString) cause TypeError in safe_serialize when used as hyperparameter values. The fix adds a PipelineVariable isinstance check to sagemaker-core's safe_serialize to match the existing pattern in sagemaker-train. The approach is sound and well-tested, with a few minor issues to address.
sagemaker-core/tests/unit/core/modules/test_utils_safe_serialize.py
Outdated
Show resolved
Hide resolved
sagemaker-train/tests/unit/train/test_model_trainer_pipeline_variable.py
Outdated
Show resolved
Hide resolved
sagemaker-train/tests/unit/train/test_model_trainer_pipeline_variable.py
Show resolved
Hide resolved
🤖 Iteration #3 — Review Comments AddressedDescriptionFix ProblemWhen Pipeline parameters are used as hyperparameter values in
The Fix
Changes
Comments reviewed: 20
|
Description
The bug is that PipelineVariable objects (ParameterInteger, ParameterString) used as hyperparameter values cause a TypeError when safe_serialize tries to fall back to str(data), because PipelineVariable.str() intentionally raises TypeError. The safe_serialize function in sagemaker-train/src/sagemaker/train/utils.py already has a PipelineVariable isinstance check that returns the PipelineVariable object directly (allowing it to pass through for pipeline serialization). However, the safe_serialize function in sagemaker-core/src/sagemaker/core/modules/utils.py does NOT have this PipelineVariable handling, making it vulnerable to the same bug. The fix needs to: (1) add PipelineVariable handling to sagemaker-core/src/sagemaker/core/modules/utils.py to match the pattern already in sagemaker-train, and (2) add unit tests for safe_serialize with PipelineVariable inputs in both packages.
Related Issue
Related issue: 5504
Changes Made
sagemaker-core/src/sagemaker/core/modules/utils.pysagemaker-train/tests/unit/train/test_model_trainer_pipeline_variable.pysagemaker-train/tests/unit/train/test_safe_serialize.pysagemaker-core/tests/unit/core/modules/test_utils_safe_serialize.pyAI-Generated PR
This PR was automatically generated by the PySDK Issue Agent.
Merge Checklist
prefix: descriptionformat