Skip to content

[doc] Give the Read the Docs build a larger pip retry budget - #65574

Merged
elliot-barn merged 1 commit into
masterfrom
elliot-barn/docs-rtd-pip-retries
Aug 19, 2026
Merged

elliot-barn merged 1 commit into
masterfrom
elliot-barn/docs-rtd-pip-retries

Conversation

@elliot-barn

Copy link
Copy Markdown
Collaborator

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 #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.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 cats 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.

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]>
@elliot-barn
elliot-barn requested review from a team as code owners August 18, 2026 23:20

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread .readthedocs.yaml
Comment on lines +85 to +89
- mkdir -p ~/.config/pip
- |
echo "[global]" > ~/.config/pip/pip.conf
echo "retries = 10" >> ~/.config/pip/pip.conf
cat ~/.config/pip/pip.conf

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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

@elliot-barn elliot-barn added the go add ONLY when ready to merge, run all tests label Aug 18, 2026
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core labels Aug 19, 2026
@elliot-barn
elliot-barn merged commit 2b9ae63 into master Aug 19, 2026
6 checks passed
@elliot-barn
elliot-barn deleted the elliot-barn/docs-rtd-pip-retries branch August 19, 2026 02:13
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core docs An issue or change related to documentation go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant