fix: guard --epochs 0/negative with a guided error (#145)#146
Conversation
…back Fixes robocurve#145. Wraps the two replace(task, epochs=...) call sites in _cmd_run and _cmd_eval_set with a ConfigError catch, matching the existing _resolve_or_exit pattern. eval-set names the failing task.
|
Thanks for taking this on. I pulled the branch and ran the actual gates rather than going off the checklist. Note: locally, mypy fails, there's no CHANGELOG diff, and an existing test fails — the checklist marks those as done, so this likely just needs a re-run after the fixes below. mypy --strict fails Breaks test_cli_run_closes_embodiment_when_validation_raises No CHANGELOG entry Minor, not blocking One more ask: could you paste the before/after CLI output for run --epochs 0 and eval-set --epochs -1? Clearest confirmation it behaves as expected end to end. @jeqcho could you take a look when you have a moment? The approach looks right to me and I ran the gates locally to flag the above, but I'll leave the actual direction/merge call to you. |
|
|
Fixed all three. Retyped patched as list[Task] and dropped the stale type: ignore, updated the test to expect SystemExit with a message check, and added a CHANGELOG entry under Fixed matching #47's format. Full suite passes now - 728 passed, 2 skipped (unrelated, missing rerun-sdk), 100% coverage, mypy clean. |
jeqcho
left a comment
There was a problem hiding this comment.
Thanks Pavan, this is ready. A few things stood out beyond the fix itself.
The test coverage is thorough where it counts: parametrized over 0 and negatives at both call sites, asserting the flag name, the offending value, and the task name all show up in the message. Strengthening test_cli_run_closes_embodiment_when_validation_raises with a message assertion was a good catch too, since that test guards the embodiment-close invariant and was previously asserting the buggy behavior.
Also appreciated how you handled review: all three findings fixed within hours, with before/after CLI output pasted as proof, and a CHANGELOG entry matching the #47 format.
Merging. One cosmetic thing I'll fold into a follow-up rather than block on: --epochs: Epochs count must be >= 1, got 0 doubles up a bit; something like --epochs must be >= 1, got 0 reads cleaner. There is also an open idea to extract the two inline try/excepts into a shared helper next to _resolve_or_exit. If either interests you, they are yours.
|
Merged, thanks Pavan. The follow-ups from my review are now written up in #152 if you want a second one; it builds directly on what you landed here. Either way, glad to have you contributing. |
|
Thanks Jay, appreciate it. Will check out #152, that refactor idea sounds fun |
Summary
--epochs 0 (or negative) crashed with a raw Python traceback instead of a clean CLI error. Fixing that.
Changes
_cmd_run: wrapped the replace(task, epochs=...) call in try/except for ConfigError, exits clean instead of crashing
_cmd_eval_set: same fix, but had to turn the list comprehension into a loop so I could catch the error per task and say which one failed
Added 2 tests in test_registry_cli.py for both call sites (0, -1, -5)
Updated after review: retyped patched as list[Task] (dropped a stale type: ignore), updated an existing test to expect SystemExit instead of the raw error, added a CHANGELOG entry
Checklist
pre-commit installdone; hooks pass (or ranpre-commit run --all-files)CubePickmock exercises the change where applicable)pytest --cov)ruff check .andruff format --check .passmypypasses (strict)CHANGELOG.mdupdated under "Unreleased"inspect_robots.__all__and the API-snapshot testRelated
Closes #145