-
-
Notifications
You must be signed in to change notification settings - Fork 397
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
ENH: Cache refactoring #1634
ENH: Cache refactoring #1634
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1634 +/- ##
==========================================
+ Coverage 63.97% 64.08% +0.10%
==========================================
Files 132 131 -1
Lines 16984 16927 -57
==========================================
- Hits 10866 10847 -19
+ Misses 6118 6080 -38
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@ceb8 Great to see you picking up this topic! I should probably have gotten back to you sooner on your astroquery/astroquery/eso/core.py Line 713 in 52b490c
My understanding of |
I had some old comments, but this now conflicts, so will come back to review once it's rebased. |
@orionlee No it doesn't make that PR obsolete. Because the MAST DBs update so regularly as new data comes in all the time, I had wanted this underlying work done before implementing true caching on MAST to avoid problems with outdated results being returned forever, but it doesn't solve any of the issues inherent in the long polling nature of the mast servers. |
@ceb Thanks for the clarification. |
What about looking into using one of the following? |
I would change this to a draft PR rather than dragging through more milestone changes. We can change back from draft whenever someone will have the time of wrapping it up. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not having to call time.sleep
in the expired cache test is very good. I still have two documentation suggestions, and an optional minor comment about a line in the tests. I would also recommend squashing out at least the PEP 8 commits.
I'll plan to have a final look at this on the train on Monday, thanks for all the patience @ceb8. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, one more round of review, and mostly nitpicks.
I haven't run all the remote tests, but the ones I run did pass, so I think we should go ahead.
My only serious concern is with the concept of picking. But given that we do that currently, I don't consider it as a blocker, but something for which we want to find a better solution.
/Users/username/.astropy/cache/astroquery/Simbad | ||
|
||
|
||
To clear the cache: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be worth also mentioning how to get rid of all the cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By deleting the directory you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the way I do it, but if there are any other ways, those can be listed, too.
|
||
Shown here are the cache properties, using Simbad as an example: | ||
|
||
.. code-block:: python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to cover this with the remote tests. However, if this is intentionally skipped, please indicate it with doctest-skip instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think remote data is actually required for this, so I didn't give the remote data directive. I thought that unless explicitely skipped the tests would run under doctesting (once the file is added, right now the whole file is skipped at the top).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, OK, fair enough. The file has opted into testing on main
already, so maybe this will just need a rebase to make sure these blocks pass.
OK, I would say let's merge this now. If there is anything left, small follow-ups are always welcome. Also, @ceb8, could you please go through the cache-related issues and close the ones that are not relevant anymore after the merge? I see none are linked for auto-closure, but I don't think it's worth keeping this open for that reason. |
This PR is a continuation of #442 so I am not sure it should be it's own separate thing (@bsipocz @keflavich @jwoillez).
Work included:
cache_timeout = None
which prevents the cache from ever timing outclear_cache
function that removes all cache pickle files from the current cache location (addresses have timeout for cache #1531)reset_cache_preferences
that resets cache location, timout, and enabled/disabled status to astroquery defaultsto_cache
function, guarding against users who manually blow away their cache while in the middle of a session (addresses Cache problem #1625)_request
function cache argument defaults to "None," which means that the default cache preference will be used, setting to either True or False overrides the the global preference.or
order in_request
, so that savedir overrides the global cache location if set (I believe this is the intended behavior)Questions:
suspend_chache
function: I don't understand how this function works or is being used. It sets the cache active status to False, however as far as I can tell we only cache when theto_cache
function is explicitly called, so it isn't clear to me that it is actually doing anything. I assume its presence in the login function is to make sure that login credentials aren't accidentally cached which is very important, so I don't want to mess that up. I changed the private class member_cache_active
into the public memberuse_cache
to allow users to turn caching on/off, but it is unclear to me if I can just changeself.obj._cache_active
toself.obj.use_cache
in thesuspend_cache
function or if something more complicated is needed. @bsipocz @keflavich if you can clarify this, I will updatesuspend_cache
properly.Outstanding work: