Repository: joblib/joblib
Pull request #1579 (2024-05-02 11:44:21)

RELEASE 1.4.2 - bugfix release

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/joblib/joblib/pull/1579?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=joblib) Report
Attention: Patch coverage is `91.66667%` with `1 lines` in your changes are missing coverage. Please review.
> Project coverage is 95.21%. Comparing base [(`1787fb7`)](https://app.codecov.io/gh/joblib/joblib/commit/1787fb73db6c7b08beb1bc9cc1d321197678bf53?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=joblib) to head [(`fd8d6af`)](https://app.codecov.io/gh/joblib/joblib/pull/1579?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=joblib).

| [Files](https://app.codecov.io/gh/joblib/joblib/pull/1579?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=joblib) | Patch % | Lines |
|---|---|---|
| [joblib/test/test\_memory.py](https://app.codecov.io/gh/joblib/joblib/pull/1579?src=pr&el=tree&filepath=joblib%2Ftest%2Ftest_memory.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=joblib#diff-am9ibGliL3Rlc3QvdGVzdF9tZW1vcnkucHk=) | 83.33% | [1 Missing :warning: ](https://app.codecov.io/gh/joblib/joblib/pull/1579?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=joblib) |

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main    #1579      +/-   ##
==========================================
- Coverage   95.22%   95.21%   -0.01%     
==========================================
  Files          45       45              
  Lines        7705     7716      +11     
==========================================
+ Hits         7337     7347      +10     
- Misses        368      369       +1     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/joblib/joblib/pull/1579?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=joblib).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=joblib).


Patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index efd8d13..f6601c9 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,12 +1,11 @@
 Latest changes
 ==============
 
-In development
---------------
+Release 1.4.2 -- 2024/05/02
+---------------------------
 
+Due to maintenance issues, 1.4.1 was not valid and we bumped the version to 1.4.2
 
-Release 1.4.1 -- 2024/05/02
----------------------------
 
 - Fix a backward incompatible change in ``MemorizedFunc.call`` which needs to
   return the metadata. Also make sure that ``NotMemorizedFunc.call`` return
diff --git a/joblib/__init__.py b/joblib/__init__.py
index 54f6c8f..8820321 100644
--- a/joblib/__init__.py
+++ b/joblib/__init__.py
@@ -106,7 +106,7 @@ Main features
 # Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.
 # 'X.Y.dev0' is the canonical version of 'X.Y.dev'
 #
-__version__ = '1.5.dev0'
+__version__ = '1.4.2'
 
 
 import os
diff --git a/joblib/memory.py b/joblib/memory.py
index 29e2649..b83a855 100644
--- a/joblib/memory.py
+++ b/joblib/memory.py
@@ -933,6 +933,20 @@ class Memory(Logger):
             Verbosity flag, controls the debug messages that are issued
             as functions are evaluated.
 
+        bytes_limit: int | str, optional
+            Limit in bytes of the size of the cache. By default, the size of
+            the cache is unlimited. When reducing the size of the cache,
+            ``joblib`` keeps the most recently accessed items first. If a
+            str is passed, it is converted to a number of bytes using units
+            { K | M | G} for kilo, mega, giga.
+
+            **Note:** You need to call :meth:`joblib.Memory.reduce_size` to
+            actually reduce the cache size to be less than ``bytes_limit``.
+
+            **Note:** This argument has been deprecated. One should give the
+            value of ``bytes_limit`` directly in
+            :meth:`joblib.Memory.reduce_size`.
+
         backend_options: dict, optional
             Contains a dictionary of named parameters used to configure
             the store backend.
@@ -941,12 +955,21 @@ class Memory(Logger):
     # Public interface
     # ------------------------------------------------------------------------
 
-    def __init__(self, location=None, backend='local', mmap_mode=None,
-                 compress=False, verbose=1, backend_options=None):
+    def __init__(self, location=None, backend='local',
+                 mmap_mode=None, compress=False, verbose=1, bytes_limit=None,
+                 backend_options=None):
         Logger.__init__(self)
         self._verbose = verbose
         self.mmap_mode = mmap_mode
         self.timestamp = time.time()
+        if bytes_limit is not None:
+            warnings.warn(
+                "bytes_limit argument has been deprecated. It will be removed "
+                "in version 1.5. Please pass its value directly to "
+                "Memory.reduce_size.",
+                category=DeprecationWarning
+            )
+        self.bytes_limit = bytes_limit
         self.backend = backend
         self.compress = compress
         if backend_options is None:
@@ -1076,6 +1099,9 @@ class Memory(Logger):
             of the cache, any items last accessed more than the given length of
             time ago are deleted.
         """
+        if bytes_limit is None:
+            bytes_limit = self.bytes_limit
+
         if self.store_backend is None:
             # No cached results, this function does nothing.
             return


Test patch:
diff --git a/joblib/test/test_memory.py b/joblib/test/test_memory.py
index 1a6c69c..f360e2b 100644
--- a/joblib/test/test_memory.py
+++ b/joblib/test/test_memory.py
@@ -1399,6 +1399,16 @@ def test_info_log(tmpdir, caplog):
     caplog.clear()
 
 
+def test_deprecated_bytes_limit(tmpdir):
+    from joblib import __version__
+    if __version__ >= "1.5":
+        raise DeprecationWarning(
+            "Bytes limit is deprecated and should be removed by 1.4"
+        )
+    with pytest.warns(DeprecationWarning, match="bytes_limit"):
+        _ = Memory(location=tmpdir.strpath, bytes_limit='1K')
+
+
 class TestCacheValidationCallback:
     "Tests on parameter `cache_validation_callback`"