Skip to content

feat(cli): improved run/preview display and --trace flag#125

Draft
lipikaramaswamy wants to merge 1 commit into
mainfrom
lipikaramaswamy/feature/cli-display
Draft

feat(cli): improved run/preview display and --trace flag#125
lipikaramaswamy wants to merge 1 commit into
mainfrom
lipikaramaswamy/feature/cli-display

Conversation

@lipikaramaswamy
Copy link
Copy Markdown
Collaborator

Summary

Adds richer CLI output for the run and preview commands:

  • run currently prints only "Output written to: <path>" — after this PR it prints a full summary block (entity counts by label, failed record details, rewrite evaluation metrics)
  • preview currently dumps a raw df.to_string() — after this PR it prints readable per-record blocks with the key output fields
  • New --trace flag on run writes the full trace_dataframe to a sidecar file

No new dependencies — all rendering uses stdlib + pandas.

Plan

See plans/cli-display/plan.md for the full implementation plan including output shapes, edge cases, function signatures, and test list.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring

Testing

  • make test passes locally
  • make check passes locally (format + lint + typecheck + lock-check)
  • Added/updated tests for changes

Documentation

  • If docs changed: make docs-build passes locally

Related Issues

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread plans/cli-display/plan.md

```
Output written to: /path/to/data_anonymized.csv
Trace written to : /path/to/trace.csv ← only when --trace given
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

say "trace dataset"

Comment thread plans/cli-display/plan.md
email : 312
ssn : 47
... and 3 more
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's good to add some context about what happened besides what the user ran. sth like:

Mode : replace (redact) 
Source : data.csv (1,234 rows) 
Output : /path/to/data_anonymized.csv (1,234 rows, 1.2 MB) 
Trace : /path/to/trace.csv ← only when --trace given Elapsed : 1m 23s

Comment thread plans/cli-display/plan.md

```
--- Failed Records (3) ---
record_id=abc123 step=detect reason=LLM timeout
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we make this as the group failures? sth like Group by (step, reason, count):

--- Failed Records (12) ---
  detect    LLM timeout         × 8
  replace   JSON parse error    × 3
  detect    GLiNER OOM          × 1

Tip: run with --debug to see per-record stack traces, or --failed-output failed.csv to export failures for triage.
Add --failed-output PATH (parallel to --trace): writes a small dataframe of record_id, step, reason for downstream triage.
The "Tip" footer turns a wall of text into a next action.

Comment thread plans/cli-display/plan.md
```python
from anonymizer.interface.cli._output import print_preview, print_run_summary, write_result, write_trace
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adding some TTY-aware visual polish could be very helpful to distinguish different sections of the output in CLI. The plan's mockups are pure ASCII, which is fine — but a few cheap conditionals (no new deps) make the output much more scannable:
This could be sth like, green for the output path line, red for the failures count when > 0, dim for label rows. Bold section headers (--- Summary ---) so they don't disappear in long terminal scrollback.
Auto-disable on non-TTY, NO_COLOR env, or adding a --no-color flag.

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.

2 participants