Summary
test_patch_merger_matches_hf_unfold_ordering in _pixtral_vision_test.py fails on Windows CI with:
PermissionError: [Errno 13] Permission denied: 'C:\Users\RUNNER~1\AppData\Local\Temp\tmpXXXX.onnx'
CI run: https://github.com/onnxruntime/mobius/actions/runs/24267296245/job/70864946872
Root Cause
The test uses tempfile.NamedTemporaryFile() to create a temp file, then calls ir.save(model, f.name) which internally calls onnx.save(). On Windows, the temp file handle is still open when onnx.save tries to open the same path for writing — Windows does not allow concurrent file access.
Proposed Fix
Option A (preferred by justinchuby): Run the ORT inference session directly from the in-memory IR model without saving to disk. Use onnxruntime.InferenceSession with the serialized protobuf bytes:
proto = ir.serde.serialize_model(model)
session = ort.InferenceSession(proto.SerializeToString())
Option B: Use tempfile.mkdtemp() for a directory-based approach:
with tempfile.TemporaryDirectory() as tmpdir:
path = os.path.join(tmpdir, "model.onnx")
ir.save(model, path)
session = ort.InferenceSession(path)
Option C: Use NamedTemporaryFile(delete=False), close it before saving:
f = tempfile.NamedTemporaryFile(suffix=".onnx", delete=False)
f.close()
ir.save(model, f.name)
References
Summary
test_patch_merger_matches_hf_unfold_orderingin_pixtral_vision_test.pyfails on Windows CI with:CI run: https://github.com/onnxruntime/mobius/actions/runs/24267296245/job/70864946872
Root Cause
The test uses
tempfile.NamedTemporaryFile()to create a temp file, then callsir.save(model, f.name)which internally callsonnx.save(). On Windows, the temp file handle is still open whenonnx.savetries to open the same path for writing — Windows does not allow concurrent file access.Proposed Fix
Option A (preferred by justinchuby): Run the ORT inference session directly from the in-memory IR model without saving to disk. Use
onnxruntime.InferenceSessionwith the serialized protobuf bytes:Option B: Use
tempfile.mkdtemp()for a directory-based approach:Option C: Use
NamedTemporaryFile(delete=False), close it before saving:References
src/mobius/components/_pixtral_vision_test.py::test_patch_merger_matches_hf_unfold_ordering