fix(cli): guided error for --epochs 0/negative instead of raw traceback#148
fix(cli): guided error for --epochs 0/negative instead of raw traceback#148ptlnextdoor wants to merge 1 commit into
Conversation
replace(task, epochs=...) reruns Task.__post_init__, which raises ConfigError for a count below 1. Neither _cmd_run nor _cmd_eval_set caught it, so the CLI's only unvalidated flag path crashed with a raw traceback instead of the guided SystemExit every other invalid input gets (same bug class fixed for config kwargs in robocurve#47). Adds _apply_epochs_or_exit, used by both call sites, mirroring the _resolve_or_exit pattern already used for registry resolution errors. Fixes robocurve#145
|
Thanks for this ptlnextdoor, and sorry for the awkward outcome: #146 was opened a day earlier by the contributor who had claimed #145 in the issue thread, so it got priority and just merged. Closing this one as a duplicate. That said, your PR got real things right that the merged one didn't. I opened #152 to bring exactly those pieces into main, and your branch is most of the way there already. If you want to send it, it's yours; comment on #152 to claim it. Hope to see more from you either way. |
Summary
--epochs 0(or negative) crashes bothrunandeval-setwith a raw traceback instead of the guidedSystemExitevery other invalid CLI input gets.replace(task, epochs=...)rerunsTask.__post_init__, which raisesConfigErrorwhen the count is below 1. Neither_cmd_runnor_cmd_eval_setcaught it — same bug class already fixed for config-file kwargs in #47.Changes
_apply_epochs_or_exit, mirroring the existing_resolve_or_exitpattern: catchesConfigErrorand re-raises asSystemExit(str(exc))._cmd_run,_cmd_eval_set) now go through it instead of a baredataclasses.replace.replaceimports in both functions.test_cli_run_closes_embodiment_when_validation_raises(was asserting the rawConfigErrorleaked, which was the bug) and addstest_cli_eval_set_negative_epochs_is_a_guided_errorfor theeval-setpath, which had no coverage before.Test plan
uv run ruff check .uv run ruff format --check .uv run mypy(strict)uv run pytest --cov— 724 passed, 100% line+branch coverageuv run pre-commit run --all-filesinspect-robots run --task cubepick-reach --policy scripted --embodiment cubepick --epochs 0now exits with the guided message instead of a tracebackFixes #145