emmi_inference.cli_utils¶
Exceptions¶
Aggregate exception for parallel/async tasks. |
Functions¶
|
Expand, resolve, and ensure a directory exists. |
|
Format a byte count into a human-readable string. |
|
Run a CLI task and translate exceptions into user-friendly output. |
Module Contents¶
- exception emmi_inference.cli_utils.ParallelErrors(errors)¶
Bases:
ExceptionAggregate exception for parallel/async tasks.
Used to collect multiple failures and surface them together in CLI flows.
- Parameters:
errors (list[tuple[Any, BaseException]])
- errors¶
A list of (input, exception) tuples for each failed item.
Initialize self. See help(type(self)) for accurate signature.
- errors¶
- emmi_inference.cli_utils.resolve_dir(path)¶
Expand, resolve, and ensure a directory exists.
This is a convenience for CLI arguments pointing to output folders.
- Parameters:
path (pathlib.Path) – A file-system path that may include ~ and relative segments.
- Returns:
The absolute, expanded Path. The directory is created if missing.
- Return type:
- emmi_inference.cli_utils.fmt_bytes(num)¶
Format a byte count into a human-readable string.
Examples
>>> fmt_bytes(1536) '1.50 KB'
- emmi_inference.cli_utils.run_cli(fn)¶
Run a CLI task and translate exceptions into user-friendly output.
- Behavior:
Executes fn().
If a
ParallelErrorsis raised, prints each failed input and exits with code 1 (without an exception traceback).Re-raises typer.Exit to respect early exits.
Any other exception is rendered as a single red error line and the process exits with code 1.
- Parameters:
fn (collections.abc.Callable[[], None]) – Zero-argument callable encapsulating the command body.
- Raises:
typer.Exit – Re-raised when a command intentionally exits early.
- Return type:
None