Skip to content

cli

sleap.cli

SLEAP Command-Line Interface.

This module provides the primary command-line interface for SLEAP using click and rich-click. The sleap command is the main entry point.

Usage

sleap Launch the GUI sleap my_project.slp Open project in GUI sleap label [FILE] Launch the GUI (explicit) sleap doctor Show system diagnostics sleap --help Show CLI help

Legacy CLIs (sleap-label, sleap-train, etc.) are maintained for backwards compatibility but the unified sleap command is preferred.

Classes:

Name Description
DefaultGroup

A Click group that invokes a default subcommand if none is specified.

Functions:

Name Description
cli
doctor

Show system diagnostics for troubleshooting.

label

Launch the SLEAP labeling GUI.

wrap_nn_command

Wrap a sleap-nn CLI command with SLEAP branding.

wrap_sio_command

Wrap a sleap-io CLI command with SLEAP branding.

DefaultGroup

Bases: RichGroup

A Click group that invokes a default subcommand if none is specified.

Adapted from click-contrib/click-default-group for rich-click.

Key behaviors: - sleap with no args -> invokes label command - sleap foo.slp (unrecognized command) -> invokes label foo.slp - sleap doctor -> invokes doctor command normally - sleap --help -> shows group help

Source code in sleap/cli.py
class DefaultGroup(click.RichGroup):
    """A Click group that invokes a default subcommand if none is specified.

    Adapted from click-contrib/click-default-group for rich-click.

    Key behaviors:
    - `sleap` with no args -> invokes `label` command
    - `sleap foo.slp` (unrecognized command) -> invokes `label foo.slp`
    - `sleap doctor` -> invokes `doctor` command normally
    - `sleap --help` -> shows group help
    """

    ignore_unknown_options = True

    def __init__(
        self,
        *args: Any,
        default: Optional[str] = None,
        default_if_no_args: bool = False,
        **kwargs: Any,
    ) -> None:
        super().__init__(*args, **kwargs)
        self.default_cmd_name = default
        self.default_if_no_args = default_if_no_args

    def parse_args(self, ctx: click.Context, args: list[str]) -> list[str]:
        # If no args and we have a default, insert it
        if not args and self.default_if_no_args and self.default_cmd_name:
            args.insert(0, self.default_cmd_name)
        # If first arg is a flag (not a subcommand), route to default
        # so e.g. `sleap --video-backend ffmpeg` works like
        # `sleap label --video-backend ffmpeg`
        if (
            args
            and args[0].startswith("--")
            and self.default_cmd_name
            and args[0] not in ("--help", "-h", "--version")
        ):
            args.insert(0, self.default_cmd_name)
        return super().parse_args(ctx, args)

    def get_command(self, ctx: click.Context, cmd_name: str) -> Optional[click.Command]:
        # First try normal command lookup
        cmd = super().get_command(ctx, cmd_name)
        if cmd is not None:
            return cmd
        # If command not found, we'll handle it in resolve_command
        return None

    def resolve_command(
        self, ctx: click.Context, args: list[str]
    ) -> tuple[Optional[str], Optional[click.Command], list[str]]:
        try:
            # Try to resolve normally first
            cmd_name, cmd, remaining = super().resolve_command(ctx, args)

            # If we found a real command, use it
            if cmd is not None:
                return cmd_name, cmd, remaining
        except click.UsageError:
            # No matching command found
            pass

        # No matching command - use the default and treat first arg as an argument
        if self.default_cmd_name:
            default_cmd = super().get_command(ctx, self.default_cmd_name)
            if default_cmd:
                return self.default_cmd_name, default_cmd, args

        # Re-raise if we can't handle it
        raise click.UsageError(
            f"No such command '{args[0]}'." if args else "No command specified."
        )

cli(ctx)

Run [bold cyan]sleap[/] without arguments to launch the GUI.

[dim]Examples:[/] sleap Launch the GUI sleap my_project.slp Open project in GUI sleap doctor Show system diagnostics

Source code in sleap/cli.py
@click.group(
    cls=DefaultGroup,
    default="label",
    default_if_no_args=True,
    invoke_without_command=True,
    context_settings={"help_option_names": ["-h", "--help"]},
)
@rich_config(help_config=SLEAP_HELP_CONFIG)
@click.version_option(version=sleap.__version__, prog_name="sleap")
@click.pass_context
def cli(ctx: click.Context) -> None:
    """SLEAP: A deep learning framework for multi-animal pose tracking.

    Run [bold cyan]sleap[/] without arguments to launch the GUI.

    [dim]Examples:[/]
      sleap                    Launch the GUI
      sleap my_project.slp     Open project in GUI
      sleap doctor             Show system diagnostics
    """
    pass

doctor(output_json, output_file, show_commit)

Show system diagnostics for troubleshooting.

Displays detailed information about your system configuration, including Python environment, GPU status, package versions, UV/conda configuration, and more.

This output is designed to be copy-pasted when reporting issues.

[dim]Examples:[/] sleap doctor Show diagnostics sleap doctor --json Output as JSON sleap doctor -o Save to auto-timestamped file sleap doctor -o out.txt Save to specific file

Source code in sleap/cli.py
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
@cli.command(context_settings={"help_option_names": ["-h", "--help"]})
@rich_config(help_config=SLEAP_HELP_CONFIG)
@click.option(
    "--json",
    "output_json",
    is_flag=True,
    help="Output diagnostics as JSON for programmatic use.",
)
@click.option(
    "-o",
    "--output",
    "output_file",
    default=None,
    help="Save output to file. Use '-o auto' for auto-timestamped filename.",
)
@click.option(
    "--commit",
    "show_commit",
    is_flag=True,
    default=False,
    help=(
        "Resolve and display the SLEAP commit hash for release installs by "
        "looking up the release tag on GitHub (off by default; needs network)."
    ),
)
def doctor(output_json: bool, output_file: Optional[str], show_commit: bool) -> None:
    """Show system diagnostics for troubleshooting.

    Displays detailed information about your system configuration,
    including Python environment, GPU status, package versions,
    UV/conda configuration, and more.

    This output is designed to be copy-pasted when reporting issues.

    [dim]Examples:[/]
      sleap doctor           Show diagnostics
      sleap doctor --json    Output as JSON
      sleap doctor -o        Save to auto-timestamped file
      sleap doctor -o out.txt   Save to specific file
    """
    from datetime import datetime
    from pathlib import Path

    from sleap.system_info import (
        PACKAGES,
        DIM,
        get_detailed_package_info,
        get_uv_info_data,
        get_conda_info_data,
        get_binary_info,
        get_nvidia_info,
        get_pytorch_info_detailed,
        get_memory_info,
        get_disk_info,
        get_ffmpeg_info,
        analyze_path,
        short_sha,
        resolve_tag_commit,
        SLEAP_REPO,
    )

    if output_json:
        _doctor_json(show_commit)
        return

    console = Console()
    all_data = {}

    # Print header
    console.print()
    console.print(f"[bold {SLEAP_TEAL}]SLEAP System Diagnostics[/]")
    console.print(f"[{SLEAP_TEAL}]{'=' * 24}[/]")

    # Timestamp
    timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    console.print(f"[{DIM}]Generated:[/] {timestamp}")
    console.print()
    all_data["timestamp"] = timestamp

    # -------------------------------------------------------------------------
    # Platform Information
    # -------------------------------------------------------------------------
    ram_used, ram_avail, ram_total = get_memory_info()
    venv_path = os.environ.get("VIRTUAL_ENV", "") or sys.prefix
    disk_used, disk_avail, disk_total = get_disk_info(venv_path)

    all_data["platform"] = {
        "os_name": platform.system(),
        "os_release": platform.release(),
        "platform_full": platform.platform(),
        "machine": platform.machine(),
        "processor": platform.processor(),
        "ram_used": ram_used,
        "ram_total": ram_total,
        "disk_used": disk_used,
        "disk_total": disk_total,
    }

    console.print("[Platform]", style=f"bold {SLEAP_BLUE}")
    w = _DOCTOR_WIDTHS["platform"] + 1  # +1 for colon
    console.print(f"  [{DIM}]{'OS:':<{w}}[/] {platform.system()} {platform.release()}")
    console.print(f"  [{DIM}]{'Platform:':<{w}}[/] {platform.platform()}")
    console.print(f"  [{DIM}]{'Machine:':<{w}}[/] {platform.machine()}")
    processor = platform.processor()
    if processor:
        console.print(f"  [{DIM}]{'Processor:':<{w}}[/] {processor}")
    if ram_total:
        console.print(f"  [{DIM}]{'RAM:':<{w}}[/] {ram_used} / {ram_total}")
    if disk_total:
        console.print(f"  [{DIM}]{'Disk:':<{w}}[/] {disk_used} / {disk_total}")
    console.print()

    # -------------------------------------------------------------------------
    # Python Information
    # -------------------------------------------------------------------------
    all_data["python"] = {
        "version": sys.version.split()[0],
        "executable": sys.executable,
        "prefix": sys.prefix,
        "virtual_env": os.environ.get("VIRTUAL_ENV", ""),
    }

    console.print("[Python]", style=f"bold {SLEAP_BLUE}")
    w = _DOCTOR_WIDTHS["python"] + 1  # +1 for colon
    py_ver = sys.version.split()[0]
    console.print(f"  [{DIM}]{'Version:':<{w}}[/] [{SLEAP_GREEN}]{py_ver}[/]")
    console.print(f"  [{DIM}]{'Executable:':<{w}}[/] [{SLEAP_CYAN}]{sys.executable}[/]")
    console.print(f"  [{DIM}]{'Prefix:':<{w}}[/] [{SLEAP_CYAN}]{sys.prefix}[/]")
    venv = os.environ.get("VIRTUAL_ENV")
    if venv:
        console.print(f"  [{DIM}]{'Virtual Env:':<{w}}[/] [{SLEAP_CYAN}]{venv}[/]")
    console.print()

    # -------------------------------------------------------------------------
    # UV Information
    # -------------------------------------------------------------------------
    with console.status(f"[{DIM}]Checking UV...[/]", spinner="dots"):
        uv_info = get_uv_info_data()
    all_data["uv"] = uv_info

    if uv_info:
        console.print("[UV]", style=f"bold {SLEAP_BLUE}")
        w = _DOCTOR_WIDTHS["uv"] + 1  # +1 for colon
        uv_ver = uv_info.version
        console.print(f"  [{DIM}]{'Version:':<{w}}[/] [{SLEAP_GREEN}]{uv_ver}[/]")
        console.print(f"  [{DIM}]{'Path:':<{w}}[/] [{SLEAP_CYAN}]{uv_info.path}[/]")
        uv_cache = uv_info.cache_dir
        console.print(f"  [{DIM}]{'Cache Dir:':<{w}}[/] [{SLEAP_CYAN}]{uv_cache}[/]")
        uv_tool = uv_info.tool_dir
        console.print(f"  [{DIM}]{'Tool Dir:':<{w}}[/] [{SLEAP_CYAN}]{uv_tool}[/]")
        uv_tool_bin = uv_info.tool_bin_dir
        console.print(
            f"  [{DIM}]{'Tool Bin Dir:':<{w}}[/] [{SLEAP_CYAN}]{uv_tool_bin}[/]"
        )
        uv_py_dir = uv_info.python_dir
        console.print(f"  [{DIM}]{'Python Dir:':<{w}}[/] [{SLEAP_CYAN}]{uv_py_dir}[/]")
        if uv_info.installed_tools:
            tools_str = ", ".join(uv_info.installed_tools)
            console.print(f"  [{DIM}]{'Installed Tools:':<{w}}[/] {tools_str}")
        console.print()

        # UV Config
        console.print("[UV Config]", style=f"bold {SLEAP_BLUE}")
        w = _DOCTOR_WIDTHS["uv_config"] + 1  # +1 for colon
        if uv_info.default_python:
            default_py = uv_info.default_python
            console.print(
                f"  [{DIM}]{'Default Python:':<{w}}[/] [{SLEAP_CYAN}]{default_py}[/]"
            )
        else:
            console.print(
                f"  [{DIM}]{'Default Python:':<{w}}[/] [{DIM}](not configured)[/]"
            )
        if uv_info.resolved_python:
            resolved_py = uv_info.resolved_python
            console.print(
                f"  [{DIM}]{'Resolved Python:':<{w}}[/] [{SLEAP_CYAN}]{resolved_py}[/]"
            )

        pref = uv_info.python_preference or "managed"
        is_default = not uv_info.python_preference
        pref_display = f"{pref} [{DIM}](default)[/]" if is_default else pref
        console.print(f"  [{DIM}]{'Python Preference:':<{w}}[/] {pref_display}")

        res = uv_info.resolution_strategy or "highest"
        is_default = not uv_info.resolution_strategy
        res_display = f"{res} [{DIM}](default)[/]" if is_default else res
        console.print(f"  [{DIM}]{'Resolution:':<{w}}[/] {res_display}")

        idx = uv_info.index_strategy or "first-index"
        is_default = not uv_info.index_strategy
        idx_display = f"{idx} [{DIM}](default)[/]" if is_default else idx
        console.print(f"  [{DIM}]{'Index Strategy:':<{w}}[/] {idx_display}")

        pre = uv_info.prerelease or "if-necessary"
        is_default = not uv_info.prerelease
        pre_display = f"{pre} [{DIM}](default)[/]" if is_default else pre
        console.print(f"  [{DIM}]{'Prerelease:':<{w}}[/] {pre_display}")
        console.print()

    # -------------------------------------------------------------------------
    # Conda Information
    # -------------------------------------------------------------------------
    with console.status(f"[{DIM}]Checking conda...[/]", spinner="dots"):
        conda_info = get_conda_info_data()
    all_data["conda"] = conda_info

    if conda_info:
        console.print("[Conda]", style=f"bold {SLEAP_BLUE}")
        w = _DOCTOR_WIDTHS["conda"] + 1  # +1 for colon
        if conda_info.active:
            console.print(f"  [{DIM}]{'Status:':<{w}}[/] [{SLEAP_YELLOW}]ACTIVE[/]")
            console.print(f"  [{DIM}]{'Environment:':<{w}}[/] {conda_info.environment}")
            conda_prefix = conda_info.prefix
            console.print(
                f"  [{DIM}]{'Prefix:':<{w}}[/] [{SLEAP_CYAN}]{conda_prefix}[/]"
            )
        else:
            console.print(f"  [{DIM}]{'Status:':<{w}}[/] installed but not activated")
        if conda_info.version:
            console.print(f"  [{DIM}]{'Version:':<{w}}[/] {conda_info.version}")
        if conda_info.auto_activate_base is not None:
            status = "True" if conda_info.auto_activate_base else "False"
            color = SLEAP_RED if conda_info.auto_activate_base else SLEAP_GREEN
            console.print(
                f"  [{DIM}]{'auto_activate_base:':<{w}}[/] [{color}]{status}[/]"
            )
            if conda_info.auto_activate_base:
                console.print(
                    f"  [{SLEAP_YELLOW}]WARNING: auto_activate_base=True "
                    f"may interfere with uv[/]"
                )
                console.print(
                    f"  [{DIM}]Suggestion: "
                    f"conda config --set auto_activate_base false[/]"
                )
        if conda_info.sleap_packages:
            pkgs_str = ", ".join(conda_info.sleap_packages)
            console.print(
                f"  [{DIM}]{'SLEAP in conda:':<{w}}[/] [{SLEAP_RED}]{pkgs_str}[/]"
            )
            console.print(
                f"  [{SLEAP_YELLOW}]WARNING: Conda SLEAP packages "
                f"may conflict with uv/pip[/]"
            )
        console.print()

    # -------------------------------------------------------------------------
    # GPU / CUDA Information
    # -------------------------------------------------------------------------
    with console.status(f"[{DIM}]Checking GPU...[/]", spinner="dots"):
        nvidia_driver, system_cuda, gpus = get_nvidia_info()
    all_data["nvidia_driver"] = nvidia_driver
    all_data["system_cuda"] = system_cuda
    all_data["gpus"] = gpus

    with console.status(f"[{DIM}]Checking PyTorch...[/]", spinner="dots"):
        pytorch_version, pytorch_accelerator, pytorch_cuda = get_pytorch_info_detailed()
    all_data["pytorch_version"] = pytorch_version
    all_data["pytorch_accelerator"] = pytorch_accelerator
    all_data["pytorch_cuda"] = pytorch_cuda

    console.print("[GPU / CUDA]", style=f"bold {SLEAP_BLUE}")
    w = _DOCTOR_WIDTHS["gpu"] + 1  # +1 for colon
    if nvidia_driver:
        driver_str = nvidia_driver
        if system_cuda:
            driver_str += f" (CUDA {system_cuda})"
        console.print(
            f"  [{DIM}]{'NVIDIA Driver:':<{w}}[/] [{SLEAP_GREEN}]{driver_str}[/]"
        )
        for i, gpu in enumerate(gpus):
            console.print(
                f"  [{DIM}]{f'GPU {i}:':<{w}}[/] [{SLEAP_TEAL}]{gpu.name}[/] "
                f"([{SLEAP_GREEN}]{gpu.memory_free}[/] free / {gpu.memory_total})"
            )
    else:
        console.print(f"  [{DIM}]{'NVIDIA Driver:':<{w}}[/] Not detected")
    if pytorch_version:
        pt_str = f"v{pytorch_version}"
        if pytorch_accelerator == "cuda":
            pt_str += f" ([{SLEAP_GREEN}]CUDA {pytorch_cuda}[/])"
        elif pytorch_accelerator == "mps":
            pt_str += f" ([{SLEAP_GREEN}]MPS[/])"
        else:
            pt_str += f" ([{SLEAP_YELLOW}]CPU[/])"
        console.print(f"  [{DIM}]{'PyTorch:':<{w}}[/] [{SLEAP_TEAL}]{pt_str}[/]")
    else:
        console.print(f"  [{DIM}]{'PyTorch:':<{w}}[/] Not installed")
    console.print()

    # -------------------------------------------------------------------------
    # Package Versions
    # -------------------------------------------------------------------------
    with console.status(f"[{DIM}]Checking packages...[/]", spinner="dots"):
        packages = []
        for pkg_name in PACKAGES:
            pkg_info = get_detailed_package_info(pkg_name)
            if pkg_info:
                packages.append(pkg_info)
    all_data["packages"] = packages

    # Optionally resolve the SLEAP commit from its release tag via GitHub. Only
    # done with --commit (it needs network) and only for release installs that
    # don't already carry a local commit.
    resolved_commits = {}
    if show_commit:
        sleap_pkg = next((p for p in packages if p.name == "sleap"), None)
        if sleap_pkg and not sleap_pkg.git_commit:
            with console.status(
                f"[{DIM}]Resolving commit from GitHub...[/]", spinner="dots"
            ):
                sha = resolve_tag_commit(SLEAP_REPO, sleap_pkg.version)
            if sha:
                resolved_commits["sleap"] = sha
    all_data["resolved_commits"] = resolved_commits

    console.print("[Packages]", style=f"bold {SLEAP_BLUE}")
    w = max(len(pkg.name) for pkg in packages) + 1 if packages else 10  # +1 for colon
    for pkg in packages:
        source_color = (
            SLEAP_PURPLE
            if pkg.source == "editable"
            else SLEAP_ORANGE
            if pkg.source == "conda"
            else DIM
        )
        pkg_line = (
            f"  [{SLEAP_TEAL}]{(pkg.name + ':'):<{w}}[/] "
            f"[{SLEAP_GREEN}]v{pkg.version}[/] ([{source_color}]{pkg.source}[/])"
        )
        if pkg.git_commit:
            git_info = f"git:{pkg.git_branch or 'HEAD'}@{short_sha(pkg.git_commit)}"
            if pkg.git_dirty:
                git_info += "*"
            pkg_line += f" [[{SLEAP_PURPLE}]{git_info}[/]]"
        elif pkg.name in resolved_commits:
            tag_info = f"github:v{pkg.version}@{short_sha(resolved_commits[pkg.name])}"
            pkg_line += f" [[{SLEAP_PURPLE}]{tag_info}[/]]"
        console.print(pkg_line)
        if pkg.editable:
            console.print(f"  {'':<{w}} Location: [{SLEAP_CYAN}]{pkg.location}[/]")
        elif pkg.git_remote:
            console.print(f"  {'':<{w}} Remote: [{SLEAP_CYAN}]{pkg.git_remote}[/]")
    console.print()

    # -------------------------------------------------------------------------
    # CLI Binaries
    # -------------------------------------------------------------------------
    with console.status(f"[{DIM}]Checking CLI binaries...[/]", spinner="dots"):
        binaries = []
        bin_names = ["sleap", "sleap-nn", "sio"]
        for bin_name in bin_names:
            bin_info = get_binary_info(bin_name)
            if bin_info:
                binaries.append(bin_info)
        # Add ffmpeg binaries
        binaries.extend(get_ffmpeg_info())
    all_data["binaries"] = binaries

    if binaries:
        console.print("[CLI Binaries]", style=f"bold {SLEAP_BLUE}")
        w = _DOCTOR_WIDTHS["binaries"] + 1  # +1 for colon
        for binary in binaries:
            source_color = (
                SLEAP_TEAL
                if binary.source == "venv"
                else SLEAP_PURPLE
                if binary.source == "uv-tool"
                else SLEAP_ORANGE
            )
            console.print(f"  [{SLEAP_TEAL}]{binary.name}[/]:")
            bin_path = binary.path
            console.print(f"    [{DIM}]{'Path:':<{w}}[/] [{SLEAP_CYAN}]{bin_path}[/]")
            if binary.real_path != binary.path:
                real_path = binary.real_path
                console.print(
                    f"    [{DIM}]{'Real Path:':<{w}}[/] [{SLEAP_CYAN}]{real_path}[/]"
                )
            bin_src = binary.source
            console.print(
                f"    [{DIM}]{'Source:':<{w}}[/] [{source_color}]{bin_src}[/]"
            )
            if binary.python_path:
                py_path = binary.python_path
                console.print(
                    f"    [{DIM}]{'Python:':<{w}}[/] [{SLEAP_CYAN}]{py_path}[/]"
                )
        console.print()

    # -------------------------------------------------------------------------
    # PATH Analysis
    # -------------------------------------------------------------------------
    path_entries, path_conflicts = analyze_path()
    all_data["path_entries"] = path_entries
    all_data["path_conflicts"] = path_conflicts

    if path_conflicts:
        console.print("[PATH Conflicts]", style=f"bold {SLEAP_RED}")
        for conflict in path_conflicts:
            console.print(f"  [{SLEAP_YELLOW}]WARNING: {conflict}[/]")
        console.print()

    console.print("[PATH (relevant entries)]", style=f"bold {SLEAP_BLUE}")
    relevant_keywords = [
        "conda",
        "miniconda",
        "uv",
        ".local",
        "sleap",
        "python",
        "venv",
    ]
    for path in path_entries:
        if any(kw in path.lower() for kw in relevant_keywords):
            console.print(f"  [{SLEAP_CYAN}]{path}[/]")
    console.print()

    # -------------------------------------------------------------------------
    # Footer
    # -------------------------------------------------------------------------
    output_path = None
    if output_file:
        if output_file == "auto":
            file_timestamp = datetime.now().strftime("%Y%m%d-%H%M%S")
            output_path = Path(f"sleap-doctor-{file_timestamp}.txt")
        else:
            output_path = Path(output_file)

        output_text = _format_doctor_plain(all_data)
        output_path.write_text(output_text)

    console.print(f"[{DIM}]Copy this output when reporting issues at:[/]")
    console.print(f"[{SLEAP_BLUE}]https://github.com/talmolab/sleap/issues[/]")
    console.print()
    if output_path:
        console.print(f"[{SLEAP_GREEN}]Saved to:[/] [{SLEAP_TEAL}]{output_path}[/]")
    else:
        console.print(
            f"[bold {SLEAP_TEAL}]Tip:[/] [{DIM}]Use[/] "
            f"[{SLEAP_TEAL}]sleap doctor -o[/] "
            f"[{DIM}]to save diagnostics to a file[/]"
        )
    console.print()

label(labels_path, verbose, reset, no_usage_data, nonnative, profiling, video_backend)

Launch the SLEAP labeling GUI.

Optionally open a labels file (.slp) directly.

[dim]Examples:[/] sleap label Launch empty GUI sleap label my_project.slp Open existing project sleap my_project.slp Same as above (shorthand)

Source code in sleap/cli.py
@cli.command(context_settings={"help_option_names": ["-h", "--help"]})
@rich_config(help_config=SLEAP_HELP_CONFIG)
@click.argument(
    "labels_path",
    required=False,
    type=click.Path(exists=False),
    metavar="[LABELS.slp]",
)
@click.option(
    "-v",
    "--verbose",
    is_flag=True,
    help="Show detailed startup information including GPU status.",
)
@click.option(
    "--reset",
    is_flag=True,
    help="Reset GUI preferences to defaults.",
)
@click.option(
    "--no-usage-data",
    is_flag=True,
    help="Disable anonymous usage data collection.",
)
@click.option(
    "--nonnative",
    is_flag=True,
    help="Use non-native file dialogs.",
)
@click.option(
    "--profiling",
    is_flag=True,
    help="Enable performance profiling.",
)
@click.option(
    "--video-backend",
    type=click.Choice(["opencv", "FFMPEG", "pyav"], case_sensitive=False),
    default=None,
    help="Video backend plugin. Overrides saved preference.",
)
def label(
    labels_path: Optional[str],
    verbose: bool,
    reset: bool,
    no_usage_data: bool,
    nonnative: bool,
    profiling: bool,
    video_backend: Optional[str],
) -> None:
    """Launch the SLEAP labeling GUI.

    Optionally open a labels file (.slp) directly.

    [dim]Examples:[/]
      sleap label                      Launch empty GUI
      sleap label my_project.slp       Open existing project
      sleap my_project.slp             Same as above (shorthand)
    """
    # Build args list for the existing GUI main function
    args = []

    if labels_path:
        args.append(labels_path)
    if verbose:
        args.append("--verbose")
    if reset:
        args.append("--reset")
    if no_usage_data:
        args.append("--no-usage-data")
    if nonnative:
        args.append("--nonnative")
    if profiling:
        args.append("--profiling")
    if video_backend:
        args.extend(["--video-backend", video_backend])

    # Import and call the existing GUI launcher
    from sleap.gui.app import main as gui_main

    gui_main(args=args)

wrap_nn_command(nn_cmd, deprecated_note=None)

Wrap a sleap-nn CLI command with SLEAP branding.

This creates a new command that: 1. Has the same parameters as the original command 2. Uses SLEAP's rich-click configuration for help formatting 3. Replaces 'sleap-nn' with 'sleap' in help text examples

Parameters:

Name Type Description Default
nn_cmd Command

A Click Command object from sleap-nn.

required
deprecated_note Optional[str]

If given, printed as a warning to stderr every time the command runs, and prepended to its help text.

None

Returns:

Type Description
Command

A new Command object with SLEAP branding applied.

Source code in sleap/cli.py
def wrap_nn_command(
    nn_cmd: click.Command, deprecated_note: Optional[str] = None
) -> click.Command:
    """Wrap a sleap-nn CLI command with SLEAP branding.

    This creates a new command that:
    1. Has the same parameters as the original command
    2. Uses SLEAP's rich-click configuration for help formatting
    3. Replaces 'sleap-nn' with 'sleap' in help text examples

    Args:
        nn_cmd: A Click Command object from sleap-nn.
        deprecated_note: If given, printed as a warning to stderr every time the
            command runs, and prepended to its help text.

    Returns:
        A new Command object with SLEAP branding applied.
    """
    import copy

    # Deep copy to avoid modifying the original
    new_cmd = copy.copy(nn_cmd)

    # Replace examples in help text
    if new_cmd.help:
        new_cmd.help = new_cmd.help.replace("sleap-nn ", "sleap ")
        new_cmd.help = new_cmd.help.replace("$ sleap-nn ", "$ sleap ")
        # Also replace any "sleap-nn" command references in the docs
        new_cmd.help = new_cmd.help.replace("[bold]sleap-nn[/]", "[bold]sleap[/]")

    if deprecated_note is not None:
        original_callback = new_cmd.callback

        def _callback_with_deprecation_warning(*args: Any, **kwargs: Any) -> Any:
            click.echo(click.style(deprecated_note, fg="yellow"), err=True)
            return original_callback(*args, **kwargs)

        new_cmd.callback = _callback_with_deprecation_warning
        new_cmd.help = f"[dim](Legacy)[/] {new_cmd.help or ''}".strip()

    # Apply SLEAP's rich-click configuration
    # RichCommand stores config in _rich_config attribute
    new_cmd._rich_config = SLEAP_HELP_CONFIG

    return new_cmd

wrap_sio_command(sio_cmd)

Wrap a sleap-io CLI command with SLEAP branding.

This creates a new command that: 1. Has the same parameters as the original command 2. Uses SLEAP's rich-click configuration for help formatting 3. Replaces 'sio' with 'sleap' in help text examples

Parameters:

Name Type Description Default
sio_cmd Command

A Click Command object from sleap-io.

required

Returns:

Type Description
Command

A new Command object with SLEAP branding applied.

Source code in sleap/cli.py
def wrap_sio_command(sio_cmd: click.Command) -> click.Command:
    """Wrap a sleap-io CLI command with SLEAP branding.

    This creates a new command that:
    1. Has the same parameters as the original command
    2. Uses SLEAP's rich-click configuration for help formatting
    3. Replaces 'sio' with 'sleap' in help text examples

    Args:
        sio_cmd: A Click Command object from sleap-io.

    Returns:
        A new Command object with SLEAP branding applied.
    """
    import copy

    # Deep copy to avoid modifying the original
    new_cmd = copy.copy(sio_cmd)

    # Replace examples in help text
    if new_cmd.help:
        new_cmd.help = new_cmd.help.replace("$ sio ", "$ sleap ")
        # Also replace any "sio" command references in the docs
        new_cmd.help = new_cmd.help.replace("[bold]sio[/]", "[bold]sleap[/]")

    # Apply SLEAP's rich-click configuration
    # RichCommand stores config in _rich_config attribute
    new_cmd._rich_config = SLEAP_HELP_CONFIG

    return new_cmd