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

speed up testing #451

Open
Mikejmnez opened this issue Oct 11, 2024 · 1 comment
Open

speed up testing #451

Mikejmnez opened this issue Oct 11, 2024 · 1 comment

Comments

@Mikejmnez
Copy link
Collaborator

Mikejmnez commented Oct 11, 2024

  • OceanSpy version:
    most recent

Description

Running pytest -v takes ~ 6 minutes (laptop). The test file oceanspy/tests/test_open_oceandataset.pystalls for a very long there. Sometimes in the past I have had to kill the testing. I ran tests without the file as follows

pytest -v --ignore=oceanspy/tests/tests_opening_saving.py

and it took about 4 minutes to finish through. Better but not ideal...

Approaches:

  • Refactor testing
  • Add parallelism

What I Did

Add parallelism to the testing via pytest-xdist. pip Install it and then run:

pytest -v -n 4

It took consistently a little over 1 minute to be done with all testing (N=10)!!!. However, sometimes pytest would err before testing even began during collection the 4 workers

collecting: 0/4 workers

error was not very helpful. Trying again would always work. Not sure why... I think refactor is still needed, but this was a huge improvements.

Side note on slowest test files

Testing spit out a very interesting RunTimeError with the slow testing file :

oceanspy/tests/test_open_oceandataset.py::test_opening_and_saving[xarray-./oceanspy/tests/Data/catalog_xarray.yaml] - RuntimeError: only endian='native' allowed for NETCDF3 files, got 'big' (variable 'Tair', group '/')

Groups is part of NetCDF4 and not of netCDF3. Perhaps the reason of why that test takes a very long time?

@ThomasHaine
Copy link
Collaborator

That's insightful @Mikejmnez!

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

No branches or pull requests

2 participants