Skip to content

refactor(cli): rename scripts→cli, migrate argparseclick#412

Closed
Borda wants to merge 2 commits into
developfrom
cli/click
Closed

refactor(cli): rename scripts→cli, migrate argparseclick#412
Borda wants to merge 2 commits into
developfrom
cli/click

Conversation

@Borda
Copy link
Copy Markdown
Member

@Borda Borda commented May 12, 2026

This pull request introduces a new trackers.cli package implementing a modern, modular command-line interface (CLI) for the project using the click library, replacing the older argparse-based CLI. It adds new CLI entrypoints for dataset downloading, evaluation, tracking, and hyperparameter tuning, and updates the project configuration to use the new CLI. The legacy CLI is now a thin wrapper for backward compatibility.

Major changes:

New CLI implementation

  • Introduced a new trackers.cli package with subcommands (download, eval, track, tune) using the click library for a more user-friendly, extensible CLI. Each subcommand is implemented in its own module for maintainability. [1] [2] [3] [4]
  • Added a new progress.py utility for rich, live progress display during tracking operations.

Project configuration and entrypoint updates

  • Updated pyproject.toml to add a dependency on click, and changed the CLI entrypoint to use trackers.cli.__main__:main instead of the old scripts location.
  • The legacy trackers.scripts.__main__.py is now a backward-compatibility shim that simply calls the new CLI.

Miscellaneous

  • Added standard copyright/license headers to new files.

These changes modernize and modularize the CLI, making it easier to extend and maintain, and provide a better user experience.


  • Add new trackers/cli/ package: main.py, track.py, eval.py, tune.py, download.py, progress.py
  • Rewrite all subcommands with click decorators; dynamic --tracker.X params appended via cmd.params.append(click.Option(..., expose_value=False, callback=...)) stored in ctx.obj
  • Add click>=8.0 to core dependencies (zero transitive deps on Linux/macOS)
  • Update pyproject.toml console-scripts entry point to trackers.cli.main:main
  • Replace scripts/ files with backward-compat shims re-exporting from cli/
  • Rewrite test_download.py and test_tune.py CLI tests using click.testing.CliRunner; update imports in test_track.py and test_progress.py

Resolves #406

- Add new trackers/cli/ package: __main__.py, track.py, eval.py, tune.py, download.py, progress.py
- Rewrite all subcommands with click decorators; dynamic --tracker.X params appended via cmd.params.append(click.Option(..., expose_value=False, callback=...)) stored in ctx.obj
- Add click>=8.0 to core dependencies (zero transitive deps on Linux/macOS)
- Update pyproject.toml console-scripts entry point to trackers.cli.__main__:main
- Replace scripts/ files with backward-compat shims re-exporting from cli/
- Rewrite test_download.py and test_tune.py CLI tests using click.testing.CliRunner; update imports in test_track.py and test_progress.py

---
Co-authored-by: Claude Code <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 12, 2026 12:06
@Borda Borda requested a review from SkalskiP as a code owner May 12, 2026 12:06
@Borda Borda added the enhancement New feature or request label May 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the Trackers CLI by introducing a new trackers.cli package implemented with click, switching the console-script entrypoint to the new CLI, and turning the legacy trackers.scripts modules into backward-compatibility shims.

Changes:

  • Added a new trackers.cli package (track, eval, download, tune, plus shared progress) implemented with click.
  • Updated packaging to depend on click and to route the trackers console script to trackers.cli.__main__:main.
  • Migrated CLI tests to click.testing.CliRunner and updated imports to the new modules.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
uv.lock Locks click (and Windows-only colorama) into the dependency graph.
pyproject.toml Adds click>=8.0 and points the trackers entrypoint to trackers.cli.__main__:main.
src/trackers/cli/init.py Introduces the trackers.cli package.
src/trackers/cli/main.py Defines the top-level Click group and registers subcommands.
src/trackers/cli/track.py Click-based track command, including dynamic --tracker.* option generation.
src/trackers/cli/eval.py Click-based eval command with single-sequence and benchmark modes.
src/trackers/cli/download.py Click-based download command with --list and argument parsing.
src/trackers/cli/tune.py Click-based tune command that delegates to trackers.tune.Tuner.
src/trackers/cli/progress.py Progress UI utilities moved under the new CLI package.
src/trackers/scripts/main.py Backward-compat shim delegating to the new CLI entrypoint.
src/trackers/scripts/track.py Backward-compat shim re-exporting the new track implementation.
src/trackers/scripts/eval.py Backward-compat shim re-exporting the new eval command.
src/trackers/scripts/download.py Backward-compat shim re-exporting the new download implementation.
src/trackers/scripts/tune.py Backward-compat shim re-exporting the new tune implementation.
src/trackers/scripts/progress.py Backward-compat shim re-exporting the new progress utilities.
tests/scripts/test_download.py Rewritten download CLI tests using CliRunner.
tests/scripts/test_tune.py Rewritten tune CLI tests using CliRunner.
tests/scripts/test_track.py Updates imports to reference trackers.cli.track.
tests/scripts/test_progress.py Updates imports/patch paths to reference trackers.cli.progress.

Comment thread src/trackers/cli/track.py
Comment on lines +185 to +187
if model is not None and detections is not None:
raise click.UsageError("--model and --detections are mutually exclusive.")

Comment thread src/trackers/cli/track.py
"--track_ids", default=None, metavar="IDS", help="Filter output by track IDs (comma-separated, e.g., 1,3,5)"
)
@click.option(
"--tracker",
runner = CliRunner()
result = runner.invoke(cli, ["download"])
assert result.exit_code != 0
assert "Please specify a dataset" in result.output
@Borda Borda marked this pull request as draft May 12, 2026 13:55
- Fix parse-time crash: filter non-primitive tracker param types in _add_tracker_params (class defaults caused click to invoke them as callables at parse time)
- Fix --detections-only mode: set --model default=None, apply DEFAULT_MODEL after mutex check so detections-only invocation no longer raises spurious UsageError
- Add CliRunner smoke tests for track command covering help and missing-source paths
- Extract shared metrics/threshold/seqmap/output decorators to _options.py; deduplicate ~50 LOC across eval.py and tune.py
- Move logging.basicConfig to cli() group with -v/--verbose; replace print(stderr) with click.echo(err=True); sys.exit(rc) → click.exceptions.Exit(rc) in tune_command

---
Co-authored-by: Claude Code <noreply@anthropic.com>
@Borda Borda changed the title refactor(cli): rename scripts→cli, migrate argparse→click refactor(cli): rename scripts→cli, migrate argparseclick May 15, 2026
@Borda
Copy link
Copy Markdown
Member Author

Borda commented May 20, 2026

does not bring the expected simplification

@Borda Borda closed this May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor trackers/scriptstrackers/cli and evaluate CLI framework

3 participants