-
Notifications
You must be signed in to change notification settings - Fork 12
Racing condition xdist fix #273
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
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
Resolved intermittent failures 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.
Pull Request Overview
This PR addresses race conditions when running matplotlib image comparison tests in parallel by explicitly setting RNG generators and isolating matplotlib state per worker.
- Updated pytest-mpl marker usage and network layout seeding
- Introduced an autouse fixture to isolate temp directories and backends
- Configured per-worker result paths in
pytest_configure
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
tests/test_1dplots.py | Removed parentheses from @pytest.mark.mpl_image_compare and switched seed to a default_rng instance for network layouts |
tests/conftest.py | Added isolate_mpl_testing fixture for per-worker isolation and adjusted pytest_configure to set worker-specific result directories |
Comments suppressed due to low confidence (3)
ultraplot/tests/test_1dplots.py:578
- NetworkX layout functions expect an int or
RandomState
seed; passing aGenerator
may lead to unexpected behavior. Useseed=SEED
or wrap in aRandomState
object.
layout_kw = dict(seed=np.random.default_rng(SEED))
ultraplot/tests/test_1dplots.py:528
- Removing the parentheses might prevent pytest-mpl from applying default tolerances or baselines; consider restoring
@pytest.mark.mpl_image_compare()
or verifying marker behavior.
@pytest.mark.mpl_image_compare
ultraplot/tests/conftest.py:90
uplt
is not imported in this scope, causing aNameError
. Import the appropriate module or useplt
instead.
uplt.close("all")
Co-authored-by: Copilot <[email protected]>
Note I am not completely sure on the proposed fix here but it cannot hurt. The three tests that are failing are:
Not really sure at this moment what is causing the issue. The network one is highly likely to be caused by the rng which may be fixed in the first commit here. The other two are a bit of a mystery to me. |
I doubt the change from a seed to an RNG will help networkx, but we can try it. |
Ah damn was still drafting this. Couldn't hurt. Not sure why the last two tests are not working properly. It only happens on python 3.10 with mpl 3.90 I believe. Not your fault didn't mark it as draft. |
Ah sorry. It made the failures on the other PR worse, so we could back it out and try again if you wanted. |
We can leave this in as I think it improved the situation from a robustness standpoint (the tmp folders); the network seed was probable not necessary but was a sanity check on my end and the decorator had to be fixed anyway. |
I probed around nx codebase and couldn't directly see how they handled if the seed was an int, hence the generator. In their codebase they immediately called |
This reverts commit c939ae7.
Attempting to set the rng generator explicitly rather than using an integer.