88import shutil
99import subprocess
1010import sys
11- import zipfile
1211from argparse import RawTextHelpFormatter
1312from difflib import SequenceMatcher
1413from functools import cached_property
15- from pathlib import Path , PurePosixPath
14+ from pathlib import Path
1615from pprint import pformat , pprint
1716from typing import (
1817 Any ,
2928)
3029
3130from loguru import logger
32- from pydantic import BaseModel , model_validator
31+ from pydantic import BaseModel , Field , model_validator
3332from pydantic_settings import (
3433 BaseSettings ,
3534 CliPositionalArg ,
@@ -114,14 +113,14 @@ def descr_id(self) -> str:
114113
115114
116115class 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
123122class 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
146145class 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
203202class 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
548547class 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