Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less verbose cli errors #77

Merged

Conversation

jeremyfowers
Copy link
Collaborator

Closes #76 by printing only usage and a hint, instead of the full help page, on CLI arg errors.

Demos

(tkml) jefowers@XSJ-JEFOWERS-L1:~/turnkeyml/models/selftest$ turnkey cache stats --blah
error: the following arguments are required: build_name

Run 'turnkey cache stats --help' for more information

usage: turnkey cache stats [-h] [-d CACHE_DIR] build_name
(tkml) jefowers@XSJ-JEFOWERS-L1:~/turnkeyml/models/selftest$ turnkey cache blah
error: argument cache_cmd: invalid choice: 'blah' (choose from 'report', 'list', 'stats', 'delete', 'clean', 'location')

Run 'turnkey cache --help' for more information

usage: turnkey cache [-h] {report,list,stats,delete,clean,location} ...
(tkml) jefowers@XSJ-JEFOWERS-L1:~/turnkeyml/models/selftest$ turnkey golboddy  report
error: argument COMMAND: invalid choice: 'golboddy' (choose from 'benchmark', 'cache', 'models', 'version')

Run 'turnkey --help' for more information

usage: turnkey [-h] COMMAND ...
(tkml) jefowers@XSJ-JEFOWERS-L1:~/turnkeyml/models/selftest$ turnkey bob.po
error: input_files must end with .py, .onnx, or .txt (got 'bob.po')

Run 'turnkey benchmark --help' for more information

usage: turnkey benchmark [-h] [-a] [-b] [--labels [LABELS [LABELS ...]]]
                         [--script-args SCRIPT_ARGS] [--max-depth MAX_DEPTH]
                         [--device {nvidia,x86}]
                         [--runtime {ort,trt,torch-eager,torch-compiled}]
                         [-d CACHE_DIR] [--lean-cache]
                         [--sequence {optimize-fp16,optimize-fp32,onnx-fp32}]
                         [--rebuild {if_needed,always,never}]
                         [--onnx-opset ONNX_OPSET] [--iterations ITERATIONS]
                         [--rt-args [RT_ARGS [RT_ARGS ...]]]
                         [--use-slurm | --process-isolation]
                         [--timeout TIMEOUT]
                         input_files [input_files ...]

@jeremyfowers jeremyfowers self-assigned this Dec 18, 2023
@jeremyfowers jeremyfowers linked an issue Dec 18, 2023 that may be closed by this pull request
Signed-off-by: Jeremy <jeremy.fowers@amd.com>
@jeremyfowers jeremyfowers force-pushed the 76-print-a-shorter-cli-message-on-argparse-errors branch from 93875ee to 345f4a6 Compare December 18, 2023 19:46
@jeremyfowers jeremyfowers marked this pull request as ready for review December 18, 2023 19:47
@jeremyfowers jeremyfowers enabled auto-merge (squash) December 18, 2023 19:47
Copy link
Collaborator

@danielholanda danielholanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. Thanks!

@jeremyfowers jeremyfowers merged commit a52414c into main Dec 18, 2023
10 checks passed
@jeremyfowers jeremyfowers deleted the 76-print-a-shorter-cli-message-on-argparse-errors branch December 18, 2023 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Print a shorter CLI message on argparse errors
2 participants