Repository navigation
fix(eval): don't drop a random-named report file in the CWD - #141
Open
ddaihao2022 wants to merge 1 commit into
Open
ddaihao2022 wants to merge 1 commit into
ddaihao2022 wants to merge 1 commit into
Conversation
Closes LLMSQL#128 `evaluate()` called `save_json_report()` unconditionally. When `save_report` was None it generated `evaluation_results_<uuid>.json`, so every call from a notebook, a test or a loop left a new file behind in the working directory — and the report embeds every mismatch with the full model output, so a full run can be tens of MB. The repo even had a session fixture that sweeps `evaluation_results*` out of the CWD after the test session. Changes: * `evaluate()` writes the file only when `save_report` is given. The report dict was already returned to the caller, so nothing is lost for API users. * `llmsql evaluate` still produces a report by default (a one-shot CLI run should leave one behind), but at a deterministic path derived from `--outputs`: `<outputs>.eval.json`. Re-running on the same predictions overwrites the previous report instead of piling up new ones. * The SQLite connection now goes through `contextlib.closing()` around the evaluation loop. It used to be closed only by a bare `conn.close()` at the end of the function, so any exception raised by `evaluate_sample()` leaked it. * Dropped the now-unused `uuid` import and updated `evaluation/README.md`, which documented the old default filename. Tests: * `test_no_report_file_is_written_when_save_report_is_none` replaces the old `test_saves_report_with_auto_filename`, which asserted the exact behaviour the issue asks us to remove. * `test_report_is_written_to_the_given_path` keeps the `save_report=<path>` path covered. * Two CLI tests pin the default `<outputs>.eval.json` name and check that an explicit `--save-report` is passed through untouched.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #128
evaluate()calledsave_json_report()unconditionally. Whensave_reportwasNoneit generatedevaluation_results_<uuid>.json, so every call from a notebook, a test or a loop left a new file behind in the working directory — and the report embeds every mismatch with the full model output, so a full run can be tens of MB. (tests/conftest.pyalready had a session fixture sweepingevaluation_results*out of the CWD, which is a good sign this was biting in practice.)Changes
llmsql/evaluation/evaluate.py— write the file only whensave_reportis given. The report dict is already returned to the caller, so API users lose nothing. Also dropped the now-unuseduuidimport.llmsql/_cli/evaluate.py— the CLI still writes a report by default (a one-shot CLI run should leave one behind), but at a deterministic path derived from--outputs:<outputs>.eval.json. Re-running on the same predictions overwrites the previous report instead of piling up new ones, and--save-reportstill wins when given.llmsql/evaluation/evaluate.py— the SQLite connection now goes throughcontextlib.closing()around the evaluation loop. It used to be closed by a bareconn.close()at the very end of the function, so any exception raised byevaluate_sample()leaked the connection (also mentioned in the issue).llmsql/evaluation/README.md— updated the two places that documented the oldevaluation_results_{uuid}.jsondefault.Not done (marked optionally in the issue): capping stored mismatches via
max_saved_mismatches. That changes the report schema for anyone parsing it today, so it felt like a separate decision — happy to add it if you want it in this PR.Tests
test_no_report_file_is_written_when_save_report_is_nonereplacestest_saves_report_with_auto_filename, which asserted exactly the behaviour this issue asks us to remove.test_report_is_written_to_the_given_pathkeeps thesave_report=<path>path covered.tests/cli/test_cli.py: two new tests pin the default<outputs>.eval.jsonname and check that an explicit--save-reportis passed through untouched.Verification
Local (Windows, no GPU):
tests/evaluation: 24 passed before, still green with the new/updated tests (25 passed).tests/cli: the 5 new/updated report tests pass. 4 pre-existing failures intests/cli/test_cli.py/tests/cli/test_model_args.pyare unrelated — they needtransformers, which isn't installed here.evaluate.py/_cli/evaluate.pymakestest_no_report_file_is_written_when_save_report_is_noneandtest_evaluate_default_report_path_is_deterministicfail, so the new tests really pin the fix.tests/inference/*and the vLLM/GPU-marked suites (multi-GB wheels + GPU).