Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX forward mmap_mode to store backend in MemorizedResult - #1799

Merged
Nanored4498 merged 1 commit into
joblib:mainfrom
IgnazioDS:fix-memorizedresult-mmap-mode
Jun 16, 2026
Merged

FIX forward mmap_mode to store backend in MemorizedResult#1799
Nanored4498 merged 1 commit into
joblib:mainfrom
IgnazioDS:fix-memorizedresult-mmap-mode

Conversation

@IgnazioDS

Copy link
Copy Markdown
Contributor

MemorizedResult takes an mmap_mode argument but never passes it to its store backend. _store_backend_factory is called without backend_options, so the backend keeps mmap_mode=None and load_item loads arrays fully into memory even when mmap_mode="r" was requested. MemorizedFunc already forwards it the same way (via backend_options).

So reconstructing a cached result from a location and asking for mmap gives you a plain array instead of a memmap:

cached = f.call_and_shelve()
direct = MemorizedResult(cached.store_backend.location, cached._call_id, mmap_mode="r")
direct.store_backend.mmap_mode   # None, should be "r"
type(direct.get())               # ndarray, should be memmap

The fix forwards mmap_mode to the factory, matching MemorizedFunc. Added a regression test. Full test_memory.py passes (68), ruff clean.

MemorizedResult accepted mmap_mode but never passed it to
_store_backend_factory, so a result reconstructed from a location loaded
cached arrays fully into memory instead of memory-mapping them, even when
mmap_mode was requested. MemorizedFunc already forwards it via
backend_options. Add a regression test.
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.17%. Comparing base (a78f652) to head (307a715).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1799      +/-   ##
==========================================
- Coverage   94.19%   94.17%   -0.02%     
==========================================
  Files          46       46              
  Lines        7926     7936      +10     
==========================================
+ Hits         7466     7474       +8     
- Misses        460      462       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Nanored4498

Copy link
Copy Markdown
Contributor

LGTM, thanks for the PR

@Nanored4498
Nanored4498 merged commit 7008193 into joblib:main Jun 16, 2026
34 of 37 checks passed
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

Successfully merging this pull request may close these issues.

2 participants