nbodykit icon indicating copy to clipboard operation
nbodykit copied to clipboard

MPI Unit Test Github action is flaky

Open sbird opened this issue 4 months ago • 0 comments

The MPI Unit test github action runs:

mpirun -n 4 --oversubscribe python -m pytest --with-mpi

in a matrix for python 3.8, 3.10 and 3.13.

This fails frequently on github actions, although it passes on my local machine. Test failures are different each time the tests run, and often happen in one python version but not another. Failures are often in IO related tests. An example is:

io/tests/test_fits.py:45:


/usr/lib/python3.12/contextlib.py:137: in enter return next(self.gen) io/tests/test_fits.py:31: in temporary_data fitsio.write(tmpfile, dset, extname='Catalog') ../../../../.local/lib/python3.12/site-packages/fitsio/fitslib.py:408: in write @pytest.mark.parametrize("comm", [MPI.COMM_WORLD,]) @pytest.mark.mpi @pytest.mark.skipif(fitsio is None, reason="fitsio is not installed") def test_string_ext(comm):

    with temporary_data() as (data, tmpfile):

        # read
      f = FITSFile(tmpfile, ext='Catalog')

io/tests/test_fits.py:75:


io/fits.py:34: in init with fitsio.FITS(path) as ff:


self = <[AttributeError("'FITS' object has no attribute '_FITS'") raised in repr()] FITS object at 0x7fb1e01056d0> filename = '/tmp/nbkit_tmp_data.fits', mode = 'r', lower = False, upper = False trim_strings = False, vstorage = 'fixed', case_sensitive = False iter_row_buffer = 1, write_bitcols = False, ignore_empty = False verbose = False, clobber = False, keys = {}, create = 0

with FITS(filename, 'rw', **kwargs) as fits:

self = <[AttributeError("'FITS' object has no attribute 'hdu_list'") raised in repr()] FITS object at 0x7f4a27a63ce0> filename = '/tmp/nbkit_tmp_data.fits', mode = 'rw', lower = False, upper = False trim_strings = False, vstorage = 'fixed', case_sensitive = False iter_row_buffer = 1, write_bitcols = False, ignore_empty = False verbose = False, clobber = False, keys = {}, create = 1

def __init__(self, filename, mode='r', lower=False, upper=False,
             trim_strings=False, vstorage='fixed', case_sensitive=False,
             iter_row_buffer=1, write_bitcols=False, ignore_empty=False,
             verbose=False, clobber=False, **keys):

    if keys:
        import warnings
        warnings.warn(
            "The keyword arguments '%s' are being ignored! This warning "
            "will be an error in a future version of `fitsio`!" % keys,
            DeprecationWarning, stacklevel=2)

    self.lower = lower
    self.upper = upper
    self.trim_strings = trim_strings
    self.vstorage = vstorage
    self.case_sensitive = case_sensitive
    self.iter_row_buffer = iter_row_buffer
    self.write_bitcols = write_bitcols
    filename = extract_filename(filename)
    self._filename = filename

    # self.mode=keys.get('mode','r')
    self.mode = mode
    self.ignore_empty = ignore_empty

    self.verbose = verbose

    if self.mode not in _int_modemap:
        raise IOError("mode should be one of 'r', 'rw', "
                      "READONLY,READWRITE")

    self.charmode = _char_modemap[self.mode]
    self.intmode = _int_modemap[self.mode]

    # Will not test existence when reading, let cfitsio
    # do the test and report an error.  This allows opening
    # urls etc.
    create = 0
    if self.mode in [READWRITE, 'rw']:
        if clobber:
            create = 1
            if filename[0] != '!':
                filename = '!' + filename
        else:
            if os.path.exists(filename):
                create = 0
            else:
                create = 1

    self._did_create = (create == 1)
  self._FITS = _fitsio_wrap.FITS(filename, self.intmode, create)

E OSError: FITSIO status = 104: could not open the named file E failed to find or open the following file: (ffopen) E /tmp/nbkit_tmp_data.fits

../../../../.local/lib/python3.12/site-packages/fitsio/fitslib.py:534: OSError

sbird avatar Aug 20 '25 05:08 sbird