Repository navigation
Closed
Description
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
Activity
pllim commentedon May 26, 2020
Probably because of
PytestCacheWarning: could not create cache path? Are you able to run this somewhere you have write access?dhomeier commentedon May 26, 2020
The cache path in the warning is a system directory and not writable, but running from my user installation throws the same exception:
pllim commentedon May 26, 2020
That is weird. It passed
assert len(url2hash) == 1but fails aturl = get_cached_urls()[0]. Are you able to reproduce it outside of testing environment?dhomeier commentedon May 26, 2020
Where is the
tmpdirfunction set up? When using a manually created newcachedir, I get this:but after the
icrscallcache/astropy/download/py3contains a file in addition tourlmapcontaining the Vizier table; apparentlyget_cached_urlsdoes not find this:pllim commentedon May 26, 2020
I cannot reproduce that on Linux. But I did notice a behavior: For a given
temp_cache_dir(doesn't have to bepytestdir, I use/home/user/zzz), ifzzzis not created yet, it complains aboutFileNotFoundError: [Errno 2] No such file or directory: '/home/user/zzz/astropy', but ifzzzis there but notzzz/astropy, then it creates theastropysubdir and succeeds.When it succeeds:
dhomeier commentedon May 26, 2020
Yes, the
cachedir is expected to be created by thetmpdir.mkdir('cache'), all subdirectories are then created automatically, butdelete=Truewas removing the base directory as well, therefore I changed it todelete=Falseto check the contents.The
url2hashfrom the context apparently has the correct url, but it is not communicated toget_cached_urls:pllim commentedon May 26, 2020
Do you get any warnings at all? Looking at
_cacheimplementation, it yields an emptydictwith a warning if something goes wrong. That would explain why you are seeing an empty list, which is the output of listing keys for emptydict.pllim commentedon May 26, 2020
Also, I am starting to get curious if newer OSX sees this or it is just 10.12.
dhomeier commentedon May 26, 2020
Yes, it looks like it is failing on getting the file lock; when changing the warning to an error I see in
astropy/astropy/utils/data.py
Line 1723 in 0a46d33
pllim commentedon May 26, 2020
Let's see if @aarchiba knows of cache support in OSX 10.12. Unfortunately, I am not a Mac user.
dhomeier commentedon May 26, 2020
It seems to work allright with the default
~/.astropy/cachedirectory, but using anypaths.set_temp_cache()directory (even inside~/.astropy) always results in the[Errno 35] Resource temporarily unavailableexception.pllim commentedon May 27, 2020
Are you able to turn that warning into exception (say, using the filtering provided by
warnings) to see where exactly it is coming from?aarchiba commentedon Jun 2, 2020
Sorry, just getting up to speed on this. This particular error means what it says - the cache exists, but the index is in a database format the current python does not understand. The most common situation is that the cache was created by a Python that supports gdbm but the current python does not (for example it is often not part of Anaconda).
aarchiba commentedon Jun 2, 2020
Getting back to the original bug: do any of the tests in astropy.utils fail? There is a very extensive cache testing suite in there, and it would help to see whether any of those fail.
aarchiba commentedon Jun 2, 2020
Because the test as written pokes around in the guts of the cache mechanism, it's possible there isn't actually a problem. But the test is checking that the downloaded data is stored in the cache, so if something about your configuration makes caching not work, download_file will just re-download on every request, but this test will fail. Now it does its testing with a cache set to a temporary directory, so I can't see how the cache could fail to be writable, so that shouldn't be a problem.
The test could be simplified - there isn't really any need to check what is in the cache, since the property being tested is really just that after the first download the file is available even if the internet is not.