Skip to content

fix: reject batch_size < 1 and handle empty-query benchmarks - #26

Merged
royalpinto007 merged 1 commit into
AgentPostmortem:mainfrom
HarshRajSinghania:fix/ingest-batch-size-and-empty-benchmark
Sep 22, 2026
Merged

royalpinto007 merged 1 commit into
AgentPostmortem:mainfrom
HarshRajSinghania:fix/ingest-batch-size-and-empty-benchmark

Conversation

@HarshRajSinghania

Copy link
Copy Markdown
Contributor

Summary

Validate ingest batch size and return empty-mode results for a zero-query benchmark instead of crashing.

Fixes #22 and #23.

Motivation

ingest_documents(..., batch_size=0) forwarded a zero step into range(), which raised ValueError: range() arg 3 must not be zero.
run_benchmark divided by len(r5) even when the dataset had no queries, which raised ZeroDivisionError.

Both were labeled good first issue / help wanted, were unassigned, and had no open PR.

Implementation

  • ingest_documents raises ValueError("batch_size must be >= 1") before batching.
  • batched() uses the same guard so other callers cannot hit the raw range() error.
  • run_benchmark treats an empty query list as recall 0.0 / qps 0.0 and still returns a ModeResult per requested mode (n_queries=0).

Testing

Installed pytest, qdrant-client, and prometheus-client in an isolated environment (full pip install -e .[dev] failed on a hatchling index 502).

PYTHONPATH=src python3 -m pytest tests/test_ingest.py tests/test_benchmark.py::test_run_benchmark_empty_queries_returns_empty_modes tests/test_benchmark.py::test_percentile_and_recall_helpers -q

Result: 6 passed.

Not run: full suite (test_search.py / test_benchmark_produces_numbers) because those need the project's FastEmbed optional stack and a longer install that was blocked here.

Notes

No public API shape change besides the new validation error message requested in #22.

@royalpinto007
royalpinto007 merged commit d643222 into AgentPostmortem:main Sep 22, 2026
1 check passed
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.

ingest_documents(batch_size=0) dies with raw range() error

2 participants