[Evaluation] `evaluate()` always writes a randomly named report file into the working directory
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_reportis 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.
Hi! I’d like to work on this issue. I’ll investigate the root cause and work on a fix. Thank you!
Taking this one — I'll put up a PR shortly.
Plan, following the proposal in the issue:
evaluate()writes the report only whensave_reportis given (the dict is already returned to the caller).llmsql evaluatekeeps 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 insideevaluate_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.