Conversation
Pull Request Test Coverage Report for Build 14511196164Details
💛 - Coveralls |
timj
left a comment
There was a problem hiding this comment.
The cache directory location can't work as written.
I think you need to have a combination of a read-only resource inside the python package that is accessed via importlib.resources.
ie do a look up first in the package, then look in the astropy cache and then do the simbad query itself and write to the astropy cache.
|
If you don't want to special case this one star in the source code itself, my other suggestion was to have the test |
|
I put a decorator for the test, like Is it sufficient? Otherwise can you be more explicit concerning your idea "to have the test setUp write the ecsv file to the astropy cache so that when the test runs it reads from the cache." ? |
|
I think your decorator idea should be okay so long as nothing writes to that directory. My idea was a more explicit |
|
OK, I hope I understood well your recommandation. I have just pushed a modification of |
|
I don't see any changes to a test for setting the cache dir so that the ecsv file is read. |
Sorry the git push failed. Now it's online. |
| import astropy | ||
| astropy_cache_dir = astropy.config.get_cache_dir() | ||
| except ImportError: | ||
| astropy_cache_dir = os.path.join(f"{os.path.expanduser('~')}", ".astropy", "cache") |
There was a problem hiding this comment.
I'm sorry. When I said "copy the file to the cache in setup" I meant in the test code just before the test runs. Not having setup.py copy the file -- For tests with unittest there is a setUp method that is called that can do things that the tests need. I'm not sure what the equivalent would be for your tests since you aren't using unittest. I didn't even realize you were using the deprecated setup.py to build the package. There is no guarantee that when test code runs that that cache file written during package installation would still exist.
PS I saw recently that Astropy cache tooling does allow you to name the cache directory so you can call it "spectractor", just like astroquery calls it "astroquery".
Avoid multiple queries to Simbad
Coordinates are stored as pickle files in .cache/astroquery folder in the extractor subpackage