fix(train): write sm_train.sh with LF line endings - #6255
Open
MohammedAlkindi wants to merge 1 commit into
Open
Conversation
_prepare_train_script opened the file in text mode, so on a Windows host Python translated every newline to CRLF. The script is packaged and run inside the Linux training container, where bash rejects it at line 1 with "$'\r': command not found" before any user code executes. Nothing in the SDK reads the file back on the host, so the corruption is invisible until the job fails. Pass newline="\n" so the file is LF regardless of the host. Closes aws#5904.
MohammedAlkindi
requested a deployment
to
manual-approval
September 10, 2026 12:58 — with
GitHub Actions
Waiting
MohammedAlkindi
requested a deployment
to
manual-approval
September 10, 2026 12:58 — with
GitHub Actions
Waiting
MohammedAlkindi
requested a deployment
to
manual-approval
September 10, 2026 12:58 — with
GitHub Actions
Waiting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5904.
_prepare_train_scriptopenssm_train.shin text mode, so on a Windows host Python writes CRLF. The file is tarred, uploaded and executed inside the Linux training container, where bash rejects it at line 1:The job fails before any user code runs, and the user cannot fix it: the SDK generates the script. Nothing reads it back on the host, so nothing catches it locally.
newline="\n"makes the write LF regardless of host; the file is only ever consumed by Linux. This is the fix proposed in the issue.The added test writes the script to a real temp dir and asserts no CRLF in the bytes. It fails on unmodified
masterand passes with the change.test_model_trainer.pygoes 57 to 58 passed with an identical set of 7 pre-existing failures, allnova_recipeandllmft_recipecases untouched by this change.Not run: the wider
sagemaker-trainsuite andtox, which is not installed here, so this is pytest against the one file the change affects. Also not run: black, flake8 and pylint.AI-assisted; I reproduced the CRLF output and ran the tests before and after myself.