-
Notifications
You must be signed in to change notification settings - Fork 413
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
FIX _get_items_to_delete
raising error when items list empty
#1503
Conversation
when calling `.reduce_size` on a newly created memory object without any cached items, it raises a `ValueError: min() arg is an empty sequence`. The argument of `age_limit` must not be None for this case. Fixed by providing a default value to the `min` function used in calculating the oldest item, which would be the current datetime as no items exist.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1503 +/- ##
==========================================
- Coverage 94.99% 94.95% -0.04%
==========================================
Files 45 45
Lines 7551 7556 +5
==========================================
+ Hits 7173 7175 +2
- Misses 378 381 +3
☔ View full report in Codecov by Sentry. |
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.
thanks a lot for the pr.!
maybe a simpler solution is to skip the function of no item is present?
also could you add a non regression test for this case?
Thank you for your comment! 🚀
I would certainly like to try it. Full disclosure: |
A non-regression test is a test case in I agree that the simpler is to skip the function when the |
- return on empty items list
test__get_items_to_delete() function
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.
LGTM! thanks for the PR @Dr-Blank !
There's a test that failed on last merge on main related to reduce size and age limit on windows: https://dev.azure.com/joblib/joblib/_build/results?buildId=3725&view=logs&j=8008bb8c-6b4f-56d5-66f4-b1d037aba1bf&t=7af8808d-3494-56e0-c1dc-6fbf5bb2bc40&l=1563 Could it be related to those changes ? (edit: doesn't seem likely) |
Can we please get this sorted out and merged? It's a pain running with the following construct: from datetime import timedelta
from joblib import Memory
cache_dir: Memory = Memory("/tmp/") # nosec
try:
cache_dir.reduce_size(age_limit=timedelta(days=1))
except ValueError:
# https://github.com/joblib/joblib/pull/1503
@cache_dir.cache(verbose=0)
def dummy():
"""Define dummy function to initialize the cache."""
dummy()
cache_dir.reduce_size(age_limit=timedelta(days=1))
# define cached functions |
when calling
.reduce_size
on a newly created memory object without any cached items, it raises aValueError: min() arg is an empty sequence
. The argument ofage_limit
must not be None for this case.Fixed by providing a default value to the
min
function used in calculating the oldest item, which would be the current datetime as no items exist.