From 3d37fd73e196e2af1e44e31395a592fa10ac8c5c Mon Sep 17 00:00:00 2001 From: kaatr Date: Mon, 23 Jun 2025 10:59:59 +0300 Subject: [PATCH 1/4] Fix sai-cli -h (import yaml when needed) --- python/cli/convert/tum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cli/convert/tum.py b/python/cli/convert/tum.py index 7fcb0a2..0a04d43 100644 --- a/python/cli/convert/tum.py +++ b/python/cli/convert/tum.py @@ -11,7 +11,6 @@ import os from pathlib import Path import subprocess -import yaml from contextlib import contextmanager import shutil import tempfile @@ -86,6 +85,7 @@ def maybe_extract_tar_or_zip(path): print(f"Warning: Failed to delete temporary directory '{temp_dir}': {e}") def get_calibration(input_dir, stereo): + import yaml calibration = { "cameras": [] } def convert_distortion(model, coeffs): From e01f11cf1b34a8d26350b529cb3f5381b1e8463b Mon Sep 17 00:00:00 2001 From: kaatr Date: Mon, 23 Jun 2025 11:02:25 +0300 Subject: [PATCH 2/4] Simplify smooth.py imports (use run_sai_cli.py instead) --- python/cli/smooth.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/python/cli/smooth.py b/python/cli/smooth.py index 0600a99..d88b763 100644 --- a/python/cli/smooth.py +++ b/python/cli/smooth.py @@ -2,13 +2,7 @@ Post-process a session and generate a smoothed trajectory with all frames """ import json - -try: - from process.process import parse_input_dir, auto_config -except ImportError: - # hacky: The following mechanism allows using this both as a stand-alone - # script and as a subcommand in sai-cli. - from .process.process import parse_input_dir, auto_config +from .process.process import parse_input_dir, auto_config def define_args(parser): parser.add_argument("input", help="Path to folder with session to process") From 2116947efa97f64646f0c69a1b582e907a1b4e5c Mon Sep 17 00:00:00 2001 From: kaatr Date: Mon, 23 Jun 2025 11:03:10 +0300 Subject: [PATCH 3/4] Catch ImportError in sai_cli.py and suggest pip install spectacularAI[full] --- python/cli/sai_cli.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/cli/sai_cli.py b/python/cli/sai_cli.py index 776f740..15e33ac 100644 --- a/python/cli/sai_cli.py +++ b/python/cli/sai_cli.py @@ -19,8 +19,12 @@ def parse_args(): return parser.parse_args() def main(): - args = parse_args() - args.func(args) + try: + args = parse_args() + args.func(args) + except ImportError as e: + print(e) + print("Try installing with 'pip install spectacularAI[full]'") if __name__ == '__main__': main() From e49788b9eeb9201224943e4a979155b9ca517b8a Mon Sep 17 00:00:00 2001 From: kaatr Date: Mon, 23 Jun 2025 13:58:32 +0300 Subject: [PATCH 4/4] Improve error message --- python/cli/sai_cli.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/cli/sai_cli.py b/python/cli/sai_cli.py index 15e33ac..1b2c729 100644 --- a/python/cli/sai_cli.py +++ b/python/cli/sai_cli.py @@ -23,8 +23,10 @@ def main(): args = parse_args() args.func(args) except ImportError as e: - print(e) - print("Try installing with 'pip install spectacularAI[full]'") + print(f"\n[ImportError] {e}") + print("Try installing dependencies with") + print(" pip install spectacularAI[full]\n") + raise if __name__ == '__main__': main()