Skip to content

Commit b9897da

Browse files
committed
improve help text formatting
1 parent 6c68179 commit b9897da

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

bioimageio/core/cli.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""bioimageio CLI
2+
3+
Note: Some docstrings use a hair space ' '
4+
to place the added '(default: ...)' on a new line.
5+
"""
6+
17
import json
28
import shutil
39
import subprocess
@@ -22,12 +28,7 @@
2228
)
2329

2430
from loguru import logger
25-
from pydantic import (
26-
BaseModel,
27-
ConfigDict,
28-
TypeAdapter,
29-
model_validator,
30-
)
31+
from pydantic import BaseModel, model_validator
3132
from pydantic_settings import (
3233
BaseSettings,
3334
CliPositionalArg,
@@ -89,7 +90,8 @@ class ArgMixin(BaseModel, use_attribute_docstrings=True):
8990

9091
class WithSource(ArgMixin):
9192
source: CliPositionalArg[str]
92-
"""Url/path to a bioimageio.yaml/rdf.yaml file or a bioimage.io resource identifier, e.g. 'affable-shark'"""
93+
"""Url/path to a bioimageio.yaml/rdf.yaml file
94+
or a bioimage.io resource identifier, e.g. 'affable-shark'"""
9395

9496
@cached_property
9597
def descr(self):
@@ -223,8 +225,8 @@ class PredictCmd(CmdBase, WithSource):
223225
--inputs="[[\"a_raw.tif\",\"a_mask.tif\"],[\"b_raw.tif\",\"b_mask.tif\"]]"
224226
(Note that JSON double quotes need to be escaped.)
225227
226-
Alternatively a `bioimageio-cli.yaml` (or `bioimageio-cli.json`) file may provide
227-
the arguments, e.g.:
228+
Alternatively a `bioimageio-cli.yaml` (or `bioimageio-cli.json`) file
229+
may provide the arguments, e.g.:
228230
```yaml
229231
inputs:
230232
- [a_raw.tif, a_mask.tif]
@@ -235,6 +237,8 @@ class PredictCmd(CmdBase, WithSource):
235237
Aavailable formats are listed at
236238
https://imageio.readthedocs.io/en/stable/formats/index.html#all-formats.
237239
Some formats have additional dependencies.
240+
241+
238242
"""
239243

240244
outputs: Union[str, NotEmpty[Tuple[str, ...]]] = (
@@ -246,6 +250,8 @@ class PredictCmd(CmdBase, WithSource):
246250
- '{model_id}' (from model description)
247251
- '{output_id}' (from model description)
248252
- '{sample_id}' (extracted from input paths)
253+
254+
249255
"""
250256

251257
overwrite: bool = False
@@ -257,7 +263,8 @@ class PredictCmd(CmdBase, WithSource):
257263
stats: Path = Path("dataset_statistics.json")
258264
"""path to dataset statistics
259265
(will be written if it does not exist,
260-
but the model requires statistical dataset measures)"""
266+
but the model requires statistical dataset measures)
267+
 """
261268

262269
preview: bool = False
263270
"""preview which files would be processed
@@ -274,6 +281,8 @@ class PredictCmd(CmdBase, WithSource):
274281
3. writes input arguments to `{model_id}_example/bioimageio-cli.yaml`
275282
4. executes a preview dry-run
276283
5. executes prediction with example input
284+
285+
277286
"""
278287

279288
def _example(self):
@@ -305,7 +314,12 @@ def _example(self):
305314
stats_file = "dataset_statistics.json"
306315
stats = (example_path / stats_file).as_posix()
307316
yaml.dump(
308-
dict(inputs=inputs, outputs=output_pattern, stats=stats_file),
317+
dict(
318+
inputs=inputs,
319+
outputs=output_pattern,
320+
stats=stats_file,
321+
blockwise=self.blockwise,
322+
),
309323
bioimageio_cli_path,
310324
)
311325

@@ -324,6 +338,7 @@ def get_example_command(preview: bool, escape: bool = False):
324338
"predict",
325339
f"--preview={preview}", # update once we use implicit flags, see `class Bioimageio` below
326340
"--overwrite=True",
341+
f"--blockwise={self.blockwise}",
327342
f"--stats={q}{stats}{q}",
328343
f"--inputs={q}{inputs_escaped if escape else inputs_json}{q}",
329344
f"--outputs={q}{output_pattern}{q}",
@@ -346,7 +361,7 @@ def get_example_command(preview: bool, escape: bool = False):
346361
logger.debug("restored '{}'", YAML_FILE)
347362

348363
print(
349-
"🎉 Sucessfully ran example prediction!"
364+
"🎉 Sucessfully ran example prediction!\n"
350365
+ "To predict the example input using the CLI example config file"
351366
+ f" {example_path/YAML_FILE}, execute `bioimageio predict` from {example_path}:\n"
352367
+ f"$ cd {str(example_path)}\n"

0 commit comments

Comments
 (0)