G
2025-12-09 12:40:55 -05:00
|
|
|
"""
|
G
2025-12-09 12:51:16 -05:00
|
|
|
This module contains the main group for the ria toolkit oss CLI.
|
G
2025-12-09 12:40:55 -05:00
|
|
|
"""
|
|
|
|
|
|
2026-06-03 16:25:47 -04:00
|
|
|
import subprocess
|
2026-06-04 15:49:44 -04:00
|
|
|
import sys
|
2026-06-04 09:15:20 -04:00
|
|
|
import warnings
|
|
|
|
|
|
|
|
|
|
warnings.filterwarnings(
|
|
|
|
|
"ignore",
|
|
|
|
|
message="Unable to import Axes3D",
|
|
|
|
|
category=UserWarning,
|
|
|
|
|
module="matplotlib",
|
|
|
|
|
)
|
2026-06-03 16:25:47 -04:00
|
|
|
|
2026-06-04 15:06:28 -04:00
|
|
|
import click # noqa: E402
|
G
2025-12-09 12:40:55 -05:00
|
|
|
|
2026-06-04 15:06:28 -04:00
|
|
|
from ria_toolkit_oss_cli.ria_toolkit_oss import commands # noqa: E402
|
G
2025-12-09 12:40:55 -05:00
|
|
|
|
|
|
|
|
|
2026-06-03 16:25:47 -04:00
|
|
|
def _git_lfs_installed() -> bool:
|
|
|
|
|
"""Return True if git-lfs is available on PATH."""
|
|
|
|
|
try:
|
2026-06-04 15:06:28 -04:00
|
|
|
return (
|
|
|
|
|
subprocess.run(
|
|
|
|
|
["git", "lfs", "version"],
|
|
|
|
|
capture_output=True,
|
|
|
|
|
).returncode
|
|
|
|
|
== 0
|
|
|
|
|
)
|
2026-06-03 16:25:47 -04:00
|
|
|
except FileNotFoundError:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
2026-06-03 16:43:02 -04:00
|
|
|
@click.group(invoke_without_command=True)
|
G
2025-12-09 12:40:55 -05:00
|
|
|
@click.option("-v", "--verbose", is_flag=True, type=bool, help="Increase verbosity, especially useful for debugging.")
|
2026-06-03 16:43:02 -04:00
|
|
|
@click.pass_context
|
|
|
|
|
def cli(ctx, verbose):
|
2026-06-04 09:15:20 -04:00
|
|
|
lfs_missing = not _git_lfs_installed()
|
|
|
|
|
if lfs_missing:
|
2026-06-03 16:25:47 -04:00
|
|
|
click.echo(
|
|
|
|
|
"Warning: git-lfs is not installed. RIA Hub projects require git-lfs to\n"
|
|
|
|
|
"track large binary files (models, recordings, datasets).\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Linux: sudo apt-get install git-lfs\n"
|
|
|
|
|
" macOS: brew install git-lfs\n"
|
|
|
|
|
" Other platforms: https://git-lfs.com\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"After installing, run: git lfs install",
|
|
|
|
|
err=True,
|
|
|
|
|
)
|
2026-06-03 16:43:02 -04:00
|
|
|
if ctx.invoked_subcommand is None:
|
2026-06-04 15:49:44 -04:00
|
|
|
if lfs_missing and sys.stdin.isatty():
|
2026-06-04 09:15:20 -04:00
|
|
|
click.pause(info="\nPress Enter to continue...", err=True)
|
2026-06-03 16:43:02 -04:00
|
|
|
click.echo(ctx.get_help())
|
G
2025-12-09 12:40:55 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Loop through project commands, binding them all to the CLI.
|
|
|
|
|
for command_name in dir(commands):
|
|
|
|
|
command = getattr(commands, command_name)
|
|
|
|
|
if isinstance(command, click.Command):
|
|
|
|
|
cli.add_command(command, name=command_name)
|