Repository navigation
Keep current results when evicting stale versions from the diskcache adapter - #1823
Open
dhananjay6561 wants to merge 2 commits into
Open
dhananjay6561 wants to merge 2 commits into
dhananjay6561 wants to merge 2 commits into
Conversation
Signed-off-by: dhananjay6561 <dhananjayaggarwal6561@gmail.com>
Signed-off-by: dhananjay6561 <dhananjayaggarwal6561@gmail.com>
Author
|
Hi @skrawcz @jernejfrank, another small fix when you get a chance. |
This branch has not been deployed
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.
h_diskcache.evict_all_except(andevict_all_except_driver) is meant to drop every cached version of a node except the current one. It has two bugs:DiskCacheAdapterappends the node's hash to_nodes_historyon every cache miss, so after runningdoubled(x)withx=1andx=2the history is[h, h].history.remove(h)only takes out the first one, and the loop then evicts tagdoubled.h, which deletes all the current results.ValueError: list.remove(x): x not in listwhen the current version of a node has no cached results yet, e.g. you edited the function and call eviction before running it again.Repro for the first one:
Changes
evict_all_exceptdedupes the hashes in a node's history before evicting, and only keeps (and skips evicting) the current hash when it is actually in the history. Otherwise the node is left out of the new history, since nothing is cached for it.How I tested this
assert 2 == 1with the current results gone, and theValueError), and pass with the change.pytest tests/plugins/test_h_diskcache.py(8 passed).x=1after eviction, and eviction after editing the function no longer raises.ruff format --checkandruff check(0.16.9) on the touched files.Notes
I know
DiskCacheAdapteris deprecated in favour ofBuilder.with_cache(), but it is still shipped and this loses cached results silently, so it seemed worth a small fix.eviction_counternow counts each stale version once rather than once per history entry.Checklist