RadioAstronomySoftwareGroup / pyuvsim

A ultra-high precision package for simulating radio interferometers in python on compute clusters.
https://pyuvsim.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
43 stars 7 forks source link

Bug with parallelized tests which fail in serial mode #341

Closed aelanman closed 3 years ago

aelanman commented 3 years ago

MPI-enabled tests work by spawning a subprocess to run pytest with mpirun. The pytest hook pytest_runtest_call identifies if a given test has the parallel marker and spawns the subprocess. However, if the subprocess finishes without error (that is, the test passes), the main thread then goes on to run the test (without parallelization, in serial mode). If you have a test that will only pass with multiple MPI processes, it will fail at this step. This hasn't come up before because all of our tests have passed in serial mode if they pass in parallel.

There's a fairly simple fix to this -- If the subprocess completes (i.e., the parallelized test passes), replace the test function in the main thread with a blank function that doesn't do anything. This has been implemented here: https://github.com/RadioAstronomySoftwareGroup/pyuvsim/blob/4724f417999025a4080d753549a28cd7c08caac8/pyuvsim/tests/conftest.py#L113-L116