Skip to content

Fix boolean parsing for capture-onnx-graph options - #2647

Open
Sylvester Kaczmarek (sylvesterkaczmarek) wants to merge 2 commits into
microsoft:mainfrom
sylvesterkaczmarek:fix/capture-onnx-boolean-args
Open

Fix boolean parsing for capture-onnx-graph options#2647
Sylvester Kaczmarek (sylvesterkaczmarek) wants to merge 2 commits into
microsoft:mainfrom
sylvesterkaczmarek:fix/capture-onnx-boolean-args

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Describe your changes

Fixes boolean argument parsing for capture-onnx-graph.

The --exclude_embeds, --exclude_lm_head, and --enable_cuda_graph options used type=bool. With argparse, values such as false are non-empty strings and therefore evaluate to True.

The options now parse explicit true/false values correctly and reject invalid boolean input.

Regression tests cover true, false, and invalid values.

Checklist before requesting a review

  • Add unit tests for this change.
  • Make sure all tests can pass.
  • Update documents if necessary. No documentation change required.

Copilot AI lite review requested due to automatic review settings September 3, 2026 18:03
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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_bool argparse type that accepts common true/false string forms and rejects invalid values.
  • Updated --exclude_embeds, --exclude_lm_head, and --enable_cuda_graph to use type=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.

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.

2 participants