Fix boolean parsing for capture-onnx-graph options - #2647
Fix boolean parsing for capture-onnx-graph options#2647Sylvester Kaczmarek (sylvesterkaczmarek) wants to merge 3 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟢 Approval recommended
The change correctly addresses argparse boolean parsing semantics and is covered by targeted regression tests for valid and invalid inputs.
Pull request overview
This pull request fixes incorrect boolean parsing for the capture-onnx-graph CLI subcommand by replacing type=bool (which treats any non-empty string as True) with an explicit boolean parser, and adds regression tests to validate accepted/invalid values.
Changes:
- Added a
parse_boolargparse type that accepts common true/false string forms and rejects invalid values. - Updated
--exclude_embeds,--exclude_lm_head, and--enable_cuda_graphto usetype=parse_bool. - Added unit tests covering true/false variants and invalid input rejection.
File summaries
| File | Description |
|---|---|
olive/cli/capture_onnx.py |
Introduces parse_bool and wires it into capture-onnx-graph boolean options to ensure correct CLI parsing. |
test/cli/test_capture_onnx_args.py |
Adds regression tests verifying boolean parsing behavior and invalid value handling. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
|
Addressed the review: replaced the explicit parser with argparse |
|
shaahji The current head uses |
Describe your changes
Fixes boolean argument parsing for
capture-onnx-graph.The
--exclude_embeds,--exclude_lm_head, and--enable_cuda_graphoptions usedtype=bool. With argparse, values such asfalseare non-empty strings and therefore evaluate toTrue.These options now use argparse's standard
store_trueflag semantics: absence leaves the option disabled (orNoneforenable_cuda_graph, preserving its existing tri-state default), while presence enables it.Regression tests cover both default and enabled states.
Checklist before requesting a review
ruffand direct parser smoke test).