refactor(benchmark): split benchmark fetching and lookup modules (#41) - #143
Conversation
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
left a comment
There was a problem hiding this comment.
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.
|
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. |
Refs #41
What
Splits
src/whichllm/models/benchmark.pyinto focused modules:benchmark_cache.py— benchmark cache read/write helpersbenchmark_fetch.py— source fetching and layered merge policybenchmark_lineage.py— frozen-score lineage recency demotionbenchmark_index.py— score indices and model-line interpolationbenchmark_lookup.py— benchmark evidence lookup and inheritance rulesbenchmark_types.py— sharedBenchmarkEvidencedataclassbenchmark.py— compatibility shim / legacy import surfaceWhy
Per #41,
benchmark.pymixed 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 passeduv run pytest -q— 466 passed.venv/bin/ruff check .— all checks passed.venv/bin/ruff format --check .— 98 files already formattedNotes
Behavior-preserving refactor:
whichllm.models.benchmark