Skip to content

feat: add Cyclopts-based CLI with run/preview/validate subcommands#63

Merged
mckornfield merged 5 commits into
mainfrom
sandbox/cli-tyro-clean
Mar 27, 2026
Merged

feat: add Cyclopts-based CLI with run/preview/validate subcommands#63
mckornfield merged 5 commits into
mainfrom
sandbox/cli-tyro-clean

Conversation

@binaryaaron
Copy link
Copy Markdown
Collaborator

@binaryaaron binaryaaron commented Mar 23, 2026

Summary

  • Adds a CLI entry point (anonymizer) using tyro's SubcommandApp with three subcommands: run (full pipeline), preview (sample subset), and validate (config check)
  • Includes GlobalOpts for --verbose, --debug, model config, and artifact path overrides
  • Comprehensive test coverage: argument parsing, error handling, help output, and output formatting
  • Updates README.md with CLI quick-start examples and CONTRIBUTING.md with CLI developer guidance and fixed stale setup instructions

Also included (not CLI-related)

  • Removes the kind literal field from Redact, Hash, Annotate, and Substitute strategy models and replaces the string-based Discriminator with a callable _resolve_replace_tag that resolves the tag from the class name (for instances) or a kind/type key (for dicts). No existing workflows are affected; this was bundled here as a low-risk cleanup.

Changes

Area Files
CLI source src/anonymizer/interface/cli/main.py, _output.py, __init__.py
Entry point src/anonymizer/__main__.py (python -m anonymizer support)
Config pyproject.toml (tyro>=0.9 dep + [project.scripts] entry point)
Tests tests/interface/cli/test_cli_parse.py, test_cli_errors.py, test_cli_help.py, test_cli_output.py
Docs README.md, CONTRIBUTING.md

Test plan

  • make test passes (363 tests, including 19 new CLI tests)
  • anonymizer --help, anonymizer run --help, anonymizer preview --help, anonymizer validate --help all exit 0
  • Verify CLI arg parsing matches Python API behavior for all replace strategies (redact, hash, annotate, substitute)
  • Verify --output writes CSV/Parquet correctly via write_result

Made with Cursor

@binaryaaron binaryaaron requested review from a team as code owners March 23, 2026 17:31
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 23, 2026

All contributors have signed the DCO ✍️ ✅
Posted by the DCO Assistant Lite bot.

@binaryaaron
Copy link
Copy Markdown
Collaborator Author

I have read the DCO document and I hereby sign the DCO.

@binaryaaron
Copy link
Copy Markdown
Collaborator Author

recheck

Copy link
Copy Markdown
Contributor

@mckornfield mckornfield left a comment

Choose a reason for hiding this comment

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

yay cli

Comment thread src/anonymizer/interface/cli/_output.py Outdated
Comment thread src/anonymizer/interface/cli/main.py Outdated
Comment thread tests/interface/cli/test_cli_errors.py Outdated
Comment thread README.md Outdated
@mckornfield
Copy link
Copy Markdown
Contributor

I have read the DCO document and I hereby sign the DCO.

Comment thread src/anonymizer/config/replace_strategies.py
Comment thread tests/interface/cli/test_cli_errors.py Outdated
Copy link
Copy Markdown
Collaborator

@lipikaramaswamy lipikaramaswamy left a comment

Choose a reason for hiding this comment

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

Good addition overall. Cyclopts + Pydantic flattening is a clean pattern, test coverage is solid, docs fixes are welcome. Should the PR title change to reflect we are using Cyclopts?

Comment thread src/anonymizer/interface/cli/main.py
Comment thread src/anonymizer/interface/cli/main.py Outdated
Comment thread src/anonymizer/config/replace_strategies.py Outdated
Comment thread tests/interface/cli/test_cli_parse.py Outdated
Comment thread tests/interface/cli/test_cli_parse.py Outdated
@mckornfield mckornfield changed the title feat: add Tyro-based CLI with run/preview/validate subcommands feat: add Cyclopts-based CLI with run/preview/validate subcommands Mar 25, 2026
@mckornfield mckornfield force-pushed the sandbox/cli-tyro-clean branch 2 times, most recently from 8df45a4 to a223f66 Compare March 25, 2026 21:42
Comment thread src/anonymizer/interface/cli/main.py Outdated
Comment thread tests/interface/cli/test_cli_errors.py Outdated
Copy link
Copy Markdown
Collaborator

@lipikaramaswamy lipikaramaswamy left a comment

Choose a reason for hiding this comment

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

lgtm, just small note about error handler

binaryaaron and others added 3 commits March 27, 2026 11:33
Adds a CLI entry point (`anonymizer`) using tyro's SubcommandApp:
- run: full anonymization pipeline (detection + replacement)
- preview: run on a subset of records for quick inspection
- validate: check config compatibility with model selections

Includes GlobalOpts (--verbose, --debug, model/artifact overrides),
output helpers (format_summary, write_result), and comprehensive
test coverage (parse, errors, help, output).

Updates README.md and CONTRIBUTING.md with CLI usage and developer
guidance.

Signed-off-by: aagonzales <aagonzales@nvidia.com>
Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
@mckornfield mckornfield force-pushed the sandbox/cli-tyro-clean branch from a223f66 to a5dc1dc Compare March 27, 2026 18:48
@mckornfield mckornfield merged commit dc7b230 into main Mar 27, 2026
6 checks passed
@mckornfield mckornfield deleted the sandbox/cli-tyro-clean branch March 27, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants