Skip to content

Add --json output to breeze ui check-translation-completeness - #75831

Merged
potiuk merged 1 commit into
apache:mainfrom
aaiss0927:breeze-translation-completeness-json
Nov 1, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
aaiss0927:breeze-translation-completeness-json

Conversation

@aaiss0927

Copy link
Copy Markdown
Contributor

Add a --json flag to breeze ui check-translation-completeness that prints the completeness report as a single machine-readable JSON document on stdout, following the pattern breeze ci verify --json established 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 as breeze ci verify --json: console narration is suppressed (sent to stderr with --verbose), stdout carries nothing but the JSON document (pipe-safe for jq), and ctx.meta[SKIP_LOCAL_REPRODUCTION] is set so CI's reproduction epilogue cannot pollute the contract. If the computation aborts (e.g. a locale without a PLURAL_SUFFIXES entry, or an unreadable locale file), the suppressed narration is replayed to stderr so the error is not silent — whether the abort was a sys.exit() or an unexpected exception.
  • apply_translation_modifications() — the --add-missing / --remove-unused block is extracted unchanged so both output modes share the exact same modification semantics (--json reports the post-modification state).
  • Tests (15 new, covering the report builder, the CLI JSON mode, the complete-verdict semantics, and both error-replay paths), docs (10_ui_tasks.rst, i18n README.md, the translation agent skill's validation step), option registration in ui_commands_config.py, and regenerated command image + hash.

Output shape

$ breeze ui check-translation-completeness --language ko --json | jq '.languages.ko.totals'
{
  "required": 1296,
  "required_base_en": 1296,
  "required_plural": 0,
  "translated": 1253,
  "missing": 43,
  "todos": 0,
  "unused": 13,
  "coverage": 96.7
}

Per-file entries additionally carry missing_keys / unused_keys (sorted), and the top level carries complete, 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

  • Default output is byte-identical. Verified by capturing the full output of the parent commit and this commit with PYTHONHASHSEED=0 (the printed key lists come from list(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.
  • Exit-code semantics unchanged per the original design in Check if plural forms are correct for languages. #55327: missing translations never fail the command; --json exits 2 for an invalid/en --language (before printing anything to stdout), exactly like the table mode.
  • --language, --add-missing, --remove-unused all compose with --json.

Test

  • uv run pytest dev/breeze/tests/test_ui_commands.py — 48 passed (33 existing + 15 new).
  • Byte-identical default output proof as described above (all locales + --language ko).
  • Cross-checked the JSON against the rendered tables on real data: all 10 ko per-file rows × 8 numeric columns plus the All files row match, and all 20 languages' total coverage values equal the "Total Coverage per Language" table.
  • Error paths: --json --language xx and --json --language en exit 2 with empty stdout; a locale without PLURAL_SUFFIXES and a malformed locale file both keep stdout clean and replay the narration to stderr; --json output re-parses with python -m json.tool and is byte-stable across runs (sorted key lists).

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    Claude Fable 5

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {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.

@aaiss0927

Copy link
Copy Markdown
Contributor Author

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):

  • Test examples of PROD image building: apt-get install build-essential libopenmpi-dev in the extending/add-build-essential-extend docker example failed with "Unable to correct problems, you have held broken packages" (Debian archive dependency conflict at build time).
  • Java SDK e2e test: the Java worker image build failed at apt-get install temurin-17-jre (Adoptium repo, exit code 100) before any test ran.

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
@potiuk
potiuk force-pushed the breeze-translation-completeness-json branch from 808d1cf to 6042121 Compare November 1, 2026 22:38

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

@potiuk
potiuk enabled auto-merge (squash) November 1, 2026 22:38
@potiuk
potiuk merged commit eb47cc9 into apache:main Nov 1, 2026
149 of 150 checks passed
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.

Breeze: add --json output to check-translation-completeness

2 participants