refactor(cli): unify -m/--model option across all commands#990
Open
xieofxie wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@
Summary
Unifies the
-m/--modeloption across every command insrc/winml/modelkit/commands/by routing them all through the sharedmodel_option/model_path_optionhelpers inutils/cli.py, instead of ad-hoc inlineclick.optiondefinitions. 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 ONNXPath) — addedmultipleandhelp_textparameters.model_option(any model reference, no validation) — addedmultipleandhelp_textparameters.Commands converted from inline
click.optionto the shared helperscompilemodel_path_option(required=False, multiple=True, help_text=…)optimizemodel_path_option(required=False, help_text=…)quantizemodel_path_option(required=True, help_text=…)exportmodel_option(required=True, help_text=…)evalmodel_option(required=False, multiple=True, help_text=…)buildmodel_option(required=False, help_text=…)inspectmodel_option(required=False, help_text=…)(
analyze,run,serve,perf,configalready used the helpers.)Destination standardized to
model—buildandinspectpreviously bound--modeltomodel_id; the CLI binding is nowmodel. 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 flexibleTEXT),requiredsemantics,multiple, and help wording.@