Fixed unit tests failure due to file access permission issue on Window OS - #84
Merged
Merged
Conversation
…w OS Set delete=False in tempfile.NamedTemporaryFile and removed temp file manually at the end of the unit tests
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
Jacob-Chmura
approved these changes
Jul 1, 2025
Jacob-Chmura
left a comment
Member
There was a problem hiding this comment.
Looks good, thanks for the patch. Hopefully not too many other platform issues arise.
Member
|
We may want to consider adding window's runners for our CI pipeline, to catch things like this |
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.
Purpose
Current unit tests are not compatible with Window OS due to the use of
NamedTemporaryFile().NamedTemporaryFile()keeps a file open and locked for exclusive access. Trying to open the temporary file withopen()causePermisionError.Solution
As suggested here allenai/olmocr#74, an additional flag
delete=Falseis added to each function callNamedTemporaryFile(). The side effect of this flag is that the temporal file will not be removed automatically. Hence,os.remove()is used to delete the temporary file manually.Related PR
Fix #82