Repository navigation
fix: keep every cached bulk file until its ttl - #71
Merged
Merged
Conversation
CacheManager kept the two most recently downloaded bulk files across all datasets, so a pipeline using three or more downloaded every file again on each run. Each URL has one entry and a refetch overwrites its file, so the eviction only deleted files still in use. The startup sweep now deletes entries past their own TTL, and the bulk TTL is 90 days.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2c90b5320
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
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.
CacheManager._evict_lruinsrc/oda_reader/_cache/manager.pykept thekeep_n=2most recently downloaded entries across the whole bulk cache. Each URL has one entry keyed onsha1(url), and a refetch overwrites that entry's file in place, so the eviction never removed an old version of anything. It removed other datasets. A pipeline that reads CRS, DAC1 and DAC2a downloaded all three again on every run, including the 1.18 GBCRS.parquet. Live checks against 1.11.3 confirmed it: cycling four DAC files, or the full, reduced and 2024 CRS files, re-streamed every one on the second pass._evict_lruand thekeep_nargument are gone. The startup sweep,_evict_expired, deletes each entry whose age exceeds its ownttl_days, along with its file, and keeps the record when the file cannot be deleted, so the TTL is the one bound on what the cache holds.CacheEntry.ttl_daysdefaults to 90, up from 30. The ETag check catches a republish on any call, so the TTL only decides freshness when that check fails, and disk use grows with the number of distinct bulk files a user fetches.docs/docs/caching.md,src/oda_reader/_cache/README.mdand the DAC1 and DAC2b docstrings describe the new rule. The version is 1.11.4.Testing:
uv run pytestpassed (581 passed, 8 skipped).tests/cache/test_expiry_eviction.pyreplaces the LRU tests: four entries within their TTL all survive, an entry one day past its TTL is removed from disk and manifest while one a day short stays, and a failed unlink keeps the record so the next sweep removes it. All three fail against the previousmanager.py.ruff check,ruff format --checkandty checkpass. Against the live host, DAC1, DAC2b and the CRS 2024 file downloaded in one process and all three loaded from the cache in a second.