Skip to content

Commit 014bc92

Browse files
committed
rename CLI argument weight_format -> weight-format (also accept weights-format)
1 parent e16a9ca commit 014bc92

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

bioimageio/core/cli.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
import rich.markdown
3434
from loguru import logger
35-
from pydantic import BaseModel, Field, model_validator
35+
from pydantic import AliasChoices, BaseModel, Field, model_validator
3636
from pydantic_settings import (
3737
BaseSettings,
3838
CliPositionalArg,
@@ -82,6 +82,11 @@
8282
from .utils import VERSION, compare
8383
from .weight_converters._add_weights import add_weights
8484

85+
WEIGHT_FORMAT_ALIASES = AliasChoices(
86+
"weight-format",
87+
"weights-format",
88+
)
89+
8590

8691
class CmdBase(BaseModel, use_attribute_docstrings=True, cli_implicit_flags=True):
8792
pass
@@ -154,7 +159,11 @@ def run(self):
154159
class TestCmd(CmdBase, WithSource, WithSummaryLogging):
155160
"""Test a bioimageio resource (beyond meta data formatting)."""
156161

157-
weight_format: WeightFormatArgAll = "all"
162+
weight_format: WeightFormatArgAll = Field(
163+
"all",
164+
alias="weight-format",
165+
validation_alias=WEIGHT_FORMAT_ALIASES,
166+
)
158167
"""The weight format to limit testing to.
159168
160169
(only relevant for model resources)"""
@@ -197,7 +206,11 @@ class PackageCmd(CmdBase, WithSource, WithSummaryLogging):
197206
If it does not have a `.zip` suffix
198207
this command will save the package as an unzipped folder instead."""
199208

200-
weight_format: WeightFormatArgAll = "all"
209+
weight_format: WeightFormatArgAll = Field(
210+
"all",
211+
alias="weight-format",
212+
validation_alias=WEIGHT_FORMAT_ALIASES,
213+
)
201214
"""The weight format to include in the package (for model descriptions only)."""
202215

203216
def run(self):
@@ -406,7 +419,11 @@ class PredictCmd(CmdBase, WithSource):
406419
"""preview which files would be processed
407420
and what outputs would be generated."""
408421

409-
weight_format: WeightFormatArgAny = "any"
422+
weight_format: WeightFormatArgAny = Field(
423+
"any",
424+
alias="weight-format",
425+
validation_alias=WEIGHT_FORMAT_ALIASES,
426+
)
410427
"""The weight format to use."""
411428

412429
example: bool = False

0 commit comments

Comments
 (0)