Repository navigation
fix(eval): reject table columns that have no computed value - #660
BarsamErshadi wants to merge 3 commits into
Conversation
_get_metrics_dict returned 0 for any column it could not find in a computed metric family, and _format_value rendered that as a score. `trackers eval --columns '[MOTA,HOTA,IDF1]'` without --metrics computes only CLEAR, so it printed HOTA and IDF1 as 0.000 and exited 0, and a typo such as MOTa printed 0. Neither could be told apart from a real zero. Raise ValueError naming the column instead. eval_command already catches ValueError around table(), so the CLI prints the error and returns 1. It calls table() before saving, so --output is not written on that error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change to reject unavailable evaluation columns instead of displaying misleading zero scores.
No open issues 🎉
What changed in this PR
This PR prevents evaluation tables from presenting uncomputed metrics or misspelled column names as zero scores.
Changes:
- Raise
ValueErrornaming the unavailable column and document the exception. - Add regression tests for table validation, valid metric rendering, and CLI failures without JSON output.
- Document the behavior change and migration guidance in the changelog.
| File | Description |
|---|---|
tests/eval/test_evaluate.py |
Tests invalid columns, computed values, and CLI error handling. |
src/trackers/eval/results.py |
Replaces zero fallback with an explicit error and documents it. |
CHANGELOG.md |
Explains the change and how affected commands should be updated. |
Review effort: Balanced
|
Hello, thank you for the contribution and the detailed repro! The trade-offs you list in Additional Context are what I'd like to avoid though, with the error, one wrong column makes the whole command fail, the skipped = [col for col in columns if col not in available]
if skipped:
warnings.warn(f"Skipping columns with no computed value: {', '.join(skipped)}. ...", UserWarning, stacklevel=3)
columns = [col for col in columns if col in available] or availablewhere What are your thoughts? For the tests, a single parametrized test is enough, with two cases: We should also define the behaviour when all are skipped. We can either fallback to the default table, like no parameters were passed or return an empty table, which is impractical, but shows your error more clearly. For this, A second small test can check that |
What does this PR do?
SequenceResult.table(columns=...),BenchmarkResult.table(columns=...)andtrackers eval --columnsprinted a score of zero for any column that had no computed value. That covers a metric family that was not requested as well as a misspelled name.--metricsdefaults to CLEAR only, so--columns '[MOTA,HOTA,IDF1]'without--metricsis an easy command to run. It showed HOTA and IDF1 as0.000and exited 0, even though neither was computed. The cause is the finalreturn 0in_get_metrics_dict. I replaced it with aValueErrorthat names the column.Related Issue(s): None. I found no open issue or PR for this. Open PR #556 touches the table helpers in the same file, but not these lines (see Additional Context).
Type of Change
It does change behaviour for anyone relying on the zero fill (see Additional Context).
Testing
Test details:
I added
TestTableColumnstotests/eval/test_evaluate.py. It covers:eval_commandin single-sequence and benchmark mode: it returns 1, printsError: ..., prints no table and writes no--outputfileOn unfixed code, 7 of the 8 tests failed, with
DID NOT RAISE ValueErrorfor the table tests andassert 0 == 1for the CLI tests. The 8th test guards existing behaviour and passed both before and after. With the fix, all 8 pass.Minimal repro (
g.txtandt.txtare the same two-row file,1,1,0,0,10,10,1,1,1and2,1,0,0,10,10,1,1,1):Before:
After:
Requesting the families gives the same output before and after:
I ran these through
python -m trackers.cli, not the installedtrackersscript. Therc=lines come from my shell loop.Results:
-W ignore, so it does not show warnings:2 failed, 2092 passed, 5 skipped. Neither failure comes from this change:test_real_reid_model_runs_over_framesfails withModuleNotFoundError: No module named 'reid', and fails the same way without my change. That package is missing from my environment.test_tracker_regression[dancetrack-dancetrack_flat_data-bytetrack]failed once withInvalid MOT formatwhile reading a file from the shared test cache in~/.cache/trackers-test, then passed on rerun both with and without my change. Other test runs were active on this machine at the time, so I suspect a concurrent write to the cache, but I did not confirm that.pre-commit run --fileson the changed files, not--all-files.table()(nocolumns) for all 7 combinations of metric families. This covered sequence and benchmark results, and results reloaded from JSON. None of them raised. This was a one-off script and is not in the test suite.Checklist
The documentation change is a
Raises:entry on the twotable()methods and on_get_metrics_dict. The doc pages did not need changing: every--columnsexample inREADME.mdanddocs/already passes the matching--metrics.Additional Context
Some behaviour changes and trade-offs for you to judge:
table(columns=...)call ortrackers eval --columnscommand with a column that has no value used to succeed. It now raises, or exits 1 on the CLI.--outputis no longer written when--columnsis bad.eval_commandcallstable()before saving, so the error happens first. Before this change, the JSON was saved. The evaluation has already run by then, so a typo in--columnson a long benchmark throws away that work, and the error only appears at the end. I did not measure the cost on a real benchmark. I kept this PR small and did not move the save or check the columns up front. Either would be a reasonable follow-up if you prefer it.--columns=[MOTa,IDSw]namesMOTaonly, so a user with two bad columns finds the second on the next run._format_sequence_tableand_format_benchmark_tableinresults.py, but it keeps calling_get_metrics_dictand does not change itsreturn 0. It may still need a rebase because the changes are close together. I read its diff but did not test the two together.