Skip to content

refactor(benchmark): split benchmark fetching and lookup modules (#41) - #143

Merged
Andyyyy64 merged 1 commit into
Andyyyy64:mainfrom
RaghavRD:refactor/benchmark-split
Jul 8, 2026
Merged

refactor(benchmark): split benchmark fetching and lookup modules (#41)#143
Andyyyy64 merged 1 commit into
Andyyyy64:mainfrom
RaghavRD:refactor/benchmark-split

Conversation

@RaghavRD

@RaghavRD RaghavRD commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Refs #41

What

Splits src/whichllm/models/benchmark.py into focused modules:

  • benchmark_cache.py — benchmark cache read/write helpers
  • benchmark_fetch.py — source fetching and layered merge policy
  • benchmark_lineage.py — frozen-score lineage recency demotion
  • benchmark_index.py — score indices and model-line interpolation
  • benchmark_lookup.py — benchmark evidence lookup and inheritance rules
  • benchmark_types.py — shared BenchmarkEvidence dataclass
  • benchmark.py — compatibility shim / legacy import surface

Why

Per #41, benchmark.py mixed cache I/O, network source orchestration, merge rules, lineage staleness handling, score indexing, and lookup/evidence heuristics. Splitting these responsibilities makes future benchmark and evidence changes easier to review independently.

Testing

  • uv run pytest -q tests/test_benchmark_lookup.py tests/test_cache_encoding.py tests/test_r3_regressions.py — 41 passed
  • uv run pytest -q — 466 passed
  • .venv/bin/ruff check . — all checks passed
  • .venv/bin/ruff format --check . — 98 files already formatted

Notes

Behavior-preserving refactor:

  • No ranking behavior changes
  • No CLI behavior changes
  • No source score formula changes
  • Public import surface preserved through whichllm.models.benchmark
  • Existing benchmark cache monkey-patch behavior preserved

Move benchmark cache I/O, source fetching, lineage demotion, score indexing, lookup evidence, and shared types into focused modules.

Keep whichllm.models.benchmark as a compatibility shim so existing imports and tests continue to work.

Refs Andyyyy64#41

@Andyyyy64 Andyyyy64 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this took me a few days to review.

I checked the split carefully. The important benchmark helpers moved cleanly into focused modules, and whichllm.models.benchmark keeps the old import surface through the shim. I also checked the cache monkeypatch path because our tests patch BENCHMARK_CACHE through the old module, and that still works.

I verified the moved helpers against main and ran local QA around benchmark lookup, cache encoding, ranker regressions, full pytest, lint, format, compileall, and a CLI smoke run with --gpu "RTX 4060" --gpu-only --speed usable --json.

No issues found from my side. Thanks for doing this refactor, and sorry again for the slow review.

@Andyyyy64
Andyyyy64 merged commit 0a49590 into Andyyyy64:main Jul 8, 2026
4 checks passed
@RaghavRD

RaghavRD commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review and for running the extra QA @Andyyyy64. No worries on timing.

I’m glad the shim and cache monkeypatch path held up. I’ll sync with main and continue with the next #41 slice separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants