Conversation
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 aws#6255 / aws#6088 (sm_train.sh) and aws#6313 (repack launcher), so they are not repeated here. Fixes aws#5873 --- X-AI-Prompt: Fix S-effort PySDK V3 bugs, windows theme X-AI-Tool: Kiro
|
Claude finished @jam-jee's task in 47s —— View job PR Review: Close temp tarball before reading it
VerdictThis is a clean, correct bug fix. It properly addresses the Windows What the fix does well
Test
Minor / non-blocking observations
No correctness, security, or backward-compatibility concerns. Behavior on Linux/macOS is unchanged. Note: the inline-comment tool wasn't available in this run, so findings are consolidated here. |
Summary
FrameworkProcessor._package_coderead and then deleted its temporarytar.gzwhile theNamedTemporaryFilehandle was still open. On Windows that raisesPermissionError: [WinError 32]because the open handle still holds the file, so everyFrameworkProcessor.run()on Windows failed before the job was submitted.The fix closes the handle first, reads the archive through a
with open(...)context, and unlinks it in afinallyblock so the temp file is removed on every path (including upload failure). Behaviour on Linux/macOS is unchanged.The LF line-ending fixes for
sm_train.shand the repack launcher that were originally bundled with this change are already covered by open PRs #6255 / #6088 (sm_train.sh) and #6313 (repack launcher), so they are deliberately not repeated here.Issues fixed
Fixes #5873
Testing
New unit test in
sagemaker-core/tests/unit/test_processing.py:test_package_code_closes_temp_handle_before_unlink-- fails onmaster, passes with this change.tests/unit/test_processing.py: 124 passed.black -l 100andflake8clean on changed files.Integration tests
None added. The defect is a Windows file lock on an open temp handle; CI runs Linux, where the old code also passed, so an integ test could not reproduce it. The unit test is the regression proof, and the tarball round-trip itself is exercised end-to-end by the FrameworkProcessor integ test added in #6318.
X-AI-Prompt: Fix S-effort PySDK V3 bugs, windows theme
X-AI-Tool: Kiro