← Back to Pull requests

Stable cache keys: hash-seed-independent plans and a df_key option #78

Closed
unknown closed this pull request without merging on Oct 14, 2026 00:53 UTC
View on GitHub
unknown unknown commented on Oct 12, 2026 23:22 UTC
Author

Description

Makes cache() keys usable across processes and environments. Each commit is reviewable on its own.

Plans no longer depend on PYTHONHASHSEED. pushdown_combine and pushdown_pivot captured sets of column names in their IO-source closures. Cloudpickle writes a set in iteration order, and for strings that order depends on the hash seed, so LazyFrame.serialize() returned different bytes in each process. cache() derives its default key from those bytes, so a persistent cache missed on every new run for any frame that included one of these sources. The closures now hold a sorted tuple and a list. I checked every other IO-source closure in the package and found no other sets of strings. There's no regression test for this, because one would need a subprocess per hash seed for every IO source.

New df_key option on cache(). Even with stable ordering, the serialized plan of a frame built from Python IO sources includes the source file paths of its pickled closures (polars' own register_io_source wrapper among them). The default key therefore changes across machines, virtual environments and library upgrades. df_key lets the caller supply the frame's identity instead. order_by and partition_cols are still part of the key, so caches with different layouts stay separate. The default behaviour is unchanged.

Type of Change

  • Bug fix

  • New feature

  • Documentation update

  • Refactor / code cleanup

  • CI / build configuration

  • Other (describe below)
  • Checklist

  • Linting passes (make lint-py, make lint-docs)

  • Tests pass (make test)

  • New tests added for new functionality

  • Documentation updated (if applicable)

  • Changelog / version bump (if applicable)
  • Tests

    test_explicit_df_key_replaces_plan_identity and test_explicit_df_key_still_separates_layouts cover the new option.

    Diff: 237 lines (+177 / -60) across 2 files Reviewer: timkpaine Review duration: 1530m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 237 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.327
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #78"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 37.2% (MEDIUM) · Higher = larger blast radius
    37.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.1% · Safe to merge
    16.1%