|
32 | 32 |
|
33 | 33 | import rich.markdown |
34 | 34 | from loguru import logger |
35 | | -from pydantic import BaseModel, Field, model_validator |
| 35 | +from pydantic import AliasChoices, BaseModel, Field, model_validator |
36 | 36 | from pydantic_settings import ( |
37 | 37 | BaseSettings, |
38 | 38 | CliPositionalArg, |
|
82 | 82 | from .utils import VERSION, compare |
83 | 83 | from .weight_converters._add_weights import add_weights |
84 | 84 |
|
| 85 | +WEIGHT_FORMAT_ALIASES = AliasChoices( |
| 86 | + "weight-format", |
| 87 | + "weights-format", |
| 88 | +) |
| 89 | + |
85 | 90 |
|
86 | 91 | class CmdBase(BaseModel, use_attribute_docstrings=True, cli_implicit_flags=True): |
87 | 92 | pass |
@@ -154,7 +159,11 @@ def run(self): |
154 | 159 | class TestCmd(CmdBase, WithSource, WithSummaryLogging): |
155 | 160 | """Test a bioimageio resource (beyond meta data formatting).""" |
156 | 161 |
|
157 | | - weight_format: WeightFormatArgAll = "all" |
| 162 | + weight_format: WeightFormatArgAll = Field( |
| 163 | + "all", |
| 164 | + alias="weight-format", |
| 165 | + validation_alias=WEIGHT_FORMAT_ALIASES, |
| 166 | + ) |
158 | 167 | """The weight format to limit testing to. |
159 | 168 |
|
160 | 169 | (only relevant for model resources)""" |
@@ -197,7 +206,11 @@ class PackageCmd(CmdBase, WithSource, WithSummaryLogging): |
197 | 206 | If it does not have a `.zip` suffix |
198 | 207 | this command will save the package as an unzipped folder instead.""" |
199 | 208 |
|
200 | | - weight_format: WeightFormatArgAll = "all" |
| 209 | + weight_format: WeightFormatArgAll = Field( |
| 210 | + "all", |
| 211 | + alias="weight-format", |
| 212 | + validation_alias=WEIGHT_FORMAT_ALIASES, |
| 213 | + ) |
201 | 214 | """The weight format to include in the package (for model descriptions only).""" |
202 | 215 |
|
203 | 216 | def run(self): |
@@ -406,7 +419,11 @@ class PredictCmd(CmdBase, WithSource): |
406 | 419 | """preview which files would be processed |
407 | 420 | and what outputs would be generated.""" |
408 | 421 |
|
409 | | - weight_format: WeightFormatArgAny = "any" |
| 422 | + weight_format: WeightFormatArgAny = Field( |
| 423 | + "any", |
| 424 | + alias="weight-format", |
| 425 | + validation_alias=WEIGHT_FORMAT_ALIASES, |
| 426 | + ) |
410 | 427 | """The weight format to use.""" |
411 | 428 |
|
412 | 429 | example: bool = False |
|
0 commit comments