Repository navigation
Add --json output to breeze ui check-translation-completeness - #75831
Conversation
|
Thanks @bbovenzi for approving the workflow run! The run came back 136/138 green — the two failures are infrastructure-level and unrelated to this change (both are apt repository hiccups in PROD-image jobs during the same window):
Could a committer re-run the two failed jobs when convenient? The breeze changes themselves are fully green (Breeze unit tests + static checks). Thanks! |
The checker computed its per-file statistics inside the rich table rendering loop, so the report existed only as terminal output. Extract the aggregation into build_completeness_report() and add a --json flag that prints the same data as a single JSON document on stdout — following the breeze ci verify --json pattern (apache#73241): narration is suppressed (or sent to stderr with --verbose) so the output can be piped straight to jq. The default output stays byte-identical, exit-code semantics are unchanged (apache#55327), and the existing --language/--add-missing/ --remove-unused flags compose with --json. closes: apache#75772 Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01A18rBgPJ6X4oXAzsecJjnz
808d1cf to
6042121
Compare
potiuk
left a comment
There was a problem hiding this comment.
Thanks — clean refactor. Pulling the aggregation into build_completeness_report() so the tables and the JSON share one source is the right shape, and the stdout contract matches breeze ci verify --json (narration goes to stderr or is replayed on abort). The two red jobs are apt mirror hiccups in the PROD image tests; I've rebased onto main so CI reruns, with auto-merge on.
Drafted-by: Claude Code (Claude Opus 5); reviewed by @potiuk before posting
Add a
--jsonflag tobreeze ui check-translation-completenessthat prints the completeness report as a single machine-readable JSON document on stdout, following the patternbreeze ci verify --jsonestablished in #73241.closes: #75772
What changed
build_completeness_report()— the per-file aggregation (required/translated/missing/TODO/unused counts, coverage, and the sorted missing/unused key lists) used to live inside the rich-table rendering loop; it is now a pure function, and the table renderer and the JSON serializer consume the same dict, so the two outputs cannot drift apart.--json— boolean flag, same shape asbreeze ci verify --json: console narration is suppressed (sent to stderr with--verbose), stdout carries nothing but the JSON document (pipe-safe forjq), andctx.meta[SKIP_LOCAL_REPRODUCTION]is set so CI's reproduction epilogue cannot pollute the contract. If the computation aborts (e.g. a locale without aPLURAL_SUFFIXESentry, or an unreadable locale file), the suppressed narration is replayed to stderr so the error is not silent — whether the abort was asys.exit()or an unexpected exception.apply_translation_modifications()— the--add-missing/--remove-unusedblock is extracted unchanged so both output modes share the exact same modification semantics (--jsonreports the post-modification state).complete-verdict semantics, and both error-replay paths), docs (10_ui_tasks.rst, i18nREADME.md, the translation agent skill's validation step), option registration inui_commands_config.py, and regenerated command image + hash.Output shape
Per-file entries additionally carry
missing_keys/unused_keys(sorted), and the top level carriescomplete, which mirrors the table verdict exactly (file-set differences, missing keys, or TODOs among the reported locales; unused keys alone do not fail it — same as today).Backwards compatibility
PYTHONHASHSEED=0(the printed key lists come fromlist(set), so ordering is only comparable with a fixed hash seed — a pre-existing property) and diffing: zero differences for the all-locales run and for--language ko.--jsonexits 2 for an invalid/en--language(before printing anything to stdout), exactly like the table mode.--language,--add-missing,--remove-unusedall compose with--json.Test
uv run pytest dev/breeze/tests/test_ui_commands.py— 48 passed (33 existing + 15 new).--language ko).koper-file rows × 8 numeric columns plus theAll filesrow match, and all 20 languages' total coverage values equal the "Total Coverage per Language" table.--json --language xxand--json --language enexit 2 with empty stdout; a locale withoutPLURAL_SUFFIXESand a malformed locale file both keep stdout clean and replay the narration to stderr;--jsonoutput re-parses withpython -m json.tooland is byte-stable across runs (sorted key lists).Was generative AI tooling used to co-author this PR?
Claude Fable 5
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.