Skip to content

Commit 70ccac7

Browse files
committed
add: print versions at the beginning
1 parent 7568daa commit 70ccac7

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

flatone/cli.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,37 @@ def run_3dviewer(seg_ids: list[int], root_out: Path, warped: bool) -> None:
487487
) # same == default white
488488

489489

490+
def _safe_module_version(mod_name: str, dist_name: str | None = None) -> str:
491+
"""Best-effort version lookup: module.__version__ → metadata.version → 'unknown'."""
492+
try:
493+
mod = __import__(mod_name)
494+
v = getattr(mod, "__version__", None)
495+
if v:
496+
return str(v)
497+
except Exception:
498+
pass
499+
try:
500+
return version(dist_name or mod_name)
501+
except Exception:
502+
return "unknown"
503+
504+
505+
def _print_versions() -> None:
506+
"""Print key package versions at startup."""
507+
pkgs = [
508+
("flatone", __version__),
509+
("caveclient", _safe_module_version("caveclient")),
510+
("cloudvolume", _safe_module_version("cloudvolume", "cloud-volume")),
511+
("skeliner", _safe_module_version("skeliner")),
512+
("pywarper", _safe_module_version("pywarper")),
513+
]
514+
w = max(len(name) for name, _ in pkgs)
515+
print("Package versions:")
516+
for name, ver in pkgs:
517+
print(f" {name:<{w}} {ver}")
518+
print()
519+
520+
490521
# ---------- CLI entry-point ---------------------------------------------- #
491522

492523

@@ -632,6 +663,9 @@ def main() -> None:
632663
# otherwise: pipeline
633664
args = _build_pipeline_parser().parse_args(argv)
634665

666+
if args.verbose:
667+
_print_versions()
668+
635669
outdir = args.output_dir / str(args.seg_id)
636670
outdir.mkdir(parents=True, exist_ok=True)
637671

0 commit comments

Comments
 (0)