Repository navigation
FIX Memory accepts any os.PathLike location - #1945
Merged
Merged
Conversation
Memory only converted pathlib.Path locations to str. Any other os.PathLike object was rejected with a "not supported" warning and caching was silently disabled. Convert every os.PathLike with os.fspath, as dump and load already do.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1945 +/- ##
==========================================
- Coverage 93.59% 93.55% -0.04%
==========================================
Files 46 46
Lines 8690 8694 +4
==========================================
+ Hits 8133 8134 +1
- Misses 557 560 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
LGTM. Thanks for the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1944
Memoryconverted onlypathlib.Pathlocations tostr. Any otheros.PathLikeobject was rejected with a "not supported" warning, and caching was silently disabled, so cached functions ran again on every call.This change converts every
os.PathLikewithos.fspath, the same wayjoblib.dumpandjoblib.loadalready do.pathlib.Pathis anos.PathLike, so its behaviour does not change. Other path-like objects now get the same location handling asPath: nojoblibsubdirectory is added. Thestrchecks inMemory.__init__andMemory.cacheare unchanged.Changes:
joblib/memory.py: convertos.PathLikewithos.fspathin_store_backend_factory, remove the now-unusedpathlibimport, and update thelocationdocstring.joblib/test/test_memory.py: add a module-level_CustomPathLiketest class and include it in the two existinglocation_typeparametrizations.CHANGES.rst: new entry under "In Development".Related: #960 (PathLike support in dump/load, already handled in #1812) and #1684 (
strvsPathsubdirectory behaviour, not changed here).Testing:
pytest joblib/test/test_memory.py -k "not test_parallel_call_cached_function_defined_in_jupyter" --timeout 30 -vl: pass.test_parallel_call_cached_function_defined_in_jupyter(both parametrizations) was deselected: it fails onmainin my test environment too.pytest joblib/test/test_memory.py -k "preserves_location or preserves_cache_hits" --timeout 30 -vl: pass. The added_CustomPathLikecases fail without the fix.ruff checkandruff format --checkonjoblib/memory.pyandjoblib/test/test_memory.py: pass.pre-commit run --all-files(CI linting job) was not run locally.