Skip to content

fix(translation_graph): prevent CI failure when writing translation stats#651

Open
dimasd-angga wants to merge 1 commit into
pyOpenSci:mainfrom
dimasd-angga:fix/issue-649-priority-bug-troubleshoot-translation-js
Open

fix(translation_graph): prevent CI failure when writing translation stats#651
dimasd-angga wants to merge 1 commit into
pyOpenSci:mainfrom
dimasd-angga:fix/issue-649-priority-bug-troubleshoot-translation-js

Conversation

@dimasd-angga
Copy link
Copy Markdown

Summary

Translated-language Sphinx builds in CI were failing with FileNotFoundError when write_translation_stats tried to open _static/translation_stats.json. The hook assumed the _static directory already existed and that stats should always be written, which isn't true when the build errored before Sphinx materialised the output tree or when no .po files were collected. This PR makes the writer defensive in those two cases and ensures the parent directory is created before opening the file.

Changes

  • In _ext/translation_graph.py, early-return from write_translation_stats when Sphinx passes a non-None exception, so a failed build doesn't trigger a second failure inside the build-finished hook.
  • Early-return when get_translation_stats() returns no entries, instead of writing an empty stats file for builds that have no translation sources.
  • Wrap app.outdir in Path(...) and call out_path.parent.mkdir(parents=True, exist_ok=True) before writing, so the _static directory is guaranteed to exist regardless of build configuration.

Testing

Ran nox -s docs-test locally; the suite completes without the FileNotFoundError previously seen in CI. No new tests were added — the change is a guard inside a Sphinx build-finished callback, and the existing docs build exercises the path.

Notes

The two new early-returns log at info level so it's still visible in CI output when stats are skipped, which should make future debugging easier without changing the build outcome.

Closes #649

…tats

The translation stats writer assumed `_static` existed and that a stats file should always be produced, causing `FileNotFoundError` in CI when the build errored or no `.po` files were present. Skip the write on build failure or empty stats, and ensure the output directory exists before writing so translated-language Sphinx builds finish cleanly.
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.

PRIORITY bug: troubleshoot translation.json file missin in CI

1 participant