Skip to content

Commit 26ff7d4

Browse files
Sravan1011claude
andcommitted
Fix broken indent from suggested change; address Copilot findings
- Restore indentation of the lazy moss import inside the moss_client fixture (auto-applied suggestion dedented it, breaking collection) - Fail fast when a benchmark query has no ground-truth entry instead of silently shrinking the evaluated set and inflating recall - Create parent directories for --benchmark-output before writing - Correct --recall-threshold help text (guard compares recall@5) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 196d2f8 commit 26ff7d4

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

benchmarks/ci/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ def pytest_addoption(parser: pytest.Parser) -> None:
3131
"--recall-threshold",
3232
type=float,
3333
default=0.05,
34-
help="Max allowed absolute decrease in recall@k vs baseline "
34+
help="Max allowed absolute decrease in recall@5 vs baseline "
3535
"(default: 0.05 = 5 percentage points)",
3636
)

benchmarks/ci/test_bench_ci_moss.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def _git_sha() -> str:
103103
def moss_client():
104104
"""Create a MossClient and load the benchmark index once per session."""
105105
# Import lazily — Moss native bindings may not be installed in every env.
106-
from moss import MossClient, DocumentInfo
106+
from moss import MossClient, DocumentInfo
107107

108108
project_id = os.getenv("MOSS_PROJECT_ID")
109109
project_key = os.getenv("MOSS_PROJECT_KEY")
@@ -243,9 +243,14 @@ def test_recall(self, moss_client, ground_truth, benchmark_results):
243243

244244
async def _evaluate():
245245
for q in QUERIES:
246-
expected_ids = ground_truth.get(q, [])
246+
expected_ids = ground_truth.get(q)
247247
if not expected_ids:
248-
continue
248+
# Silently skipping would shrink the evaluated set and
249+
# inflate recall — fail loudly instead.
250+
raise AssertionError(
251+
f"Ground truth missing results for query {q!r}; "
252+
"regenerate benchmarks/ci/ground_truth.json"
253+
)
249254

250255
# recall@10 — fetch 10 results, also compute recall@5
251256
result = await client.query(
@@ -356,7 +361,8 @@ class TestWriteResults:
356361
"""Serialize benchmark results to JSON (always runs last)."""
357362

358363
def test_write_results(self, request, benchmark_results):
359-
output_path = request.config.getoption("--benchmark-output")
364+
output_path = Path(request.config.getoption("--benchmark-output"))
365+
output_path.parent.mkdir(parents=True, exist_ok=True)
360366
with open(output_path, "w") as f:
361367
json.dump(benchmark_results, f, indent=2)
362368
print(f"\n Results written to: {output_path}")

0 commit comments

Comments
 (0)