sadpandajoe opened a new pull request, #44578: URL: https://github.com/apache/superset/pull/44578
## Summary `Python Unit Test Results` is intermittently red on master (e.g. commit `7c7b3ad`, https://github.com/apache/superset/runs/107216579008), always on `test_committed_template_matches_a_fresh_extraction`. The check-run annotation itself reports "1 out of 2 runs failed" — the flake signature. Extracting the exact same commit against a clean checkout with the CI extraction command reproduces **zero** drift, so `messages.pot` is not actually out of sync; the test itself is racy. ## Root cause `check_pot_drift.py::extract_fresh` runs `pybabel extract` with `cwd=ROOT_DIR` over `.` — the live working directory. `superset-python-unittest.yml` runs the suite with `pytest -n auto --dist loadfile`, so many worker processes share this one checkout while the test executes. `pybabel extract` walks the entire tree it's pointed at, so any file a sibling worker's test transiently writes into the checkout during that window can leak into the msgid set, flipping the test red or green depending on timing. ## Fix Snapshot the tracked tree with `git archive` into a private temp directory and run the extraction there instead of against the live checkout, so the result can no longer be perturbed by concurrent filesystem activity from other workers. `git stash create` (falling back to `HEAD` when there's nothing to stash) is used to pick the archive ref, so uncommitted tracked edits are still visible to the check, preserving the existing local pre-commit workflow. The auxiliary `git stash create` / `git archive` calls intentionally go through `subprocess.Popen` rather than `subprocess.run`, since the module's existing unit tests patch `subprocess.run` to fake the single "run pybabel" call — using `run` for these too would have been intercepted by that same patch. ## Test plan - [x] Ran the actual CI extraction (`pybabel extract` with the same flags) against a clean checkout of the failing commit (`7c7b3ad`) — 0 missing, 0 stale, confirming there's no real translation drift. - [x] Ran the new `extract_fresh()` end-to-end against the same checkout — 0 missing, 0 stale. - [x] Ran all 7 existing tests in `tests/unit_tests/scripts/translations/check_pot_drift_test.py` (the 4 that mock `subprocess.run` plus the real integration test) — all pass unmodified. - [x] Simulated the race directly: spawned a thread that writes an untracked `.py` file containing a translatable string into the live checkout mid-extraction. Before this fix that file would leak into the msgid set; after this fix, `diff()` correctly ignores it. - [x] `ruff check` / `ruff format --check` pass on the changed file. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
