docs: don't abort the docs build when BUILD_PREVIEW/BUILD_LATEST is set but empty - #2567
Open
LeSingh1 wants to merge 1 commit into
Open
docs: don't abort the docs build when BUILD_PREVIEW/BUILD_LATEST is set but empty#2567LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
…mpty
Both Sphinx configs read the two docs-build flags with a bare int():
if int(os.environ.get("BUILD_PREVIEW", 0)):
os.environ.get returns the empty string, not the default, when a variable is
exported but empty -- and the build scripts that drive these configs already
treat that state as "not set":
# cuda_core/docs/build_docs.sh, cuda_python/docs/build_docs.sh
if [[ "${LATEST_ONLY}" == "1" && -z "${BUILD_PREVIEW:-}" && -z "${BUILD_LATEST:-}" ]]; then
export BUILD_LATEST=1
fi
So the shell layer says empty means unset, then conf.py raises on it:
ValueError: invalid literal for int() with base 10: ''
taking down the whole docs build from inside conf.py, before any page is
rendered. `BUILD_PREVIEW= ./build_docs.sh latest-only` is enough to hit it.
Add an _env_flag helper to each config and route all ten call sites through
it (six in cuda_core, four in cuda_python). Unset, empty, whitespace-only and
"0" are all false; any other value is true, so a non-numeric spelling such as
BUILD_LATEST=true is honoured rather than aborting the build.
The helper is duplicated across the two configs deliberately, matching the
existing duplication of _html_baseurl between them.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Both Sphinx configs read the two docs-build flags with a bare
int():os.environ.get(name, default)returns the empty string, not the default, when a variable is exported but empty. And the build scripts that drive these configs already treat that state as "not set":-zis explicit: empty means unset. Thenconf.pydisagrees and raises:That kills the docs build from inside
conf.py, before any page is rendered. Measured against the exact expression onmain:BUILD_PREVIEWmainFalse"1"True"0"False""ValueError" "ValueError"true"ValueErrorBUILD_PREVIEW/BUILD_LATESTare set to"1"by.github/actions/get_pr_number, so CI does not hit this today — it bites anyone driving the scripts by hand or from a wrapper that exports the variable unconditionally, which is precisely the casebuild_docs.shwrote a-ztest for.Fix
Add an
_env_flaghelper to each config and route all ten call sites through it. Unset, empty, whitespace-only and"0"are false; any other value is true, soBUILD_LATEST=trueis honoured rather than aborting the build. Integer values keep their exact current meaning.The helper is duplicated across the two configs deliberately — they already duplicate
_html_baseurlbetween them, and a shared module would mean restructuringcuda_python/docs/exts/, which is more churn than this warrants.Verification
conf.pyhas no test home in this repo (nothing imports or exercises either file outside a Sphinx run), so this ships without a unit test — I want to be explicit about that rather than invent a contrived one. What I did verify:_env_flagfrom each committed config via AST and exercised it directly, then reverted both files toupstream/mainand ran the same probe against the original expression:ruff check/ruff format --checkandpython -m py_compileclean on both files.upstream/mainfor the probe, then restored withgit restore --source=HEAD --worktree, wrapped intry/finally.git diff --cachedandgit diffboth empty afterwards.If you would rather have this as a shared helper under
cuda_python/docs/exts/with a test, say the word and I will restructure it.