Skip to content

Add xdist to image compare #266

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

Merged
merged 36 commits into from
Jun 18, 2025
Merged

Add xdist to image compare #266

merged 36 commits into from
Jun 18, 2025

Conversation

cvanelteren
Copy link
Contributor

@cvanelteren cvanelteren commented Jun 17, 2025

This is a continuation of #190.

I added some supporting code to conftest to allow our tests to run in parallel. In addition it adds a custom html to show the results and is compliant with our approach of only keeping the failed images.

I also sorted the dependencies alphabetically in environment.yml to reduce my OCD ;-)

@cvanelteren cvanelteren marked this pull request as draft June 17, 2025 07:13
Copy link

codecov bot commented Jun 17, 2025

@cvanelteren
Copy link
Contributor Author

On the GHA we are running automatically with two workers, not sure if we can force it to use more -- it's not much but it's something I guess. Locally it runs much faster.

@cvanelteren cvanelteren added this to the v1.57.1 milestone Jun 17, 2025
@cvanelteren cvanelteren added the enhancement New feature or request label Jun 17, 2025
@cvanelteren cvanelteren self-assigned this Jun 17, 2025
@cvanelteren cvanelteren requested a review from Copilot June 17, 2025 13:24
@beckermr
Copy link
Collaborator

For the RNGs, I wonder if something in pytest is getting the fixtures confused. Maybe we move to making the RNGs directly within each test?

@cvanelteren
Copy link
Contributor Author

For the RNGs, I wonder if something in pytest is getting the fixtures confused. Maybe we move to making the RNGs directly within each test?

I am creating a new rng for each thread now.
I just checked our context manager is not thread safe. Will add it.

@cvanelteren
Copy link
Contributor Author

I am still expecting the tests will fail when comparing with main. Race conditions are gone locally 🥳 and the test suite is more robust. I may wanna move the plugin to another repo outside the main repository as it contains a lot more code than I was expecting when I started working on it.

@beckermr
Copy link
Collaborator

I think the new rng test fixture is using a different effective seed. We should figure that out.

@cvanelteren
Copy link
Contributor Author

I think the new rng test fixture is using a different effective seed. We should figure that out.

Should be the same no? See

@beckermr
Copy link
Collaborator

beckermr commented Jun 17, 2025

I think this line

return np.random.Generator(np.random.PCG64(SEED))

may need to be

return np.random.default_rng(seed=SEED)

The image comparison tests are failing right now because the data in them is different. So something broke.

@cvanelteren
Copy link
Contributor Author

I believe these are the same for numpy, i.e. the default rng is PCG64 but can change it.

@beckermr
Copy link
Collaborator

Ohhhh I thought it was the MT one. Hrrmmmmm ok. We need to figure out why the tests now differ.

@cvanelteren
Copy link
Contributor Author

I am suspecting that the seed was not properly resetting in its current implementation which makes comparison hard as we don't know when a thread runs a particular test (the racing condition).

I can confirm that generating the baseline from the PR and then running a comparison on that data will always match which indicates that the racing condition is not the problem, but the comparison with main will still fail.

I think what we could do is first merge a PR that ensures the numpy rng is set properly on main and then re-compare this with this PR, what do you think?

@cvanelteren
Copy link
Contributor Author

I will do that now -- time permitting. At least this PR is working with xdist now nicely which is great and the speed ups are very nice for local development 💯

@cvanelteren cvanelteren mentioned this pull request Jun 17, 2025
@cvanelteren
Copy link
Contributor Author

I am going ahead an merging this as the issue is again related to the rng generation. I will confirm with the merged results offline is the issue still persists.

@cvanelteren cvanelteren marked this pull request as ready for review June 18, 2025 05:48
@cvanelteren cvanelteren merged commit 500e45b into Ultraplot:main Jun 18, 2025
3 of 4 checks passed
@cvanelteren cvanelteren deleted the xdist branch June 18, 2025 06:37
@cvanelteren
Copy link
Contributor Author

Found no issues other than then network layout not properly passing the seed, see #256

cvanelteren added a commit to cvanelteren/ultraplot that referenced this pull request Jun 20, 2025
cvanelteren added a commit to cvanelteren/ultraplot that referenced this pull request Jun 20, 2025
beckermr pushed a commit that referenced this pull request Jun 20, 2025
* Revert "Add xdist to image compare (#266)"

This reverts commit 500e45b.

* Revert "Racing condition xdist fix (#273)"

This reverts commit c939ae7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants