-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add way to have utils.data functions w/ cache have their cache expire #1162
Comments
👍 to this idea! Using |
For the IERS tables considered for Time, one will only know after the file is downloaded up to when the file is good. Also, @taldcroft has suggested that refreshing only happen if the contents do not cover the date for which information is needed; if so, this may be less essential. On the other hand, for these files at least, they just get longer, so once a copy is there, (the equivalent of) |
It might be worth noting that the Sunpy project has a GSoC student who implements a database for organize store and cache datafiles that are downloaded from archives. |
Hi, this student is me :) The docs for the database can be found at http://sunpy.readthedocs.org/en/stable/guide/acquiring_data/database.html and perhaps the most interesting section is Caching. It's also easily possible to implement and use a custom cache type. This is not documented yet, though. Here you can find a unit test for a custom cache to see an example of how to do it: https://github.com/sunpy/sunpy/blob/master/sunpy/database/tests/test_caching.py#L15 You can also find me on #astropy or #sunpy if you want to discuss this idea further outside this thread. |
Right now, the various functions in
utils.data
that have acache
option hold onto their cached copy of a download until the file is deleted. There are some use cases that require the cache expire after a certain time, and get re-downloaded (e.g. #1145).So these functions (which all depend on
download_file
I believe), should allowcache
to give a specific timeframe after which the file should be re-downloaded. This is pretty straightforward, but there is a question how best to define the expiration time. My instinct is to use stdlibdatetime.datetime
anddatetime.timedelta
objects, but an alternative might beastropy.time.Time
andastropy.time.DeltaTime
.The text was updated successfully, but these errors were encountered: