feat(cli): improved run/preview display and --trace flag#125
feat(cli): improved run/preview display and --trace flag#125lipikaramaswamy wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
|
||
| ``` | ||
| Output written to: /path/to/data_anonymized.csv | ||
| Trace written to : /path/to/trace.csv ← only when --trace given |
There was a problem hiding this comment.
say "trace dataset"
| email : 312 | ||
| ssn : 47 | ||
| ... and 3 more | ||
| ``` |
There was a problem hiding this comment.
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
|
|
||
| ``` | ||
| --- Failed Records (3) --- | ||
| record_id=abc123 step=detect reason=LLM timeout |
There was a problem hiding this comment.
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.
| ```python | ||
| from anonymizer.interface.cli._output import print_preview, print_run_summary, write_result, write_trace | ||
| ``` | ||
|
|
There was a problem hiding this comment.
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.
Summary
Adds richer CLI output for the
runandpreviewcommands:runcurrently 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)previewcurrently dumps a rawdf.to_string()— after this PR it prints readable per-record blocks with the key output fields--traceflag onrunwrites the fulltrace_dataframeto a sidecar fileNo new dependencies — all rendering uses stdlib + pandas.
Plan
See
plans/cli-display/plan.mdfor the full implementation plan including output shapes, edge cases, function signatures, and test list.Type of Change
Testing
make testpasses locallymake checkpasses locally (format + lint + typecheck + lock-check)Documentation
make docs-buildpasses locallyRelated Issues