ratt-ru / dask-ms

Implementation of a dask/xarray dataset backed by a CASA MS
https://dask-ms.readthedocs.io
Other
19 stars 7 forks source link

casacore exception thrown at end of test suite if temporary MS is deleted at the end of the session #32

Open sjperkins opened 5 years ago

sjperkins commented 5 years ago

Description

The ms fixture deletes the measurement set directory once the session closes.

@pytest.fixture(scope="session")
def ms(tmp_path_factory):
    msdir = tmp_path_factory.mktemp("msdir", numbered=False)
    fn = os.path.join(str(msdir), "test.ms")
   ...
    yield fn

    # Remove the temporary directory
    shutil.rmtree(str(msdir))

This seems to interact badly with casacore on python3. It may be hanging on to some references internally.

$ py.test -s -v xarrayms/
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.6.7, pytest-4.5.0, py-1.8.0, pluggy-0.11.0 -- /home/sperkins/venv/xms-py3/bin/python3.6
cachedir: .pytest_cache
rootdir: /home/sperkins/work/ska/code/xarray-ms, inifile: setup.cfg
collected 47 items                                                                                                                                                                                                

xarrayms/tests/test_ms.py::test_ms_read[index_cols=['ANTENNA2', 'ANTENNA1', 'TIME']-
...
xarrayms/tests/test_table_executor.py::test_table_wrapper_locks[lockseq6] PASSED

================================================================================================ warnings summary =================================================================================================
/home/sperkins/venv/xms-py3/lib/python3.6/site-packages/_pytest/mark/structures.py:324
  /home/sperkins/venv/xms-py3/lib/python3.6/site-packages/_pytest/mark/structures.py:324: PytestUnknownMarkWarning: Unknown pytest.mark.slow - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html
    PytestUnknownMarkWarning,

-- Docs: https://docs.pytest.org/en/latest/warnings.html
================================================================================ 45 passed, 2 xfailed, 1 warnings in 20.64 seconds ================================================================================
terminate called after throwing an instance of 'casacore::AipsError'
  what():  RegularFile: /tmp/pytest-of-sperkins/pytest-3/msdir/test.ms/table.dat does not exist and cannot be created
Aborted (core dumped)
sjperkins commented 5 years ago

Solve this for the moment by not deleting the temporary MS in https://github.com/ska-sa/xarray-ms/pull/31/commits/262625ec4a82c62bbf12c5c3927a4d19e028b173