Skip to content
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

Doc Improvement: parameter age_limit of function reduce_size time unit unknown. #1488

Open
PhilipMay opened this issue Aug 4, 2023 · 1 comment

Comments

@PhilipMay
Copy link

I guess it is seconds.... but should be added to the docstring.

@tomMoral
Copy link
Contributor

tomMoral commented Apr 4, 2024

Hello,

Thanks for reporting the issue and sorry for the reply delay.

The age_limit attribute should be of type datetime.timedelta (as specified here: https://joblib.readthedocs.io/en/stable/generated/joblib.Memory.html#joblib.Memory.reduce_size).
Passing an integer raises an error:

from joblib import Memory

mem = Memory('.')

@mem.cache
def f():
    return

f()
mem.reduce_size(age_limit=0)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[7], line 1
----> 1 mem.reduce_size(age_limit=0)

File ~/.local/miniconda/lib/python3.10/site-packages/joblib/memory.py:1141, in Memory.reduce_size(self, bytes_limit, items_limit, age_limit)
   1138     return
   1140 # Defers the actual limits enforcing to the store backend.
-> 1141 self.store_backend.enforce_store_limits(
   1142     bytes_limit, items_limit, age_limit
   1143 )

File ~/.local/miniconda/lib/python3.10/site-packages/joblib/_store_backends.py:303, in StoreBackendMixin.enforce_store_limits(self, bytes_limit, items_limit, age_limit)
    297 def enforce_store_limits(
    298         self, bytes_limit, items_limit=None, age_limit=None
    299 ):
    300     """
    301     Remove the store's oldest files to enforce item, byte, and age limits.
    302     """
--> 303     items_to_delete = self._get_items_to_delete(
    304         bytes_limit, items_limit, age_limit
    305     )
    307     for item in items_to_delete:
    308         if self.verbose > 10:

File ~/.local/miniconda/lib/python3.10/site-packages/joblib/_store_backends.py:343, in StoreBackendMixin._get_items_to_delete(self, bytes_limit, items_limit, age_limit)
    341 if age_limit is not None:
    342     older_item = min(item.last_access for item in items)
--> 343     deadline = datetime.datetime.now() - age_limit
    344 else:
    345     deadline = None

TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'int'

I am not sure I understand the issue, how would you specify the units?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants