Repository navigation
fix(tests): release/ignore Windows ONNX temp-file lock in llada & unet parity tests - #417
Merged
Merged
Conversation
ONNX Runtime keeps model files mapped on Windows, causing temporary model cleanup to raise PermissionError. Use cleanup-error-tolerant temporary directories across the LLaDA and UNet parity tests. Co-authored-by: Copilot <[email protected]>
Performance Comparison
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes the LLaDA and UNet numerical parity tests resilient on Windows by avoiding NamedTemporaryFile teardown failures when ONNX Runtime keeps .onnx model files memory-mapped. The parity/inference assertions remain unchanged.
Changes:
- Replace
NamedTemporaryFileusage withTemporaryDirectory(ignore_cleanup_errors=True)and a stablemodel.onnxpath in both test files. - Add brief inline documentation explaining the Windows file-lock behavior during ORT session construction.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/mobius/models/unet_parity_test.py | Writes the temporary UNet ONNX model into a temp dir and ignores cleanup errors to prevent Windows teardown failures. |
| src/mobius/models/llada_test.py | Applies the same temp-dir approach to LLaDA ONNX session creation for Windows compatibility. |
| with tempfile.NamedTemporaryFile(suffix=".onnx") as handle: | ||
| onnx_ir.save(model, handle.name) | ||
| session = ort.InferenceSession(handle.name) | ||
| # Windows keeps the ORT model file mapped; ignore cleanup errors so the dir can be removed. |
| # onnxruntime reads the model fully at construction, so the temp file | ||
| # can be removed as soon as the session exists. | ||
| return ort.InferenceSession(handle.name) | ||
| # Windows keeps the ORT model file mapped; ignore cleanup errors so the dir can be removed. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Summary
TemporaryDirectory(ignore_cleanup_errors=True)for every temporary ONNX model in the LLaDA and UNet parity testsRoot cause
ONNX Runtime can retain a memory-mapped handle to the
.onnxmodel on Windows. Temporary-directory teardown then raisesPermissionErrorbecause Windows does not allow deleting an open file, unlike POSIX.Verification
python3 -m pytest src/mobius/models/unet_parity_test.py src/mobius/models/llada_test.py -q— 3 passed, 4 skippedruff format --check src/mobius/models/llada_test.py src/mobius/models/unet_parity_test.pyruff check src/mobius/models/llada_test.py src/mobius/models/unet_parity_test.pylintrunnerwas also attempted with only these paths; the installed adapter invokes an older Ruff that cannot parse the repository configuration ruleRUF067.