Skip to content

Commit f4efbaa

Browse files
committed
update CLI
1 parent fe993d0 commit f4efbaa

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

bioimageio/core/cli.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
import shutil
99
import subprocess
1010
import sys
11-
import zipfile
1211
from argparse import RawTextHelpFormatter
1312
from difflib import SequenceMatcher
1413
from functools import cached_property
15-
from pathlib import Path, PurePosixPath
14+
from pathlib import Path
1615
from pprint import pformat, pprint
1716
from typing import (
1817
Any,
@@ -29,7 +28,7 @@
2928
)
3029

3130
from loguru import logger
32-
from pydantic import BaseModel, model_validator
31+
from pydantic import BaseModel, Field, model_validator
3332
from pydantic_settings import (
3433
BaseSettings,
3534
CliPositionalArg,
@@ -114,14 +113,14 @@ def descr_id(self) -> str:
114113

115114

116115
class ValidateFormatCmd(CmdBase, WithSource):
117-
"""bioimageio-validate-format - validate the meta data format of a bioimageio resource."""
116+
"""validate the meta data format of a bioimageio resource."""
118117

119118
def run(self):
120119
validate_format(self.descr)
121120

122121

123122
class TestCmd(CmdBase, WithSource):
124-
"""bioimageio-test - Test a bioimageio resource (beyond meta data formatting)"""
123+
"""Test a bioimageio resource (beyond meta data formatting)"""
125124

126125
weight_format: WeightFormatArgAll = "all"
127126
"""The weight format to limit testing to.
@@ -144,7 +143,7 @@ def run(self):
144143

145144

146145
class PackageCmd(CmdBase, WithSource):
147-
"""bioimageio-package - save a resource's metadata with its associated files."""
146+
"""save a resource's metadata with its associated files."""
148147

149148
path: CliPositionalArg[Path]
150149
"""The path to write the (zipped) package to.
@@ -201,7 +200,7 @@ def _get_stat(
201200

202201

203202
class PredictCmd(CmdBase, WithSource):
204-
"""bioimageio-predict - Run inference on your data with a bioimage.io model."""
203+
"""Run inference on your data with a bioimage.io model."""
205204

206205
inputs: NotEmpty[Sequence[Union[str, NotEmpty[Tuple[str, ...]]]]] = (
207206
"{input_id}/001.tif",
@@ -547,22 +546,20 @@ def input_dataset(stat: Stat):
547546

548547
class Bioimageio(
549548
BaseSettings,
550-
# alias_generator=AliasGenerator(
551-
# validation_alias=lambda s: AliasChoices(s, to_snake(s).replace("_", "-"))
552-
# ),
553-
# TODO: investigate how to allow a validation alias for subcommands
554-
# ('validate-format' vs 'validate_format')
555549
cli_parse_args=True,
556550
cli_prog_name="bioimageio",
557551
cli_use_class_docs_for_groups=True,
558-
# cli_implicit_flags=True, # TODO: make flags implicit, see https://github.com/pydantic/pydantic-settings/issues/361
552+
cli_implicit_flags=True,
559553
use_attribute_docstrings=True,
560554
):
561555
"""bioimageio - CLI for bioimage.io resources 🦒"""
562556

563-
model_config = SettingsConfigDict(json_file=JSON_FILE, yaml_file=YAML_FILE)
557+
model_config = SettingsConfigDict(
558+
json_file=JSON_FILE,
559+
yaml_file=YAML_FILE,
560+
)
564561

565-
validate_format: CliSubCommand[ValidateFormatCmd]
562+
validate_format: CliSubCommand[ValidateFormatCmd] = Field(alias="validate-format")
566563
"Check a resource's metadata format"
567564

568565
test: CliSubCommand[TestCmd]

0 commit comments

Comments
 (0)