llmsql-benchmark icon indicating copy to clipboard operation
llmsql-benchmark copied to clipboard

[Evaluation] `evaluate()` always writes a randomly named report file into the working directory

Open DzmitryPihulski opened this issue 1 month ago • 2 comments

Problem

evaluate() always writes a JSON report, and when save_report is not given it uses a random name in the current directory (evaluation_results_<uuid>.json). Every call from a notebook, test or loop leaves a new file behind. The report contains every mismatch with the full model output, so for a full run it can be tens of MB.

Also, the SQLite connection is closed only at the end of the function, so it stays open if evaluation raises.

Proposal

  • In the Python API, write the report only when save_report is given (the dict is already returned). The CLI can keep writing a report by default, with a deterministic name derived from the outputs file (e.g. <outputs>.eval.json).
  • Optionally cap stored mismatches (e.g. max_saved_mismatches, default all, for backwards compatibility).
  • Open the connection with a context manager (contextlib.closing).
  • Tests: no file written when save_report=None.

DzmitryPihulski avatar Oct 05 '26 16:10 DzmitryPihulski

Hi! I’d like to work on this issue. I’ll investigate the root cause and work on a fix. Thank you!

Mounikaishu avatar Oct 08 '26 15:10 Mounikaishu

Taking this one — I'll put up a PR shortly.

Plan, following the proposal in the issue:

  • evaluate() writes the report only when save_report is given (the dict is already returned to the caller).
  • llmsql evaluate keeps writing a report by default, at a deterministic path derived from --outputs: <outputs>.eval.json.
  • The SQLite connection goes through contextlib.closing() so a raise inside evaluate_sample() can't leak it.
  • Tests: replace test_saves_report_with_auto_filename (which asserts the old behaviour) with one asserting no file is written, plus CLI tests pinning the default name.

I'm leaving out the optional max_saved_mismatches cap — it changes the report schema for existing consumers, so it seemed better as its own decision. Say the word if you'd rather have it here.

ddaihao2022 avatar Oct 11 '26 15:10 ddaihao2022