astropy: get_cached_urls() return is empty in test_name_resolve_cache

Description

Both in 4.1rc1 and on master the above test fails:

> python3.8 -c "import astropy; astropy.test(package='coordinates', args='-vk test_name_resolve', remote_data=True, open_files=True)"                                       
================================================================================== test session starts ===================================================================================
platform darwin -- Python 3.8.3, pytest-5.3.0, py-1.8.1, pluggy-0.13.0 -- /sw/bin/python3.8
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/Users/derek/Downloads/.hypothesis/examples')

Running tests with Astropy version 4.1rc1.
Running tests in /sw/lib/python3.8/site-packages/astropy/coordinates.

Date: 2020-05-26T19:34:58

Platform: macOS-10.12.6-x86_64-i386-64bit

Executable: /sw/bin/python3.8

Full Python Version: 
3.8.3 (default, May 14 2020, 22:17:35) 
[Clang 9.0.0 (clang-900.0.39.2)]

encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8
byteorder: little
float info: dig: 15, mant_dig: 15

Package versions: 
Numpy: 1.19.0rc1
Scipy: 1.4.1
Matplotlib: 3.2.1
h5py: 2.9.0
Pandas: not available
Cython: 0.29.16
Scikit-image: not available
asdf: 2.6.0

Using Astropy options: remote_data: any.

Matplotlib: 3.2.1
Freetype: 2.6.1
PyQt5 5.12.2 -- Qt runtime 5.7.1 -- Qt compiled 5.7.1
rootdir: /sw/lib/python3.8/site-packages/astropy/coordinates
plugins: asdf-2.6.0, flaky-3.5.3, hypothesis-4.36.0, arraydiff-0.3, astropy-header-0.1.2, cov-2.6.1, doctestplus-0.5.0, expect-1.1.0, forked-1.1.3, mock-1.10.4, mpl-0.11, openfiles-0.3.2, qt-3.3.0, remotedata-0.3.1, xdist-1.30.0, requests-mock-1.7.0
collected 1338 items / 1333 deselected / 5 selected                                                                                                                                      

../../../sw/lib/python3.8/site-packages/astropy/coordinates/tests/test_name_resolve.py::test_names PASSED                                                                          [ 20%]
../../../sw/lib/python3.8/site-packages/astropy/coordinates/tests/test_name_resolve.py::test_name_resolve_cache FAILED                                                             [ 40%]
../../../sw/lib/python3.8/site-packages/astropy/coordinates/tests/test_name_resolve.py::test_names_parse PASSED                                                                    [ 60%]
../../../sw/lib/python3.8/site-packages/astropy/coordinates/tests/test_name_resolve.py::test_database_specify[NGC 3642-db_dict0] PASSED                                            [ 80%]
../../../sw/lib/python3.8/site-packages/astropy/coordinates/tests/test_name_resolve.py::test_database_specify[castor-db_dict1] PASSED                                              [100%]

======================================================================================== FAILURES ========================================================================================
________________________________________________________________________________ test_name_resolve_cache _________________________________________________________________________________

tmpdir = local('/private/var/folders/7l/j6rbh6fw8xjc4w0059bv63_h00027w/T/pytest-of-derek/pytest-46/test_name_resolve_cache0')

    @pytest.mark.remote_data
    def test_name_resolve_cache(tmpdir):
        from astropy.utils.data import _get_download_cache_locs, get_cached_urls
        import shelve
    
        target_name = "castor"
    
        temp_cache_dir = str(tmpdir.mkdir('cache'))
        with paths.set_temp_cache(temp_cache_dir, delete=True):
            download_dir, urlmapfn = _get_download_cache_locs()
    
            with shelve.open(urlmapfn) as url2hash:
                assert len(url2hash) == 0
    
            icrs1 = get_icrs_coordinates(target_name, cache=True)
    
            # This is a weak test: we just check to see that a url is added to the
            #  cache!
            with shelve.open(urlmapfn) as url2hash:
                assert len(url2hash) == 1
>               url = get_cached_urls()[0]
E               IndexError: list index out of range

/sw/lib/python3.8/site-packages/astropy/coordinates/tests/test_name_resolve.py:164: IndexError
==================================================================================== warnings summary ====================================================================================
/sw/lib/python3.8/site-packages/_pytest/cacheprovider.py:124
  /sw/lib/python3.8/site-packages/_pytest/cacheprovider.py:124: PytestCacheWarning: could not create cache path /sw/lib/python3.8/site-packages/astropy/coordinates/.pytest_cache/v/cache/stepwise
    self.warn("could not create cache path {path}", path=path)

/sw/lib/python3.8/site-packages/_pytest/cacheprovider.py:124
  /sw/lib/python3.8/site-packages/_pytest/cacheprovider.py:124: PytestCacheWarning: could not create cache path /sw/lib/python3.8/site-packages/astropy/coordinates/.pytest_cache/v/cache/nodeids
    self.warn("could not create cache path {path}", path=path)

/sw/lib/python3.8/site-packages/_pytest/cacheprovider.py:124
  /sw/lib/python3.8/site-packages/_pytest/cacheprovider.py:124: PytestCacheWarning: could not create cache path /sw/lib/python3.8/site-packages/astropy/coordinates/.pytest_cache/v/cache/lastfailed
    self.warn("could not create cache path {path}", path=path)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
===Flaky Test Report===


===End Flaky Test Report===
=============================================================== 1 failed, 4 passed, 1333 deselected, 3 warnings in 13.73s ================================================================

System Details

Same for Python 3.6.10 and 3.7.7

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

Yes, it looks like it is failing on getting the file lock; when changing the warning to an error I see in https://github.com/astropy/astropy/blob/0a46d333a976d3d69c6cd7f9f2e3574298fe5209/astropy/utils/data.py#L1723

    raise WrongDBMModule(wrong_dbm_message + str(e))
astropy.utils.data.WrongDBMModule: Existing astropy cache is in an unsupported format, either install the appropriate package or use astropy.utils.data.clear_download_cache() to delete the whole cache; [Errno 35] Resource temporarily unavailable: '/var/folders/7l/j6rbh6fw8xjc4w0059bv63_h00027w/T/tmpi4atlz_1/cache/astropy/download/py3/urlmap'