[feature] Add a lock argument to cache_parquet #83
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 260 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.333
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #83"
general
weight: 0.35
timkpaine
Description
Builds on #82; only the last commit is new here.
When several processes write to the same
cache_parquetcache, each one that finds a partition missing or expired fetches it from upstream and writes it, so a cluster job can fetch the same data many times over. Withttl, this happens every time a file expires.This adds a
lockargument: a callable that takes the cache directory and returns a context manager. Only queries that may write take the lock: underCacheMode.CACHEwhen partitions are missing or expired, or when they cannot be enumerated, as for a query without date bounds; underCacheMode.REBUILDalways. Once the lock is held, the query checks the cache again, so a process that waited reads what the other process wrote instead of fetching it. The lock is released before the cache is read. The library doesn't choose a locking mechanism, so callers can use whatever their storage supports.With two processes and a slow upstream, on NFS and on local disk, both processes fetch the same month without a lock. With
SoftFileLock, the second process waits for the first and then reads from the cache without querying upstream.A waiting process still queries upstream when its query has no date bound or is open at one end, because those queries always look for new partitions, and under
CacheMode.REBUILD.Type of Change
Checklist
make lint-py,make lint-docs)python -m pytest polars_io_tools/tests --ignore=polars_io_tools/tests/integration: 2024 passed with Polars 2.0.0, 2021 with Polars 1.44.1)