Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sagemaker-train/src/sagemaker/train/model_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ def _prepare_train_script(
execute_driver=execute_driver,
)

with open(os.path.join(tmp_dir.name, TRAIN_SCRIPT), "w") as f:
with open(os.path.join(tmp_dir.name, TRAIN_SCRIPT), "w", newline="\n") as f:
f.write(train_script)

@classmethod
Expand Down
7 changes: 4 additions & 3 deletions sagemaker-train/tests/unit/train/test_model_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,10 @@ def test_train_with_distributed_config(
)

assert os.path.exists(expected_train_script_path)
with open(expected_train_script_path, "r") as f:
with open(expected_train_script_path, "rb") as f:
train_script_content = f.read()
assert test_case["expected_template"] in train_script_content
assert test_case["expected_template"] in train_script_content.decode("utf-8")
assert b"\r\n" not in train_script_content

assert os.path.exists(expected_runner_json_path)
with open(expected_runner_json_path, "r") as f:
Expand Down Expand Up @@ -1529,4 +1530,4 @@ def test_llmft_recipe_missing_training_image_error(modules_session):
)

# Clean up the temporary file
os.unlink(recipe.name)
os.unlink(recipe.name)
Loading