Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds option to disable filelock, updates tests (Issue #90) #91

Merged
merged 7 commits into from
May 31, 2024

Conversation

vbharadwaj-bk
Copy link
Collaborator

@vbharadwaj-bk vbharadwaj-bk commented May 27, 2024

Fixes #90

This PR adds the use_filelock option to cppimport's global settings (True by default). By setting this to False, users are no longer protected from multiple processes competing to rebuild an extension. This is necessary on filesystems that don't support file locking, e.g. [here].(https://docs.nersc.gov/performance/io/dvs/#:~:text=DVS%20doesn't%20support%20file,locking%2C%20please%20use%20Perlmutter%20Scratch.)

The README has been updated to describe this behavior. In test_cppimport.py, all tests EXCEPT the multiprocessing test have been updated to disable the file lock. The multiprocessing test only runs with the invocation pytest --multiprocessing, and it does not disable the file lock to test this feature.

Verified that all tests passing (2 warnings). Feedback welcome!

====================== 17 passed, 2 warnings in 42.86s =======================

@vbharadwaj-bk vbharadwaj-bk changed the title Adds option to disable filelock, updates tests. Fixes #90. Adds option to disable filelock, updates tests. May 27, 2024
@vbharadwaj-bk vbharadwaj-bk changed the title Fixes #90. Adds option to disable filelock, updates tests. Adds option to disable filelock, updates tests (Issue #90) May 27, 2024
Copy link
Owner

@tbenthompson tbenthompson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wonderful! Thank you so much.

I left one tiny comment if you don't mind making a small edit to the new readme section.

README.md Outdated
@@ -173,6 +174,35 @@ cppimport.settings['lock_timeout'] = 10*60 # 10 mins

You should not use `force_rebuild` when importing concurrently.

### Acquiring the lock hangs or times out unexpectedly - what's going on?
Certain filesystems do not support file locking. You can disable the lock
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind giving an example or two so people might have a better guess of whether their OS supports locking or not?

@tbenthompson
Copy link
Owner

Also looks like the CI flake8 checks are failing on some of the new code. There's a pre-commit config that should get things set up correctly to avoid those issues. but you're also welcome to just flake8 directly.

@tbenthompson
Copy link
Owner

I also invited you as a collaborator. Once the CI is passing, feel free to merge this when you're ready.

@vbharadwaj-bk
Copy link
Collaborator Author

No problem, fixed and passed linting. The CI is still failing for Python 3.7; it turns out Mako doesn't build on Python 3.7 since Nov. 9 2023 see here due to a change in jsonscheme (see here).

Should Python 3.7 be removed from the CI?

@tbenthompson
Copy link
Owner

Thanks! Yeah, it seems like we should just remove Python 3.7 from the CI.

@vbharadwaj-bk vbharadwaj-bk merged commit 0c4ad1c into tbenthompson:main May 31, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiprocessing file lock hangs on certain filesystems
2 participants