Repository navigation
[doc] Give the Read the Docs build a larger pip retry budget - #65574
Conversation
files.pythonhosted.org has been returning intermittent 502s (pypi/support#11895). The docs build installs a hash-pinned lock file in one pip invocation, so a single failed wheel fetch fails the whole build, and pip's default of 5 retries with exponential backoff gives up after about 8 seconds of sleeping. Raised to 10 via a pip config file rather than PIP_RETRIES, because the install is python.install, run by Read the Docs rather than by us, and each build-job command runs in its own shell so an exported variable would not reach it. pip reads ~/.config/pip/pip.conf on every invocation in the build, including that one. Only the retry count changes. The observed failures are immediate 502 responses rather than hangs, so raising the timeout would lengthen the worst case without making any fetch more likely to succeed. Signed-off-by: elliot-barn <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request updates the .readthedocs.yaml configuration to increase pip's retry budget to 10 during the documentation build, mitigating intermittent 502 errors from PyPI. The reviewer suggested a more robust approach to configuring pip by using the built-in pip config set command instead of manually creating directories and writing to the configuration file with echo redirections.
| - mkdir -p ~/.config/pip | ||
| - | | ||
| echo "[global]" > ~/.config/pip/pip.conf | ||
| echo "retries = 10" >> ~/.config/pip/pip.conf | ||
| cat ~/.config/pip/pip.conf |
There was a problem hiding this comment.
Instead of manually creating the directory and overwriting the pip.conf file using echo redirections, you can use the built-in pip config set command. This is more robust, automatically creates any necessary directories/files, and preserves any other existing configurations instead of overwriting them.
- pip config set global.retries 10
- pip config list…ject#65574) ## Description `files.pythonhosted.org` has been returning intermittent 502s (pypi/support#11895). The Read the Docs build installs `doc/requirements-doc.lock.txt` in a single pip invocation, so one failed wheel fetch fails the whole build. pip's default is 5 retries on an exponential backoff, which exhausts after roughly 8 seconds of sleeping — well short of the observed fault duration. This raises it to 10 for that build only. **Why a config file rather than `PIP_RETRIES`.** The install is `python.install`, run by Read the Docs rather than by us, so there is no command line of ours to add a flag to. Environment variables do not help either: each entry under `build.jobs` runs in its own shell, so an `export` in one does not reach the install step. pip reads `~/.config/pip/pip.conf` on every invocation in the build environment, including RTD's own, which makes it the one place that covers it. **Why only the retry count.** Every failure observed in this family is an immediate 502 response, not a hang, so raising `timeout` would only lengthen the worst case without making any individual fetch more likely to succeed. Worth setting expectations: this is a mitigation, not a fix. Measurements on a CI build of the same fault showed in-process retries have limited power against it — the client stays pinned to the same CDN edge across attempts — so this narrows the window rather than closing it. The structural fix is a caching index in front of PyPI, which is being wired up for CI in ray-project#65571 but cannot serve Read the Docs, since RTD builders run outside the network where that mirror lives. ## Related issues Upstream cause: pypi/support#11895. Not a duplicate: no open PR touches `.readthedocs.yaml`; ray-project#65571 and ray-project#65518 address the same upstream fault on the CI side and do not affect RTD builds. ## Testing - `.readthedocs.yaml` parses and the job keys are as intended: `post_checkout`, `pre_install`, `build`, with `python.install` untouched. - The `pre_install` snippet is valid shell (`bash -n`) and deliberately avoids the constructs the RTD job runner is documented in this file as mishandling: no `printf` with escape formats, no backslash escapes, no shell comments inside the block. - It `cat`s the file it writes, so the build log will show the effective config and confirm the step ran. - Not verified end to end: whether RTD's install step picks the config up in their environment. That is what the first build on this PR will show, and the failure mode if it does not is simply the status quo. AI assistance (Claude Code) was used for this change. Signed-off-by: elliot-barn <[email protected]>
Description
files.pythonhosted.orghas been returning intermittent 502s (pypi/support#11895). The Read the Docs build installsdoc/requirements-doc.lock.txtin a single pip invocation, so one failed wheel fetch fails the whole build. pip's default is 5 retries on an exponential backoff, which exhausts after roughly 8 seconds of sleeping — well short of the observed fault duration.This raises it to 10 for that build only.
Why a config file rather than
PIP_RETRIES. The install ispython.install, run by Read the Docs rather than by us, so there is no command line of ours to add a flag to. Environment variables do not help either: each entry underbuild.jobsruns in its own shell, so anexportin one does not reach the install step. pip reads~/.config/pip/pip.confon every invocation in the build environment, including RTD's own, which makes it the one place that covers it.Why only the retry count. Every failure observed in this family is an immediate 502 response, not a hang, so raising
timeoutwould only lengthen the worst case without making any individual fetch more likely to succeed.Worth setting expectations: this is a mitigation, not a fix. Measurements on a CI build of the same fault showed in-process retries have limited power against it — the client stays pinned to the same CDN edge across attempts — so this narrows the window rather than closing it. The structural fix is a caching index in front of PyPI, which is being wired up for CI in #65571 but cannot serve Read the Docs, since RTD builders run outside the network where that mirror lives.
Related issues
Upstream cause: pypi/support#11895. Not a duplicate: no open PR touches
.readthedocs.yaml; #65571 and #65518 address the same upstream fault on the CI side and do not affect RTD builds.Testing
.readthedocs.yamlparses and the job keys are as intended:post_checkout,pre_install,build, withpython.installuntouched.pre_installsnippet is valid shell (bash -n) and deliberately avoids the constructs the RTD job runner is documented in this file as mishandling: noprintfwith escape formats, no backslash escapes, no shell comments inside the block.cats the file it writes, so the build log will show the effective config and confirm the step ran.AI assistance (Claude Code) was used for this change.