| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Merging this PR will not alter performance✅ 6 untouched benchmarks Comparing fix-cache-result-bug (fc3e5aa) with main (53378e5) |
Sorry, something went wrong.
Fixes mutations of returned (or later-mutated) results leaking into cache entries, making repeated `pipeline.run` calls non-idempotent. - `SimpleCache`, `LRUCache(shared=False)`, and `HybridCache(shared=False)` now deep-copy values on `put` and `get` (shared caches already isolate values via (de)serialization). `DiskCache`'s in-memory LRU layer inherits the fix. - Opt out with `copy=False` for large never-mutated values. - Falls back to the original object with a warning if a value cannot be deep-copied.
Codecov Report✅ All modified and coverable lines are covered by tests.
|
Sorry, something went wrong.
✅ PR Title Formatted CorrectlyThe title of this PR has been updated to match the correct format. Thank you! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes the bug reported by @MitchellAcoustics in #854 (comment): a ResultDict (or any mutable result) returned by a cached function is stored in the cache by reference, so mutating the returned object — by a downstream function in the same run, or by the user afterwards — silently corrupts the cache entry. The next pipeline.run then returns the mutated object instead of the original result (e.g. ErrorSnapshots stripped to nan), making repeated runs non-idempotent.
The fix
The in-memory caches now store and return deep copies:
Performance
Copies are made only for the non-shared in-memory caches, once per put and once per hit. deepcopy is cheaper than the cloudpickle round-trip the default shared path already pays, and by definition cheaper than the recomputation the cache avoids. CodSpeed includes a cached-pipeline benchmark (test_calling_pipeline_directly_with_cache) which will quantify it.
Verification
Addresses the caching pain point of #902. The separate notebook-staleness issue (cache keys don't include the function body, so editing a function returns stale cached results) is intentionally not part of this PR.