Skip to content

refactor(cli): unify -m/--model option across all commands#990

Merged
xieofxie merged 2 commits into
mainfrom
hualxie/unify_model_flag
Jun 30, 2026
Merged

refactor(cli): unify -m/--model option across all commands#990
xieofxie merged 2 commits into
mainfrom
hualxie/unify_model_flag

Conversation

@xieofxie

Copy link
Copy Markdown
Contributor

@

Summary

Unifies the -m/--model option across every command in src/winml/modelkit/commands/ by routing them all through the shared model_option / model_path_option helpers in utils/cli.py, instead of ad-hoc inline click.option definitions. The flag spelling, ordering, type, and validation now have a single source of truth.

Closes #563.

Changes

Helpers (utils/cli.py)

  • model_path_option (validated ONNX Path) — added multiple and help_text parameters.
  • model_option (any model reference, no validation) — added multiple and help_text parameters.

Commands converted from inline click.option to the shared helpers

Command Now uses
compile model_path_option(required=False, multiple=True, help_text=…)
optimize model_path_option(required=False, help_text=…)
quantize model_path_option(required=True, help_text=…)
export model_option(required=True, help_text=…)
eval model_option(required=False, multiple=True, help_text=…)
build model_option(required=False, help_text=…)
inspect model_option(required=False, help_text=…)

(analyze, run, serve, perf, config already used the helpers.)

Destination standardized to modelbuild and inspect previously bound --model to model_id; the CLI binding is now model. Downstream keyword args that are genuinely the domain concept (e.g. WinMLQuantizationConfig.model_id) are unchanged.

This is purely structural — each command keeps its existing accept-types (PATH-validated vs flexible TEXT), required semantics, multiple, and help wording.
@

Route every command's -m/--model through the shared model_option /
model_path_option helpers instead of inline click.option definitions, so
the flag spelling, ordering, type, and validation have a single source of
truth. Extend both helpers with multiple/help_text parameters and
standardize the destination variable to model (build and inspect previously
bound to model_id).

No behavior change: each command keeps its existing accept-types,
required semantics, and help wording.
@xieofxie xieofxie requested a review from a team as a code owner June 26, 2026 08:57

@DingmaomaoBJTU DingmaomaoBJTU left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This PR cleanly consolidates the -m/--model option across 7 command files into two shared helpers. All 410 relevant unit/CLI/regression tests pass.

Overall: Refactoring is behaviorally equivalent and well-documented. One nit on missing type=str for the multiple=True path (see inline).

Comment thread src/winml/modelkit/utils/cli.py
Comment thread src/winml/modelkit/utils/cli.py
@xieofxie xieofxie merged commit 992a410 into main Jun 30, 2026
9 checks passed
@xieofxie xieofxie deleted the hualxie/unify_model_flag branch June 30, 2026 07:05
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.

[cross-cutting] [P2] --model semantic drift across 10 commands

2 participants