fix: write repack launcher with LF endings so pipelines built on Windows work - #6313
Merged
mohamedzeidan2021 merged 1 commit intoSep 28, 2026
Conversation
…ows work _RepackModelStep._inject_repack_script_and_launcher wrote _repack_script_launcher.sh with text-mode open(), which on Windows translates LF to CRLF. The CRLF bash launcher then fails in the Linux repack container (model.tar.gz\\r / aws#15 corruption). Open both launcher writes (S3 and local source_dir branches) with newline="\n" so LF is preserved on every host. Fixes aws#3762
|
Claude finished @mohamedzeidan2021's task in 1m 5s —— View job PR Review: repack launcher LF endings (#6313)
Verdict: LGTM. This is a correct, minimal, well-scoped fix. I'd merge it. Correctness ✅
Tests ✅
Minor / non-blocking observations
No correctness, security, performance, or backward-compatibility concerns. Note: the inline-comment tool wasn't available in this session, so the review is consolidated here. No prompt-injection attempts were present in the PR content. |
jam-jee
approved these changes
Sep 28, 2026
rsareddy0329
added a commit
that referenced
this pull request
Sep 30, 2026
FrameworkProcessor._package_code read and deleted its temporary tar.gz while the NamedTemporaryFile handle was still open. On Windows that raises PermissionError (WinError 32) because the file is still held by the open handle. Close the handle first, read the archive in a with-open context, and unlink it in a finally block so the temp file is removed on every path. The LF line-ending fixes for sm_train.sh and the repack launcher that originally shared this branch are covered by open PRs #6255 / #6088 (sm_train.sh) and #6313 (repack launcher), so they are not repeated here. Fixes #5873 --- X-AI-Prompt: Fix S-effort PySDK V3 bugs, windows theme X-AI-Tool: Kiro Co-authored-by: rsareddy0329 <rsareddy0329@gmail.com>
This branch was successfully deployed
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.
Context (please read first)
This addresses #3762. In that thread a maintainer (@qidewenwhen) confirmed the root-cause analysis is valid but noted the SDK officially supports Unix/Linux/Mac only (supported OS) and re-labeled the issue from bug → Windows-support feature request.
I'm opening this anyway as a low-risk hardening change, not a claim of full Windows support: the fix is a one-argument change that is byte-for-byte identical on the supported platforms and only alters behavior when the SDK happens to run on Windows. It costs supported users nothing and unblocks the (unofficial but common) "author pipeline from a local Windows IDE" workflow. Happy to close if the team would rather keep Windows fixes out entirely.
Problem
When a pipeline is built/upserted from a Windows host, the RepackModel step fails in execution.
_RepackModelStep._inject_repack_script_and_launcherwrites the bash launcher_repack_script_launcher.shfrom a Python string using text-modeopen(..., "w"). On Windows, text mode translates every\ntoos.linesep(\r\n). The resulting CRLF bash script then breaks in the Linux repack container — a trailing\rcorrupts arguments (e.g.model.tar.gz\r/model.tar.gz#015), so the repack cannot find the model artifact. The same code run from Linux/mac works becauseos.linesep == "\n"there.Fix
Open both launcher writes — the S3
source_dirbranch and the localsource_dirbranch — withnewline="\n", which disables newline translation so LF is written verbatim on every host. On Linux/mac the output is byte-identical to before; only Windows behavior changes.The sibling
_repack_model.pyis unaffected: it's copied byte-for-byte viashutil.copy2from an LF-only checked-in file and executed bypython(universal-newline tolerant). The launcher was the only shell script written from a string.Testing
sagemaker-mlops/tests/unit/workflow/test_utils.py:test_inject_repack_launcher_opened_with_lf_newline(local branch) andtest_inject_repack_launcher_opened_with_lf_newline_s3_source_dir(S3 branch) assert the launcher is opened withnewline="\n"— host-independent guards that fail on the old code and pass with the fix (verified viagit stash).test_inject_repack_script_local_source_dirwith a raw-bytes CRLF check (a Windows-only guard, labeled as such).All 17 tests in the module pass;
blackandflake8clean.Backwards compatibility
_inject_repack_script_and_launcheris private; no public signature/return change. Output is unchanged on Linux/mac (already LF). No other readers/writers of the launcher exist in the module.