Skip to content

fix(model-trainer): force LF endings for generated train script - #6146

Open
saisharan0103 wants to merge 1 commit into
aws:masterfrom
saisharan0103:mergepath/issue-5904-modeltrainer-generates-sm-train-sh-with
Open

fix(model-trainer): force LF endings for generated train script#6146
saisharan0103 wants to merge 1 commit into
aws:masterfrom
saisharan0103:mergepath/issue-5904-modeltrainer-generates-sm-train-sh-with

Conversation

@saisharan0103

Copy link
Copy Markdown

ModelTrainer generated sm_train.sh using Python text-mode defaults via open(..., "w"). On Windows, that translated the \n line endings in TRAIN_SCRIPT_TEMPLATE to \r\n; the uploaded script then ran inside a Linux training container, where CRLF line endings broke bash parsing before user code started.

This updates ModelTrainer._prepare_train_script to write sm_train.sh with newline="\n", so the SDK-generated script uses LF line endings regardless of the client OS.

A focused regression assertion was added to the existing generated-driver-script unit test. It reads sm_train.sh as bytes and verifies that no CRLF bytes are present while keeping the existing content assertions.

Fixes #5904

ruff check sagemaker-train/src/sagemaker/train/model_trainer.py sagemaker-train/tests/unit/train/test_model_trainer.py reports no new findings on the changed files.
Ran pytest -x locally with no new failures.

…line endings on Windows causing training job failure

Closes aws#5904
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.

ModelTrainer generates sm_train.sh with CRLF line endings on Windows causing training job failure

1 participant