-
Notifications
You must be signed in to change notification settings - Fork 39
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
Fix tests for multi-processing with spawn method (i.e. macOSX with Python>3.8) #1003
Conversation
nice one @bvreede - but the important question is if an actual task (not a mock task) runs on OSX without setting the multiproc method at the start of the script? Since that's what was getting raised by the failing test 👍 |
Thanks @valeriupredoi! As far as I understand, the task itself runs with either The method that was used in this test is a monkeypatched _run method that is still used, except now called in a different way; i.e. MockBaseTask._run. |
great! if you confirm that you are able to run a few example recipes on OSX with Python>=3.8 and |
I can confirm this! |
Is that enough? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excellent work 🥳
absolutely! I feel like a blind man trying to figure all this stuff only relying on the remote GA machine. Good stuff! If I am not too much of a nuisance, would you be able to have a look at the GA tests next, include OSX fully - for tests and builds etc 🍺 |
If you can explain to me what the GA tests are 😅 absolutely. |
sorry - Github Actions, you can find them in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ensure that this is working with spawn, can you add a test with a context manager:
i.e. something like this:
with multiprocessing.get_context('spawn').Pool() as pool:
pool.map(function, args)
The failing test in GA is the same as the one that's failing on my machine. The latest run on master shows the following failure summary:
The last one is new to me, however; and it does not fail locally with python 3.8 and 3.9. |
sure - go for it! That's my old comment before we've done all the good stuff with Python 3.9. Pls reinstate all the tests I commented out and add whatever you think it's needed so we start understanding what's going on in OSX land (well, more like you start understanding coz I am OSX-less 😁 ). But let's first merge this and continue work in a new PR, I reckon |
Thanks for the review @stefsmeets! I agree it's a good idea to make sure that the tests (and the software) work with both multiprocessing methods — but given that we have now explicitly removed the dependency on spawn/fork from this test, it doesn't make sense to me to add this condition. Or am I missing something? |
Hi @bvreede , good question! This is to make sure that we do not silently introduce a bug that affects the multiprocessing behaviour. i.e. if we want to transition to using 'spawn' eventually / support osx, we might as well add a test right now to ensure any change in behaviour of esmvalcore will cause the test to fail for both methods. |
@bvreede Could you please merge the master branch into this pull request, to see if all tests now pass? |
Co-authored-by: bouweandela <b.andela@esciencecenter.nl>
ac0bb50
to
2cdcbbd
Compare
Not sure if I did that in the most elegant way, but all tests pass now! Merci bien. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bvreede , nice work! Looks fine to me. I'm just wondering why this works, because it seems like it is almost the same as before. I'm not entirely happy how the second test (test_runner_uses_priority
) now monkeypatches MockBaseTask
, but I guess it is the way it is for now. I hope it won't cause issues for the next person debugging this in the future.
Just a small comment on the code and then it is good to go. 🚀
All good, I have not strong enough opinions whether this should be |
Description
Fixed a test that caused problems with MacOSX when using multiprocessing set to spawn (standard in Python 3.8).
Before you get started
Checklist
pre-commit
oryamllint
checksIf you make backwards incompatible changes to the recipe format:
To help with the number pull requests: