refactor(cli): Rename scripts→cli, integrate defopt#416
Closed
Borda wants to merge 9 commits into
Closed
Conversation
- New `trackers/cli/` package: defopt-based entry point, `--tracker-params key=val` replaces per-param `--tracker.<param>` flags, typed function signatures on all four subcommands - `trackers/scripts/` converted to thin backward-compat re-export shims - Tests moved from `tests/scripts/` to `tests/cli/`; 75 tests ported/rewritten for defopt API; tests/scripts stubs removed - Add `defopt>=7.0.0` to dependencies (pulls docutils + sphinxcontrib-napoleon + pockets) - Console-scripts entry updated to `trackers.cli.__main__:main` --- Co-authored-by: Claude Code <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
defopt
- Patch defopt._create_parser to rewrite --group-field flags to --group.field for groups: detection, filters, out, show - Rename track() params to carry group prefix (detection_model, filters_classes, out_mot_results, show_display, etc.) - Update all docs to use dotted flag syntax --- Co-authored-by: Claude Code <noreply@anthropic.com>
Extend _rewrite_dotted to match --no-<group>-<rest> and rewrite to --<group>.no-<rest> (e.g. --no-show-ids → --show.no-ids). Also update action.negative_option_strings so _BooleanOptionalAction True/False detection stays correct after the rename. --- Co-authored-by: Claude Code <noreply@anthropic.com>
- Replace --tracker.param_name style with --tracker-params key=value in code blocks and prose - Remove four non-existent --tracker.* rows from CLI Reference table; add single --tracker-params row with key=value description - Add missing --detections row to CLI Reference table (challenger catch) --- Co-authored-by: Claude Code <noreply@anthropic.com>
Replace --tracker-params key=value bag with 15 typed individual flags (--tracker.lost-track-buffer, --tracker.track-activation-threshold, etc.) by adding "tracker" to _GROUPS and removing _parse_tracker_params. None-filtering kwargs builder passes only user-supplied values to _init_tracker so each tracker's own defaults stay authoritative. - Add tracker to _GROUPS in __main__.py - Replace tracker_params param with 15 tracker_* typed params in track() - Remove _parse_tracker_params() helper - Update docs/learn/track.md CLI examples and reference table --- Co-authored-by: Claude Code <noreply@anthropic.com>
- Guard `class_id is not None` before `np.isin` in _run_frameless and _run_with_source (AttributeError on empty detections) - Add `# type: ignore` suppressions for tracked-slice and label_annotator return types - Add `mypy>=2.1.0` to dev deps; add `defopt` and `inference_models` to mypy ignore_missing_imports --- Co-authored-by: Claude Code <noreply@anthropic.com>
Resolve two conflicts: - scripts/tune.py: keep shim (HEAD wins over develop argparse impl) - tests/scripts/test_tune.py: keep deleted (argparse API removed) New from develop: defopt dep bump, tuner seeding/fixed-params/#427, ByteTrack confidence fix (#415), CMC as external module (#414), doc fixes. --- Co-authored-by: Claude Code <noreply@anthropic.com>
- Add fixed_params, images_dir, enqueue_defaults, seed to tune() signature
- Forward all four to Tuner() constructor call
- Register parsers={dict: json.loads} in defopt.run() so --fixed-params
accepts a JSON string from the CLI (e.g. '{"enable_cmc": false}')
- Add 4 tests covering param passthrough to Tuner (11 total, all green)
---
Co-authored-by: Claude Code <noreply@anthropic.com>
- Pin defopt to >=7.0.0,<8 to protect monkey-patch against breaking upgrades - Change detection_model default to None sentinel so explicit --detection.model always conflicts with --detections (was silently bypassed when model == DEFAULT_MODEL) - Add TestTrackerParamSync: asserts every primitive-typed tracker registry param appears as tracker_<name> in track(); catches future tracker additions that forget to update the signature --- Co-authored-by: Claude Code <noreply@anthropic.com>
Member
Author
|
Due to the required arg grouping, it has a similar complexity to the original |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a major refactor of the command-line interface (CLI) for the
trackersproject. The CLI implementation has been moved from thetrackers.scriptspackage, which usedargparse, to a new, modulartrackers.clipackage that leverages thedefoptlibrary for command parsing. This change modernizes the codebase, simplifies CLI command definitions, and improves maintainability. Backward compatibility is preserved via shims in the old locations. Additionally, several new CLI modules are introduced, each encapsulating a specific command.Key changes include:
CLI Refactor and Modernization:
trackers.scripts.__main__totrackers.cli.__main__, now usingdefoptfor argument parsing instead ofargparse. The main script now dispatches to subcommands (track,eval,tune,download) as standalone Python functions, improving modularity and testability. [1] [2] [3]pyproject.tomlto adddefoptas a required dependency and to point thetrackersscript entry to the new CLI location.New CLI Command Modules:
src/trackers/cli/download.py: Implements thedownloadcommand for datasets, replacing the previous argparse-based logic with a direct function interface.src/trackers/cli/eval.py: Implements theevalcommand for evaluating tracker predictions, supporting both single-sequence and benchmark modes.src/trackers/cli/tune.py: Implements thetunecommand for hyperparameter optimization using Optuna.src/trackers/cli/progress.py: Provides a progress display utility for tracking frame processing, with live updates and error handling.Backward Compatibility:
trackers.scripts(e.g.,__main__.py,download.py) that import and expose the new CLI functionality, ensuring existing scripts and user workflows do not break. [1] [2]Other:
These changes collectively modernize the CLI, improve code organization, and set the stage for future extensibility.
trackers/cli/package: defopt-based entry point,--tracker-params key=valreplaces per-param--tracker.<param>flags, typed function signatures on all four subcommandstrackers/scripts/converted to thin backward-compat re-export shimstests/scripts/totests/cli/; 75 tests ported/rewritten for defopt API; tests/scripts stubs removeddefopt>=7.0.0to dependencies (pulls docutils + sphinxcontrib-napoleon + pockets)trackers.cli.__main__:mainresolves #406