Skip to content

fix: [Bug] Pipeline parameters (ParameterInteger, ParameterString) fail in ModelTrain (5504)#38

Closed
aviruthen wants to merge 1 commit intomasterfrom
fix/bug-pipeline-parameters-parameterinteger-5504-2
Closed

fix: [Bug] Pipeline parameters (ParameterInteger, ParameterString) fail in ModelTrain (5504)#38
aviruthen wants to merge 1 commit intomasterfrom
fix/bug-pipeline-parameters-parameterinteger-5504-2

Conversation

@aviruthen
Copy link
Copy Markdown
Owner

Description

Add tests for PipelineVariable support in ModelTrainer hyperparameters

Problem

The safe_serialize function in sagemaker-train/src/sagemaker/train/utils.py was previously unable to handle PipelineVariable objects (e.g., ParameterInteger, ParameterString) passed as hyperparameter values, causing a TypeError: Object of type ParameterInteger is not JSON serializable when building pipelines.

While this bug has already been fixed in the codebase (the safe_serialize function now has an explicit elif isinstance(data, PipelineVariable): return data branch), there was a test gap: the existing test_model_trainer_pipeline_variable.py tested PipelineVariable for training_image, algorithm_name, training_input_mode, and environment fields but did NOT test PipelineVariable in hyperparameters — which is the exact scenario from the bug report.

Changes

Added the following tests to test_model_trainer_pipeline_variable.py:

In TestModelTrainerPipelineVariableAcceptance:

  • test_hyperparameters_accept_parameter_integer — verifies ParameterInteger can be used as a hyperparameter value
  • test_hyperparameters_accept_parameter_string — verifies ParameterString can be used as a hyperparameter value
  • test_hyperparameters_accept_mixed_pipeline_and_static_values — verifies a mix of PipelineVariable and static values works

New TestSafeSerializePipelineVariable class:

  • test_safe_serialize_with_parameter_integer — verifies safe_serialize returns ParameterInteger as-is
  • test_safe_serialize_with_parameter_string — verifies safe_serialize returns ParameterString as-is
  • test_safe_serialize_with_parameter_float — verifies safe_serialize returns ParameterFloat as-is
  • test_safe_serialize_with_plain_string — regression test for plain string passthrough
  • test_safe_serialize_with_int — regression test for integer JSON serialization
  • test_safe_serialize_with_dict — regression test for dict JSON serialization

Testing

All new tests validate the fix is properly covered and will prevent regressions.

Related Issue

Related issue: 5504

Changes Made

The bug described in the issue has already been fixed in the current codebase. The safe_serialize function in sagemaker-train/src/sagemaker/train/utils.py already handles PipelineVariable objects with an explicit elif isinstance(data, PipelineVariable): return data branch (line ~176). The serialize function in sagemaker-core/src/sagemaker/core/utils/utils.py also handles PipelineVariable by returning it as-is. Both functions correctly prevent the TypeError: Object of type ParameterInteger is not JSON serializable error. However, there is a test gap: the existing test_model_trainer_pipeline_variable.py tests PipelineVariable for training_image, algorithm_name, training_input_mode, and environment fields but does NOT test PipelineVariable in hyperparameters — which is the exact scenario from the bug report. We should add tests to ensure this scenario stays covered.

AI-Generated PR

This PR was automatically generated by the PySDK Issue Agent.

  • Confidence score: 92%
  • Classification: bug
  • SDK version target: V3

Merge Checklist

  • Changes are backward compatible
  • Commit message follows prefix: description format
  • Unit tests added/updated
  • Integration tests added (if applicable)
  • Documentation updated (if applicable)

@aviruthen aviruthen closed this Apr 7, 2026
@aviruthen aviruthen deleted the fix/bug-pipeline-parameters-parameterinteger-5504-2 branch April 7, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant