File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1424,10 +1424,12 @@ def _build_training_job_definition(self, inputs):
14241424 # List of InputData or Channel objects
14251425 for inp in inputs :
14261426 if isinstance (inp , InputData ):
1427- # Convert InputData to Channel
1427+ # Convert InputData to Channel. Preserve content_type so built-in
1428+ # algorithms (e.g. XGBoost) know the data format (issue #5632).
14281429 input_data_config .append (
14291430 Channel (
14301431 channel_name = inp .channel_name ,
1432+ content_type = inp .content_type ,
14311433 data_source = DataSource (
14321434 s3_data_source = S3DataSource (
14331435 s3_data_type = "S3Prefix" ,
Original file line number Diff line number Diff line change @@ -581,6 +581,35 @@ def test_build_training_job_definition_includes_internal_channels(self):
581581 assert "validation" in channel_names , "User 'validation' channel should be included"
582582 assert len (channel_names ) == 4 , "Should have exactly 4 channels"
583583
584+ def test_build_training_job_definition_preserves_content_type (self ):
585+ """Regression for #5632.
586+
587+ Converting an InputData to a Channel must carry over content_type, otherwise built-in
588+ algorithms fail because the container doesn't know the data format.
589+ """
590+ from sagemaker .core .training .configs import InputData
591+
592+ tuner = HyperparameterTuner (
593+ model_trainer = _create_mock_model_trainer (),
594+ objective_metric_name = "validation:auc" ,
595+ hyperparameter_ranges = _create_single_hp_range (),
596+ )
597+
598+ definition = tuner ._build_training_job_definition (
599+ [
600+ InputData (
601+ channel_name = "train" ,
602+ data_source = "s3://bucket/train/train.csv" ,
603+ content_type = "csv" ,
604+ )
605+ ]
606+ )
607+
608+ train_channel = next (
609+ ch for ch in definition .input_data_config if ch .channel_name == "train"
610+ )
611+ assert train_channel .content_type == "csv"
612+
584613 def test_build_training_job_definition_includes_spot_params (self ):
585614 """Test that _build_training_job_definition includes spot parameters."""
586615 tuner = HyperparameterTuner (
You can’t perform that action at this time.
0 commit comments