Repository navigation
Fix nlp cache release key - #831
Merged
milton-minervino merged 3 commits intoNov 10, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #831 +/- ##
========================================
Coverage 86.18% 86.19%
========================================
Files 115 115
Lines 11859 11864 +5
Branches 2161 2161
========================================
+ Hits 10221 10226 +5
Misses 997 997
Partials 641 641
🚀 New features to boost your workflow:
|
guerinclement
approved these changes
Nov 10, 2026
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.
Summary
NlpExplainer.explain(cache_dir=...)included the full shapash version string in its cache key. Undersetuptools-scmthat string looks like2.10.1.dev13+gd9f9d23.d20261103, which causes two problems:This PR keys the cache on the release (
major.minor.patch) and adds an explicit way to force a refresh.Changes
_cache_release()keeps only the leadingmajor.minor.patch:2.10.0and2.10.1→ different keys. A patch release may fix how a backend computes, and a stale entry looks exactly like a correct one.2.10.1.dev13+g<hash>.d<date>→2.10.1, stable across commits and days.2.11.0rc1→ shares a key with2.11.0.0+unknown(source tree that was never installed) → falls back to the raw string.explain(..., recompute=False).recompute=Trueskips both the in-memory and the on-disk cache, runs the backend again and stores the fresh result. The previous entry is only overwritten after the new one is computed, so a failed recompute (OOM, interrupted run) keeps it, whereasclear_cache()followed byexplain()loses it. This matches the existingrecomputeargument ofcompute_embeddings/compute_projection.clear_cache()stays, for dropping an entry without recomputing.demo/serve_nlp.py --recomputenow usesexplain(recompute=...)instead ofclear_cache()._compute_keyand_load_cacheddocstrings._load_cachedclaimed the key "changes with every release, not with every commit", which wasn't true.Impact
explain(). After that, users recompute once per shapash upgrade, per corpus.explain(recompute=True)or--recomputein the demo.Tests
recomputetests: it bypasses the in-memory guard, it bypasses and overwrites the disk entry, and a failed recompute keeps both the disk entry and the in-memory entry.pytest tests/unit_testspasses, and ruff and mypy are clean.