Repository navigation
[docs] Pre-bake intersphinx inventory snapshots - #64977
Conversation
Commit snapshots of the 26 third-party objects.inv inventories under doc/source/_intersphinx/ and point intersphinx_mapping at the local file first, falling back to the upstream URL only if a snapshot is missing. This avoids fetching every inventory over the network at the start of every Sphinx build (~20-60s, and an intermittent flake source; the pandas and scipy mirrors go through GitHub release-asset redirects to signed blob URLs). Add doc/source/_intersphinx/refresh.py to rebuild the snapshots (it reads the target list straight from conf.py so it can't drift) plus a README documenting the refresh cadence, tied to the DOC-932 dependency-upgrade cadence. Verified with Sphinx's own inventory loader (network disabled): all 26 inventories resolve from local files with zero network calls on both Sphinx 8.2.3 (current) and 9.1.0 (the in-progress upgrade target). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: Ronny Roland <[email protected]>
The refresh cadence documented alongside the snapshots pointed at DOC-932,
which is closed and was never a cadence: it was a one-off epic to catch Ray's
docs pins up to current stable lines.
The hook was also wrong in principle. Every entry in `_intersphinx_targets`
points at upstream's *moving* docs -- 19 explicit `stable`/`latest`/`main` and
7 unversioned roots, none pinned to a version. An inventory changes when the
upstream project releases, not when Ray bumps a pin, so tying the refresh to
Ray's own dependency upgrades would not track the thing that actually drifts.
Document what staleness costs, which the original text understated. Sphinx
defaults `intersphinx_cache_limit` to 5 days and it is unset here, so today
published builds always fetch fresh and PR builds are at most 5 days stale.
Committed snapshots replace that with an unbounded window, and the two failure
modes it bounds are not symmetric:
- upstream ADDS a symbol the docs then reference: fails `-W` loudly, fixed by
refreshing; and
- upstream REMOVES or renames a referenced symbol: the stale snapshot still
resolves it, so the build stays green and emits a link to a page that no
longer exists. Silent, and `make linkcheck` is not wired into CI.
The refresh is what surfaces the silent case -- the fresh inventory drops the
symbol, so the stale reference fails on the refresh PR's `-W` build. State that
a refresh must land as a reviewed PR and never be auto-merged, since that build
is the whole safety net.
Also correct the sphinx-fix skill, whose guidance this change invalidates:
`intersphinx-inventory-unreachable` told you to re-run the build first, but with
snapshots committed a green re-run only means the network came back while the
missing snapshot is still missing. Both inventory locations must fail to reach
that warning, so a missing snapshot is now the first thing to check. Goldens
regenerated; `sphinx_fix.py --selftest` passes (16 fixtures, 15 rules).
Signed-off-by: Ronny Roland <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces local caching for third-party Sphinx inventories under doc/source/_intersphinx/ to make documentation builds faster and more resilient to network failures. It includes a refresh.py script to update these snapshots, updates conf.py to prioritize local files, and adds documentation. Feedback on the changes suggests specifying UTF-8 encoding when reading conf.py for Windows compatibility, wrapping local file writes in a try-except block to handle I/O errors gracefully, and flattening the inventory mapping in conf.py to prevent potential type errors with tuple fallbacks.
| heavy import-time side effects (it rewrites sys.path and registers custom | ||
| Sphinx extensions). | ||
| """ | ||
| tree = ast.parse(CONF_PY.read_text(), filename=str(CONF_PY)) |
There was a problem hiding this comment.
On Windows platforms, Path.read_text() uses the system's default locale encoding (e.g., CP1252) by default, which can cause a UnicodeDecodeError when parsing conf.py if it contains non-ASCII characters (such as the em-dash — in the announcement banner). Specifying encoding="utf-8" ensures cross-platform compatibility and robustness.
| tree = ast.parse(CONF_PY.read_text(), filename=str(CONF_PY)) | |
| tree = ast.parse(CONF_PY.read_text(encoding="utf-8"), filename=str(CONF_PY)) |
There was a problem hiding this comment.
Applied in b9698b4, thanks — this is a real bug.
Confirmed the premise: conf.py carries 9 non-ASCII bytes (em-dashes, U+2014). The failure mode splits by locale rather than always raising, though — cp1252 decodes those bytes silently wrong (mojibake, no exception), while cp932 and gbk raise UnicodeDecodeError at the first one. Explicit encoding="utf-8" is the right fix either way, and I noted the split in a comment so nobody "simplifies" it back later.
| try: | ||
| data = fetch(url) | ||
| except (requests.RequestException, OSError) as err: | ||
| print(f" FAIL {name}\n {url}\n {err}") | ||
| failures.append(name) | ||
| continue | ||
| if not data.startswith(INVENTORY_MAGIC): | ||
| print( | ||
| f" FAIL {name}\n {url}\n" | ||
| f" not a Sphinx inventory (starts with {data[:40]!r})" | ||
| ) | ||
| failures.append(name) | ||
| continue | ||
| # Atomic write so an interrupted run never leaves a partial snapshot. | ||
| tmp = dest.with_name(dest.name + ".tmp") | ||
| tmp.write_bytes(data) | ||
| tmp.replace(dest) | ||
| print(f" ok {name:<20} {len(data):>9,d} bytes <- {url}") |
There was a problem hiding this comment.
The file write and replace operations (tmp.write_bytes and tmp.replace) are currently outside the try...except block. If a local I/O error occurs (such as permission denied or disk full), the script will crash immediately instead of gracefully logging the failure and continuing to refresh the remaining targets. Moving these operations inside the try block improves the script's resilience.
| try: | |
| data = fetch(url) | |
| except (requests.RequestException, OSError) as err: | |
| print(f" FAIL {name}\n {url}\n {err}") | |
| failures.append(name) | |
| continue | |
| if not data.startswith(INVENTORY_MAGIC): | |
| print( | |
| f" FAIL {name}\n {url}\n" | |
| f" not a Sphinx inventory (starts with {data[:40]!r})" | |
| ) | |
| failures.append(name) | |
| continue | |
| # Atomic write so an interrupted run never leaves a partial snapshot. | |
| tmp = dest.with_name(dest.name + ".tmp") | |
| tmp.write_bytes(data) | |
| tmp.replace(dest) | |
| print(f" ok {name:<20} {len(data):>9,d} bytes <- {url}") | |
| try: | |
| data = fetch(url) | |
| if not data.startswith(INVENTORY_MAGIC): | |
| print( | |
| f" FAIL {name}\n {url}\n" | |
| f" not a Sphinx inventory (starts with {data[:40]!r})" | |
| ) | |
| failures.append(name) | |
| continue | |
| # Atomic write so an interrupted run never leaves a partial snapshot. | |
| tmp = dest.with_name(dest.name + ".tmp") | |
| tmp.write_bytes(data) | |
| tmp.replace(dest) | |
| except (requests.RequestException, OSError) as err: | |
| print(f" FAIL {name}\n {url}\n {err}") | |
| failures.append(name) | |
| continue | |
| print(f" ok {name:<20} {len(data):>9,d} bytes <- {url}") |
There was a problem hiding this comment.
Applied in b9698b4 — agreed, and it mattered more than it looks.
Two adjustments to the suggested form:
- Kept the fetch and write failures as separate handlers. Merging them into one
tryloses the diagnostic: the message should name the URL when a download fails and the destination path when a write fails. SameFAIL/continuecontract, better error text. - Added
tmp.unlink(missing_ok=True)on the failure path. Without it a failed write leaves a stray<name>.inv.tmpin the source tree. That matters because the scheduled refresh job (anyscale/docs#2441) has a scope guard that fails the run if anything outsidedoc/source/_intersphinx/*.invis touched — so a disk-full error would have surfaced as a confusing "touched files outside" failure instead of the actual I/O error.
Verified by injecting OSError(28) on one target: reports FAIL with the errno message, leaves no .tmp, writes no partial file, does not stop the other targets, still exits 1.
| intersphinx_mapping = { | ||
| name: (base_url, (f"_intersphinx/{name}.inv", inventory)) | ||
| for name, (base_url, inventory) in _intersphinx_targets.items() | ||
| } |
There was a problem hiding this comment.
If a future target in _intersphinx_targets uses a tuple of fallback inventories instead of a single string or None, the current mapping comprehension will create a nested tuple structure (e.g., (local_path, (url1, url2))). Sphinx expects a flat tuple of strings/None for alternative inventory locations, and a nested tuple will cause a cryptic TypeError during the build. Flattening the tuple if inventory is already a tuple prevents this potential failure.
intersphinx_mapping = {
name: (
base_url,
(
(f"_intersphinx/{name}.inv", *inventory)
if isinstance(inventory, tuple)
else (f"_intersphinx/{name}.inv", inventory)
),
)
for name, (base_url, inventory) in _intersphinx_targets.items()
}There was a problem hiding this comment.
Not taking this one — I think it would make things worse, and I checked rather than assumed.
The contract for _intersphinx_targets is str | None, documented in the comment directly above it, and all 26 current values hold to it ({NoneType, str}). So the nested-tuple case is not reachable today.
The problem is that applying it to conf.py alone creates a latent divergence with refresh.py, which reads the same mapping. inventory_url() does if inventory: return inventory, so a tuple flows straight through to requests.get():
InvalidSchema: No connection adapters were found for
"('https://a/objects.inv', 'https://b/objects.inv')"
So with this change a future tuple would give a green docs build and a crashing monthly refresh job — the build tolerates the value, the refresh script does not. Failing consistently in one place is better than that, and today a tuple fails loudly at the first thing that touches it.
If we ever do want multiple upstream fallbacks per target, it should land in both files together, deliberately, with a test — not as defensive handling in one of them. Happy to file that as a follow-up if anyone actually wants tuple support; nothing has needed it so far.
Re-ran refresh.py so the initial snapshots don't land stale. Four of the 26 drifted in the six days since they were first captured: grpc 1.82.0 -> 1.83.0 (a real upstream minor release) pydantic content changed, same version string python 3.14 docs content changed transformers main moved That rate is the argument for the scheduled refresh in one line. Also corrects an overclaim in the previous commit's docs. It said every target points at upstream's *moving* docs with none pinned to a version. That is true of the base_urls, which is what I checked, but four targets set an explicit inventory URL and so resolve from somewhere else entirely: pandas -> frozen ray-project/pandas object-mirror-0.1.0 release asset scipy -> frozen ray-project/scipy object-mirror-0.1.0 release asset torch -> pinned docs/2.7/, while its links point at docs/stable/ tensorflow -> third-party GPflow mirror tracking its own master For the three frozen ones a refresh is a no-op and committing a snapshot changes nothing about their staleness -- the remote was already immutable. All of this is pre-existing conf.py behavior, not introduced here, but the README and refresh.py should not assert something narrower than the truth about when an inventory can change. Signed-off-by: Ronny Roland <[email protected]>
Two fixes from the gemini-code-assist review on #64977. Read conf.py as UTF-8 explicitly. conf.py carries 9 non-ASCII bytes (em-dashes, U+2014), and Path.read_text() without an encoding uses the locale default. The reviewer flagged UnicodeDecodeError; the failure actually splits by locale -- cp1252 decodes it silently wrong (mojibake) while cp932 and gbk raise. Either way the fix is to be explicit. Handle local write failures the way download failures are already handled. The atomic write sat outside the try, so a disk-full or read-only checkout tracebacked out of the loop and abandoned the remaining targets instead of recording a FAIL and continuing. Also unlink the temp file on that path: a stray <name>.inv.tmp would otherwise be left in the source tree, and the refresh workflow's scope guard (anyscale/docs#2441) rejects anything that isn't doc/source/_intersphinx/*.inv, so it would have failed the run with a confusing "touched files outside" message instead of the real I/O error. Kept the fetch failure and the write failure as separate handlers so the diagnostic still names the right thing -- the URL when a download fails, the destination path when a write fails. Verified: load_targets() still reads all 26 targets; an injected OSError on one target reports FAIL with the errno message, leaves no .tmp, writes no partial file, does not stop the other targets, and still exits 1. Signed-off-by: Ronny Roland <[email protected]>
Five days on from the last refresh, 3 of 26 inventories had drifted. All 26
downloaded cleanly; only these three changed:
python 3.14 +4 / -0 (PyErr_Display and its params)
transformers main +12 / -0 (GraniteMoeSWA* model docs)
pydantic - +0 / -33
Refreshing at this point rather than at merge time is deliberate. The snapshots
only need to be current when resolution flips from live fetches to the committed
files, and that happens the moment this merges -- which, with `go` already on, is
not a moment we control. A doc PR merged during the staleness window is built
against live inventories, so a cross-reference to a symbol upstream shipped in
the interim passes there and would only fail once master starts resolving from
disk.
The pydantic removals are the silent direction this change exists to catch:
pydantic dropped its re-exported pydantic-core internals (pydantic.main and
pydantic.plugin SchemaSerializer/SchemaValidator/ValidationError,
pydantic.types.PydanticCustomError, __pydantic_core_version__). Verified that
nothing under doc/source or python/ray references any of the 33, so no
cross-reference goes dead here; separately, conf.py's nitpick_ignore_regex
carries a blanket ("py:class", ".*") from #46103, so class references are not
what a -W build would have caught anyway.
Signed-off-by: Ronny Roland <[email protected]>
dstrodtman
left a comment
There was a problem hiding this comment.
Docs review: style pass plus build-behavior notes (non-blocking)
Review from Douglas Strodtman on the Anyscale documentation team. Claude Code assisted in producing it; I read every comment below and stand behind each one.
Two passes, kept separate below. The style pass checks prose against Ray's documentation style guide. The technical pass covers build behavior, where I have prior context from a Ray docs build-time audit rather than code ownership. Ray maintainers still own whether to take the change and how; nothing here is a merge gate, which is why this is a comment and not a request for changes. Happy to give the docs-side stamp once these and any maintainer feedback settle.
doc/source/_intersphinx/README.md is the only prose file here, and conf.py excludes _intersphinx/**, so it isn't a built page. That means no myst.html_meta front matter is needed and Vale doesn't gate it. I still reviewed it against the guide, since it lives under doc/source/ and contributors read it.
Already triaged, so I stayed out of it: the three gemini-code-assist threads on refresh.py and conf.py all have responses, including a well-argued decline on the tuple-flattening suggestion.
One factual correction, and it strengthens the argument
The "silent staleness" bullet says Ray's docs CI doesn't run linkcheck. It does: .buildkite/doc.rayci.yml has a doc: linkcheck step running make -C doc/ linkcheck_all, and that step is present at this PR's base commit (406c1212). What makes the failure mode genuinely silent is narrower and more convincing:
- the step is tagged
skip-on-premergeandsoft_fail: true, so it runs only after merge and never blocks; and conf.pysetslinkcheck_anchors = False, so it confirms a target page resolves but not the#anchorthat a symbol-level cross-reference actually points at.
Both details survive the argument you're making. The same sentence appears in the PR description, so it's worth fixing there too. Inline suggestion below.
What's clean
Every heading is sentence case, the code block is language-tagged with no $ prefixes, and the staleness trade-off is documented rather than left to be discovered. The bulk of the style findings are one recurring thing: the guide's sentence-structure rule asks you to avoid em dashes, en dashes, parentheticals, and semicolons and restructure instead. This file has 12 dashes and 4 semicolons in prose. Each suggestion below restructures a cluster rather than swapping punctuation.
Two questions, not style findings
- Is
_intersphinx/README.mddiscoverable enough where it is? A contributor hits the "refresh the snapshot" instruction from a build failure, and thesphinx-fixrule text is the likely entry point. Worth a sentence indoc/source/ray-contribute/pointing here? - Would it help to state in the README that
conf.pyexcludes this directory from the build, so nobody adds MyST syntax expecting it to render?
Nothing in refresh.py or conf.py drew a style finding. The added conf.py comments use "we," which the guide bans in docs prose, but code comments aren't docs prose and the surrounding comments already read that way. No change asked for.
Technical review
A second pass on behavior rather than prose. I've done a build-time audit of this surface, so this is informed input rather than a drive-by, but the design calls are yours.
Checked and correct:
doc/source/_intersphinx/is the right location, and it's the non-obvious one. Sphinx 8.2.3 resolves a non-URL inventory location through_fetch_inventory_file(inv_location=..., srcdir=srcdir)(sphinx/ext/intersphinx/_load.py:328), so the path is relative to the Sphinx source directory, notdoc/. A later cleanup that moves this todoc/_intersphinx/to get it out of the source tree would break resolution. Worth aconf.pycomment saying so.*.inv binaryin.gitattributesis right.binaryimplies-text -diff, so no CRLF normalization can corrupt a zlib payload on a Windows checkout, and the files produce no garbage diffs.exclude_patternskeeps the README andrefresh.pyout of the document set, so neither trips an orphan-toctree warning under-W.- Premerge scope is clean.
doc/source/conf.pymatchesdoc/*.pyand tagsdoc; the.invfiles and thedoc/.claude/skill files fall through to thedoc/skipping rule in.buildkite/test.rules.txt, so a future refresh PR touching only.invfiles triggers no library test steps. I checked this expecting the opposite and was wrong.
The -W safety net depends on PR previews doing a full rebuild
This is the one I'd want settled before merge, and it's a coupling with your own incremental-cache work rather than a defect in this change.
The README's argument for accepting silent staleness is that the refresh surfaces it: the fresh inventory drops the removed symbol, so the stale cross-reference fails on the refresh PR's -W build. That holds today, because .readthedocs.yaml runs make -C doc html, a full clean build, for every build including PR previews, after #64599 disabled the incremental path.
If the incremental path from #64277 comes back, which the comment at .readthedocs.yaml:59-69 explicitly contemplates once cache reuse is confirmed, the net stops working. doc/update_cache_env.py timestamps every entry in env.all_docs as fresh except the paths listed in pending_files.txt. A refresh PR changes only .inv binaries, which aren't documents, so no document is marked dirty, Sphinx re-reads nothing, and no cross-reference is re-resolved. The -W build goes green without exercising the gate it's supposed to be.
Two cheap ways out:
- Have a refresh PR take the clean path.
.readthedocs.yamlalready forcesrtd-fallbackon a structural signal (the delete-or-move guard), so an equivalent guard on a_intersphinx/*.invchange would be in keeping with what's there. - Or state the dependency in the README, so whoever re-enables the incremental path finds it.
Either way, the README currently states the net as unconditional, and that's the part I'd change regardless of which fix you choose.
intersphinx_mapping is the config key that discards the doctree cache
Not a blocker while the incremental path is off. Flagging it for when it returns. Those PR previews discarded the restored cache with [config changed ('intersphinx_mapping')], and this PR changes that value's shape from (base_url, str | None) to (base_url, (local_path, str | None)). Sphinx compares the normalized mapping, so a shape change is material to that comparison. Deriving the mapping from a single _intersphinx_targets literal is a determinism improvement on its own. When cache reuse gets re-measured, worth doing it with this mapping in place rather than assuming the earlier measurement carries over.
The optimization has no regression detection
By design, a missing or unreadable snapshot falls back to the network and logs an info message. That's the right robustness default and I'm not asking you to change it. The consequence is that every way this can quietly stop working, whether a filename typo, a target added to _intersphinx_targets without a snapshot, a relocated directory, or a corrupted file, degrades to "fetch over the network." That's invisible under -W and detectable only as build timing.
Since not fetching is the entire point, a build-time invariant would protect it: check that every name in _intersphinx_targets has a file on disk. No network call, so it stays safe under -W. Inline suggestion on conf.py.
Staleness is a cost on master and the desired behavior on a release branch
The README treats staleness as a uniform cost. It isn't, and the difference is the strongest unclaimed argument for this change.
Rebuilding a release tag today fetches whatever the upstream stable inventory happens to be on the day of the rebuild. Resolution for Ray 2.31's docs drifts with upstream forever and the build isn't reproducible. With snapshots, a tag carries the .inv files committed when it was cut, so resolution is frozen at the release epoch. On a release branch, "stale" and "pinned" are the same thing, and pinned is what you want.
That property currently holds by accident rather than by statement. Worth making it explicit in the README, including that the refresh job targets master only, so nobody later "improves" it into also refreshing release branches and silently destroys per-release reproducibility.
Two related facts that surprised me when I checked, and that bear on how far the version-fidelity argument can be pushed:
- 17 of the 26 targets aren't installed in the docs build at all.
aiohttp,composer,dask,datasets,grpc,gymnasium,horovod,lightgbm,nevergrad,pandas,pytorch_lightning,scipy,sklearn,tensorflow,torch,torchvision, andtransformersare all indoc/source/api_mock_imports.pyand mocked throughautodoc_mock_imports. Onlynumpy(2.4.6),pyarrow(19.0.1), andpydantic(2.12.4) are pinned and installed perpython/deplocks/docs/docbuild_depset_py3.11.lock. So for most targets there's no pinned version for an inventory to be faithful to, which makes the clock-based cadence the right call rather than a compromise. torchis the one target where the inventory is already version-pinned, todocs/2.7/objects.inv, while itsbase_urlpoints atdocs/stable/. That combination means torch resolution is frozen at 2.7 while the emitted links go to current stable, so a symbol that existed in 2.7 and has since been removed or moved already produces exactly the silent dead outbound link the README describes. That's live today and independent of this PR, but it's a concrete instance of the failure mode, and it makes the case that the mechanism is worth documenting.
Only two targets have an unstable inventory URL, and they're yours
Worth recording because it sharpens the flakiness argument. I resolved all 26 inventory URLs and followed redirects: 24 return 200 with no redirect at all. The only two that redirect are pandas and scipy, both 302 into release-assets.githubusercontent.com/github-production-release-asset/... with a hashed path and an expiring signed query string.
So the two most fragile fetches are the two ray-project mirror release assets, which is GitHub's normal release-asset behavior rather than upstream instability, and it's what the existing maintenance note in conf.py already warns against chasing. The snapshot helps most exactly where resolution is least stable. The README's "a couple of inventories" is accurate; naming it as two, and as the mirrors, would make it checkable.
Smaller note
intersphinx_timeout = 15 now governs only the fallback path, which is the path where it matters. No change needed; noting that it no longer exercises on a normal build.
| # Intersphinx inventory snapshots | ||
|
|
||
| This directory holds committed snapshots of the third-party Sphinx inventories |
There was a problem hiding this comment.
The guide's Soft-wrap prose rule asks for one logical line per paragraph and list item, no hard wrap at a fixed column. This file is hard-wrapped at ~79 columns throughout, which makes every future edit reflow a block instead of touching a line.
Worth a whole-file reflow. Every suggestion I left is already soft-wrapped, so accepting them moves in that direction, but the paragraphs I didn't comment on need the same treatment.
There was a problem hiding this comment.
Done as a whole-file reflow in 3e5a6a5 — every paragraph and list item is now one logical line, including the spans you didn't comment on (the intro, and the closing paragraph under "Refreshing").
Agreed on the reason, and it bit immediately: rewriting these paragraphs at 79 columns would have made this diff mostly reflow noise with the actual edits buried in it. The file is now +21/−63, and every remaining line is a real change.
| Without snapshots, every Sphinx build fetches every inventory over the network | ||
| before it can resolve a single cross-reference. That is slow (~20–60s) and | ||
| occasionally flaky — a couple of inventories are served through GitHub | ||
| release-asset redirects to signed, expiring blob-storage URLs, which are the | ||
| most fragile part of the build's startup and a plausible cause of intermittent | ||
| timeouts. |
There was a problem hiding this comment.
Restructures the parenthetical and the em dash per the sentence-structure rule, names GitHub as the actor for "are served," and spells out the unit ("20 to 60 seconds" rather than ~20-60s, which also clears Vale's Google.Units flag on the missing space).
| Without snapshots, every Sphinx build fetches every inventory over the network | |
| before it can resolve a single cross-reference. That is slow (~20–60s) and | |
| occasionally flaky — a couple of inventories are served through GitHub | |
| release-asset redirects to signed, expiring blob-storage URLs, which are the | |
| most fragile part of the build's startup and a plausible cause of intermittent | |
| timeouts. | |
| Without snapshots, every Sphinx build fetches every inventory over the network before it can resolve a single cross-reference. That costs roughly 20 to 60 seconds, and it's occasionally flaky. GitHub serves a couple of the inventories through release-asset redirects to signed, expiring blob-storage URLs. Those are the most fragile part of the build's startup and a plausible cause of intermittent timeouts. |
There was a problem hiding this comment.
Applied verbatim.
One extension of the same rule, since you flagged ~20-60s: the intro paragraph had "~two dozen others", which is the same tilde-abbreviation shape. Changed it to "about two dozen others" rather than leave one instance behind. Say if you'd rather I hadn't reached outside the span you marked.
| `intersphinx_mapping` in [`../conf.py`](../conf.py) is built to list the **local | ||
| snapshot first** and the upstream location second. Sphinx uses the first | ||
| inventory that loads, so: | ||
|
|
||
| - when the snapshot is present, the build resolves references from disk with | ||
| **no network fetch**; and | ||
| - if a snapshot is ever missing or unreadable, Sphinx transparently falls back | ||
| to the upstream URL (logged as an info message, *not* a build-breaking | ||
| warning). |
There was a problem hiding this comment.
Three things here: is built is passive with a nameable actor, the guide reserves bold for UI elements and definition-list terms rather than prose emphasis, and the ; and list separator is one of the semicolons the guide asks you to restructure away. Also drops "transparently" and "ever" as filler.
| `intersphinx_mapping` in [`../conf.py`](../conf.py) is built to list the **local | |
| snapshot first** and the upstream location second. Sphinx uses the first | |
| inventory that loads, so: | |
| - when the snapshot is present, the build resolves references from disk with | |
| **no network fetch**; and | |
| - if a snapshot is ever missing or unreadable, Sphinx transparently falls back | |
| to the upstream URL (logged as an info message, *not* a build-breaking | |
| warning). | |
| [`../conf.py`](../conf.py) builds `intersphinx_mapping` to list the local snapshot first and the upstream location second. Sphinx uses the first inventory that loads, so: | |
| - When the snapshot is present, the build resolves references from disk with no network fetch. | |
| - When a snapshot is missing or unreadable, Sphinx falls back to the upstream URL, logged as an info message rather than a build-breaking warning. |
There was a problem hiding this comment.
Applied verbatim.
| Generated cross-reference links still point at each project's live docs site — | ||
| only *resolution* uses the local snapshot, so the URLs Sphinx emits are the same | ||
| ones it emits today. What the snapshot does affect is *which* references resolve | ||
| at all; see the next section. |
There was a problem hiding this comment.
Em dash and semicolon. "today" is also on the guide's time-relative words list, and here it means "before this change," which reads more directly as a statement about what the change does and doesn't alter.
| Generated cross-reference links still point at each project's live docs site — | |
| only *resolution* uses the local snapshot, so the URLs Sphinx emits are the same | |
| ones it emits today. What the snapshot does affect is *which* references resolve | |
| at all; see the next section. | |
| Generated cross-reference links still point at each project's live docs site. Only *resolution* uses the local snapshot, so this change doesn't alter the URLs Sphinx emits. What a snapshot does affect is *which* references resolve at all. See the next section. |
There was a problem hiding this comment.
Applied verbatim.
| Most targets resolve against upstream's *moving* docs — `.../stable/`, | ||
| `.../latest/`, `.../main/`, or an unversioned root — so their inventory changes | ||
| when the upstream project *releases*, independently of anything Ray pins in its | ||
| own requirements. There is no Ray-side event to refresh against. | ||
|
|
||
| Four targets are the exception, because they set an explicit inventory URL | ||
| rather than deriving it from `base_url`: `pandas` and `scipy` read frozen | ||
| `object-mirror-*` release assets under `ray-project`, `torch` is pinned to | ||
| `docs/2.7/`, and `tensorflow` reads a third-party GPflow mirror that tracks its | ||
| own `master`. For the three frozen ones a refresh is a no-op — they change only | ||
| when someone re-cuts the mirror or repoints the URL — so committing a snapshot | ||
| of them changes nothing about their staleness. |
There was a problem hiding this comment.
Two em-dash pairs in four lines. The first becomes a colon introducing the list of URL shapes, the second becomes a sentence break.
| Most targets resolve against upstream's *moving* docs — `.../stable/`, | |
| `.../latest/`, `.../main/`, or an unversioned root — so their inventory changes | |
| when the upstream project *releases*, independently of anything Ray pins in its | |
| own requirements. There is no Ray-side event to refresh against. | |
| Four targets are the exception, because they set an explicit inventory URL | |
| rather than deriving it from `base_url`: `pandas` and `scipy` read frozen | |
| `object-mirror-*` release assets under `ray-project`, `torch` is pinned to | |
| `docs/2.7/`, and `tensorflow` reads a third-party GPflow mirror that tracks its | |
| own `master`. For the three frozen ones a refresh is a no-op — they change only | |
| when someone re-cuts the mirror or repoints the URL — so committing a snapshot | |
| of them changes nothing about their staleness. | |
| Most targets resolve against upstream's *moving* docs: `.../stable/`, `.../latest/`, `.../main/`, or an unversioned root. Their inventory therefore changes when the upstream project *releases*, independently of anything Ray pins in its own requirements. There's no Ray-side event to refresh against. | |
| Four targets are the exception, because they set an explicit inventory URL rather than deriving it from `base_url`: `pandas` and `scipy` read frozen `object-mirror-*` release assets under `ray-project`, `torch` is pinned to `docs/2.7/`, and `tensorflow` reads a third-party GPflow mirror that tracks its own `master`. For the three frozen ones a refresh is a no-op. They change only when someone re-cuts the mirror or repoints the URL, so committing a snapshot of them changes nothing about their staleness. |
There was a problem hiding this comment.
Applied verbatim.
| So these snapshots must be refreshed on a clock, and the refresh cadence is what | ||
| bounds two failure modes: |
There was a problem hiding this comment.
This paragraph is where the master-versus-release-branch distinction belongs, per the technical notes in the review body. As written, "these snapshots must be refreshed on a clock" reads as unconditional, and it's only true of master.
On a release branch or tag, a frozen snapshot is the correct behavior, not a debt: it makes cross-reference resolution reproducible at the release epoch instead of drifting with upstream on every rebuild, which is what happens today. The refresh job targeting master only is what preserves that, so it's worth stating as a design property rather than leaving implicit.
No suggestion block, because which way you word this depends on whether you also want to state the refresh job's branch scope here or in the "Refreshing" section below.
There was a problem hiding this comment.
Agreed, and this is the comment I'm most glad you left — I had the unconditional version in my head too, not just in the file.
Worded it as a design property at the end of the section, after the failure-mode list:
On a release branch or tag, the opposite holds: a frozen snapshot is the intended behavior rather than a debt. It pins cross-reference resolution to the release epoch, so rebuilding a release's docs later resolves against the inventories that release shipped with, instead of drifting with upstream on every rebuild the way a live fetch does. The refresh job targets
masteronly, which is what preserves that property.
The paragraph that over-claimed now opens with "On master, that leaves a clock as the only thing that can bound staleness", so the scope is set before the list rather than after it.
On your question of where to put the job's branch scope: I kept it here rather than in "Refreshing", because the master-only fact is doing load-bearing work in this section (it's the reason the two failure modes are a master concern) and is only incidental to the mechanics below. Splitting it across both sections meant saying it twice.
Worth adding that the freshness argument doesn't just fail to help a release branch — it actively inverts the risk. A fresher inventory is what breaks a release -W build: if upstream has dropped a symbol Ray still references, the stale snapshot resolves it quietly while a fresh one fails the build. That's the trade we want on master, where the refresh PR is the right place to discover it, and the opposite of what anyone wants at a release cut. This isn't hypothetical — refreshing this PR's snapshots two days ago, pydantic had dropped 33 symbols in 5 days (pydantic.main/pydantic.plugin SchemaSerializer/SchemaValidator/ValidationError, pydantic.types.PydanticCustomError, __pydantic_core_version__). Nothing under doc/source or python/ray references any of them, so it was a no-op here, but a release-time refresh is exactly how that becomes a red release build.
| A scheduled monthly job refreshes these snapshots and opens a PR when any of | ||
| them has drifted; the Read the Docs `-W` build on that PR is the gate. That | ||
| bounds staleness at roughly a month without depending on anyone remembering. | ||
| See [DOC-1050] for the job's ownership. |
There was a problem hiding this comment.
DOC-1050 resolves to anyscale1.atlassian.net, which no one outside Anyscale can open, so this line points a Ray contributor at a closed door for the one thing the paragraph tells them they may need: who owns the job.
Note that anyscale/docs#2441 isn't a usable substitute either. That repo is private, so swapping one link for the other leaves the same dead end. The options are to state ownership in prose with no link, or to drop the sentence and let the paragraph stand on the mechanism it already describes. I've suggested the second because ownership is yours to word, not mine. Same call applies to the (DOC-1050) in the PR title.
Also clears the semicolon on line 66.
| A scheduled monthly job refreshes these snapshots and opens a PR when any of | |
| them has drifted; the Read the Docs `-W` build on that PR is the gate. That | |
| bounds staleness at roughly a month without depending on anyone remembering. | |
| See [DOC-1050] for the job's ownership. | |
| A scheduled monthly job refreshes these snapshots and opens a PR when any of them has drifted. The Read the Docs `-W` build on that PR is the gate. That bounds staleness at roughly a month without depending on anyone remembering. |
There was a problem hiding this comment.
Fair hit, and the point about anyscale/docs#2441 not being a substitute is the part I'd have gotten wrong on my own — I'd have swapped one closed door for another.
Took your first option rather than the suggested second: the paragraph now ends "The Ray docs team owns the job." No link. My reasoning is that the question this sentence answers — who do I ask when a snapshot is stale and the job hasn't fired? — is the one a contributor actually arrives with, and dropping it entirely leaves the mechanism described but unowned. If you'd rather have your version, it's a one-line delete and I'll take it without argument; you own the wording here.
The [DOC-1050] reference and its link definition on line 84 are both gone.
| Refresh by hand whenever you need to — after adding a target, or when a | ||
| cross-reference to an upstream symbol that does exist upstream stops resolving. | ||
| Run it from the repo root, inside the docs virtualenv: |
There was a problem hiding this comment.
Em dash becomes a colon, and "upstream" appears twice in one clause. The first one is carried by "does exist upstream," so the modifier on "symbol" is redundant.
| Refresh by hand whenever you need to — after adding a target, or when a | |
| cross-reference to an upstream symbol that does exist upstream stops resolving. | |
| Run it from the repo root, inside the docs virtualenv: | |
| Refresh by hand whenever you need to: after adding a target, or when a cross-reference to a symbol that does exist upstream stops resolving. Run it from the repo root, inside the docs virtualenv: |
There was a problem hiding this comment.
Applied verbatim.
| in `../conf.py`, so it never drifts from the build configuration. To add or | ||
| remove a target, edit `_intersphinx_targets` and re-run the script. | ||
|
|
||
| [DOC-1050]: https://anyscale1.atlassian.net/browse/DOC-1050 |
There was a problem hiding this comment.
Outside the range of anything else I flagged, so no suggestion block: this is the link-definition half of the [DOC-1050] comment above. Remove this line along with the reference on line 68.
There was a problem hiding this comment.
Removed along with the reference on line 68.
| # Prefer the committed local snapshot, falling back to the upstream inventory | ||
| # (or the <base_url>objects.inv default when None) if a snapshot is missing. | ||
| intersphinx_mapping = { | ||
| name: (base_url, (f"_intersphinx/{name}.inv", inventory)) | ||
| for name, (base_url, inventory) in _intersphinx_targets.items() | ||
| } |
There was a problem hiding this comment.
Two additions here, from the technical notes in the review body.
The path is srcdir-relative, and that's worth recording. Sphinx 8.2.3 sends a non-URL inventory location to _fetch_inventory_file(inv_location=..., srcdir=srcdir) (sphinx/ext/intersphinx/_load.py:328), so _intersphinx/<name>.inv resolves against doc/source/, not doc/. Someone tidying the source tree later could reasonably move this directory up to doc/ and would get a silent fallback to network fetching rather than an error.
A missing snapshot is currently undetectable. The fallback is deliberately quiet, which is the right robustness default, but it means the optimization can stop applying without any signal: a filename typo, a new target added to _intersphinx_targets without a snapshot, a corrupted file, or the relocation above all just resume fetching over the network and log an info message. Under -W nothing fails, and the only symptom is build timing.
A file-existence check is enough to close that, and it makes no network call, so it stays safe under -W. pathlib is already imported at the top of conf.py.
I used print rather than a Sphinx warning deliberately: fail_on_warning: true would turn a missing snapshot into a hard build failure. That may well be what you want, since it makes the guard load-bearing, but it changes failure semantics for anyone working offline or adding a target, so I left that escalation to you.
| # Prefer the committed local snapshot, falling back to the upstream inventory | |
| # (or the <base_url>objects.inv default when None) if a snapshot is missing. | |
| intersphinx_mapping = { | |
| name: (base_url, (f"_intersphinx/{name}.inv", inventory)) | |
| for name, (base_url, inventory) in _intersphinx_targets.items() | |
| } | |
| # Prefer the committed local snapshot, falling back to the upstream inventory | |
| # (or the <base_url>objects.inv default when None) if a snapshot is missing. | |
| # The snapshot path is relative to the Sphinx source dir (this directory), | |
| # because Sphinx resolves a non-URL inventory location against srcdir. Moving | |
| # _intersphinx/ outside doc/source/ silently reverts to fetching over the network. | |
| intersphinx_mapping = { | |
| name: (base_url, (f"_intersphinx/{name}.inv", inventory)) | |
| for name, (base_url, inventory) in _intersphinx_targets.items() | |
| } | |
| # The fallback above is quiet by design: a missing snapshot degrades to a network | |
| # fetch and an info message, not a warning. Report it, so a snapshot that stops | |
| # being used shows up in the build log instead of only in build timing. | |
| _missing_snapshots = sorted( | |
| name | |
| for name in _intersphinx_targets | |
| if not (pathlib.Path(__file__).parent / "_intersphinx" / f"{name}.inv").is_file() | |
| ) | |
| if _missing_snapshots: | |
| print( | |
| "WARNING: no intersphinx snapshot for " | |
| f"{', '.join(_missing_snapshots)}; falling back to a network fetch. " | |
| "Run python doc/source/_intersphinx/refresh.py to restore them." | |
| ) |
Addresses dstrodtman's 10 comments on #64977. One is a factual correction, not style. The README claimed Ray's docs CI does not run Sphinx's linkcheck builder. It does: `doc: linkcheck` in .buildkite/doc.rayci.yml runs `make -C doc/ linkcheck_all`. The conclusion holds, but for reasons worth naming instead of a claim that falls over the moment someone greps for the step: it's skip-on-premerge with soft_fail: true, so it runs only after merge and never blocks, and conf.py sets linkcheck_anchors = False (line 362), so it verifies the target page resolves but not the `#anchor` a symbol-level cross-reference points at. The same wrong claim was in this PR's body and in the refresh workflow (anyscale/docs#2441); both are corrected. Second substantive point: "these snapshots must be refreshed on a clock" was unconditional, and it's only true of `master`. On a release branch or tag a frozen snapshot is the intended behavior rather than a debt -- it pins resolution to the release epoch instead of drifting with upstream on every rebuild, which is what a live fetch does today. Stated as a design property, along with the refresh job's `master`-only scope, which is what preserves it. Dropped the DOC-1050 link and its reference definition. It resolves to anyscale1.atlassian.net, which no external Ray contributor can open, and anyscale/docs#2441 is private so it isn't a substitute. Replaced with a prose ownership line, which was one of the two options offered; say the word and it goes entirely. The rest is the writing-style guide: whole-file soft-wrap reflow (one logical line per paragraph and list item), em dashes and semicolons restructured, passive voice given a named actor, bold reserved for UI elements, units spelled out. Vale drops from 14 errors / 8 suggestions to 8 / 2 on this file, with everything remaining a Vale.Spelling hit on technical vocabulary (Intersphinx, unversioned, GPflow, virtualenv) rather than a prose rule. The file stays excluded from the Sphinx build (conf.py exclude_patterns "_intersphinx/**"), so none of this changes published output; the audience is whoever is about to run refresh.py. Signed-off-by: Ronny Roland <[email protected]>
|
Im in favor of this. Thoughts on moving all the inventories to a dedicated repo for them? Then we can save them as github artifacts on a release |
I don't have strong opinions here in either direction, but I know one of the big things here is removing networking dependencies as much as possible from RtD builds. Not sure how the proposed model would differ. |
…65391) ## Why this change `ci/ray_ci/doc/` holds the documentation site build and the API-reference guards, but there's no orientation for anyone opening it. Nine modules, three of which are entry points, and the wiring that decides which is which lives in three other files (`.buildkite/doc.rayci.yml`, `.buildkite/lint.rayci.yml`, `ci/lint/lint.sh`). Reading the directory alone gives you the wrong model of it. The same is true one level up: `doc.rayci.yml` opens straight at `group: doc` with no statement of what the pipeline does, and the two rules files that decide what CI runs for *every* PR in the repo don't say anywhere that that's what they do. This PR is descriptive only. No step, rule, tag, or target changes behavior. ## What's here **New `ci/ray_ci/doc/README.md`.** What each entry point does and where it's invoked from, what the shared libraries contribute, and two things the layout actively misleads on: - `cmd_check_api_discrepancy` and `cmd_check_api_param_coverage` have `py_binary` targets but don't run through Bazel in CI. `lint.sh` invokes them with the docbuild image's interpreter, because the Bazel targets resolve `@py_deps_py310` wheels that can't import under the py3.11 docbuild image. There's already a `TODO(elliot-barn)` on #64070 to undo this once hermetic py3.11 lands. - The `doc: check API annotations` step isn't this package at all — it runs `ci/lint/check_api_annotations.py`. Easy to assume otherwise, since it sits next to `doc: check API doc consistency`, which *is* this package. **Header comment on `.buildkite/doc.rayci.yml`** listing the steps in order and what each is for, and noting that tag rules, not this file, decide what runs on a given PR. **Scope notes on `.buildkite/test.rules.txt` and `always.rules.txt`.** Both decide what CI runs for every pull request in the repository, so an edit is a repo-wide change rather than a local one. The note also records that rules are first-match-wins in file order, which makes rule *position* as load-bearing as rule content, and points at the in-repo check to run. **Two removals.** - `ci/ray_ci/doc/test_update_cache_env.py` imports `ci.ray_ci.doc.cmd_update_cache_env`, which was deleted in #47233 (Aug 2024). The test was added later, in #64277, so it has never been able to import since the day it landed. It also has no `py_test` target, which is why nothing ran it and nothing reported it was broken. - A stale cross-repo pointer in the `api_param_coverage` module docstring, referencing a path outside this repository that readers here can't follow. The paragraphs above it already describe the check's scope, so nothing is lost. ## Not a duplicate Checked open PRs for the touched areas per `AGENTS.md`: ``` gh pr list --repo ray-project/ray --state open --search "ray_ci/doc README" gh pr list --repo ray-project/ray --state open --search "test_update_cache_env" gh pr list --repo ray-project/ray --state open --search "test.rules.txt header comment" ``` No open PR adds a README here, touches the dead test, or comments these files. Two PRs matched the third search on body text only (#65342, #64977); I confirmed against their file lists that neither touches `doc.rayci.yml`, `test.rules.txt`, or `always.rules.txt`. #65211 touches `ci/ray_ci/doc/api.py`, a different file in the same directory, and doesn't conflict. ## Testing ``` bazel test //ci/pipeline:test_doc_api_rules_sync //ci/ray_ci/doc/... ``` 7/7 pass (`test_doc_api_rules_sync`, `test_api`, `test_api_param_coverage`, `test_autodoc`, `test_build_cache`, `test_cmd_check_api_discrepancy`, `test_module`). Because the comments land on rule files, I also confirmed the rules still parse and emit identical tags, loading both files through `ci/pipeline/determine_tests_to_run.py` and comparing `match_tags` output before and after. Comments are ignored by the parser and nothing moved. `pre-commit run` passes on every changed file. ## AI assistance This change was written with AI assistance. I reviewed every line, ran the tests above myself, and can defend the change end-to-end. Every technical claim in the added comments was verified against the source rather than inferred: the invocation paths from `lint.sh` and the pipeline YAML, the first-match-wins ordering from `TagRuleSet.match_tags`, and the dead import from `git log` on the deleted module plus a direct import attempt. --------- Signed-off-by: Douglas Strodtman <[email protected]>
…ay-project#65391) ## Why this change `ci/ray_ci/doc/` holds the documentation site build and the API-reference guards, but there's no orientation for anyone opening it. Nine modules, three of which are entry points, and the wiring that decides which is which lives in three other files (`.buildkite/doc.rayci.yml`, `.buildkite/lint.rayci.yml`, `ci/lint/lint.sh`). Reading the directory alone gives you the wrong model of it. The same is true one level up: `doc.rayci.yml` opens straight at `group: doc` with no statement of what the pipeline does, and the two rules files that decide what CI runs for *every* PR in the repo don't say anywhere that that's what they do. This PR is descriptive only. No step, rule, tag, or target changes behavior. ## What's here **New `ci/ray_ci/doc/README.md`.** What each entry point does and where it's invoked from, what the shared libraries contribute, and two things the layout actively misleads on: - `cmd_check_api_discrepancy` and `cmd_check_api_param_coverage` have `py_binary` targets but don't run through Bazel in CI. `lint.sh` invokes them with the docbuild image's interpreter, because the Bazel targets resolve `@py_deps_py310` wheels that can't import under the py3.11 docbuild image. There's already a `TODO(elliot-barn)` on ray-project#64070 to undo this once hermetic py3.11 lands. - The `doc: check API annotations` step isn't this package at all — it runs `ci/lint/check_api_annotations.py`. Easy to assume otherwise, since it sits next to `doc: check API doc consistency`, which *is* this package. **Header comment on `.buildkite/doc.rayci.yml`** listing the steps in order and what each is for, and noting that tag rules, not this file, decide what runs on a given PR. **Scope notes on `.buildkite/test.rules.txt` and `always.rules.txt`.** Both decide what CI runs for every pull request in the repository, so an edit is a repo-wide change rather than a local one. The note also records that rules are first-match-wins in file order, which makes rule *position* as load-bearing as rule content, and points at the in-repo check to run. **Two removals.** - `ci/ray_ci/doc/test_update_cache_env.py` imports `ci.ray_ci.doc.cmd_update_cache_env`, which was deleted in ray-project#47233 (Aug 2024). The test was added later, in ray-project#64277, so it has never been able to import since the day it landed. It also has no `py_test` target, which is why nothing ran it and nothing reported it was broken. - A stale cross-repo pointer in the `api_param_coverage` module docstring, referencing a path outside this repository that readers here can't follow. The paragraphs above it already describe the check's scope, so nothing is lost. ## Not a duplicate Checked open PRs for the touched areas per `AGENTS.md`: ``` gh pr list --repo ray-project/ray --state open --search "ray_ci/doc README" gh pr list --repo ray-project/ray --state open --search "test_update_cache_env" gh pr list --repo ray-project/ray --state open --search "test.rules.txt header comment" ``` No open PR adds a README here, touches the dead test, or comments these files. Two PRs matched the third search on body text only (ray-project#65342, ray-project#64977); I confirmed against their file lists that neither touches `doc.rayci.yml`, `test.rules.txt`, or `always.rules.txt`. ray-project#65211 touches `ci/ray_ci/doc/api.py`, a different file in the same directory, and doesn't conflict. ## Testing ``` bazel test //ci/pipeline:test_doc_api_rules_sync //ci/ray_ci/doc/... ``` 7/7 pass (`test_doc_api_rules_sync`, `test_api`, `test_api_param_coverage`, `test_autodoc`, `test_build_cache`, `test_cmd_check_api_discrepancy`, `test_module`). Because the comments land on rule files, I also confirmed the rules still parse and emit identical tags, loading both files through `ci/pipeline/determine_tests_to_run.py` and comparing `match_tags` output before and after. Comments are ignored by the parser and nothing moved. `pre-commit run` passes on every changed file. ## AI assistance This change was written with AI assistance. I reviewed every line, ran the tests above myself, and can defend the change end-to-end. Every technical claim in the added comments was verified against the source rather than inferred: the invocation paths from `lint.sh` and the pipeline YAML, the first-match-wins ordering from `TagRuleSet.match_tags`, and the dead import from `git log` on the deleted module plus a direct import attempt. --------- Signed-off-by: Douglas Strodtman <[email protected]> Signed-off-by: 400Ping <[email protected]>
## Why are these changes needed? Eight of the 26 entries in `_intersphinx_targets` resolve **zero** cross-references anywhere in the rendered documentation: `aiohttp`, `composer`, `distributed`, `horovod`, `pydantic`, `pytorch_lightning`, `scipy`, and `torchvision`. Each one still costs a committed `.inv` snapshot in the tree, a slot in the refresh cadence that `doc/source/_intersphinx/README.md` describes, and -- on any branch cut before #64977 -- a network fetch at build startup that can fail the `-W` build outright. Three of the eight (`torchvision`, `scipy`, and `pytorch_lightning`) were implicated in the Read the Docs failures on 2026-08-19/20 while resolving nothing. `pytorch_lightning` is the clearest case: `lightning.ai` serves an SPA shell for `objects.inv`, which #65604 proposed fixing by dropping the target before it was closed as superseded by #64977. Snapshots removed the urgency; nothing linking to it is the reason to drop it anyway. ### How this was measured When intersphinx resolves a cross-reference it stamps the anchor with `title="(in <Project> v<X>)"`. Counting those over a full 4,009-page HTML build gives an exhaustive per-target usage census. The 18 surviving targets: | Target | Refs | | Target | Refs | |---|---:|---|---|---:| | `python` | 10,690 | | `transformers` | 2 | | `pyarrow` | 132 | | `sklearn` | 2 | | `numpy` | 97 | | `nevergrad` | 2 | | `torch` | 96 | | `modin` | 2 | | `tensorflow` | 83 | | `mars` | 2 | | `pandas` | 55 | | `lightgbm` | 2 | | `gymnasium` | 18 | | `datasets` | 2 | | `pyspark` | 3 | | `dask` | 2 | | `grpc` | 3 | | `pymongoarrow` | 1 | The eight dropped targets appear nowhere in that census. ### Why this is safe under `-W` `conf.py` sets `nitpicky = True`, but `nitpick_ignore_regex` blanket-ignores `("py:class", ".*")`. Third-party type annotations resolve as `py:class`, so an unresolved one degrades to plain text instead of failing the build -- which is also what `ray-contribute/docs.md` promises contributors. Verified in addition that no `:external:` role and no explicit `py:obj` / `py:func` / `py:meth` / `py:mod` reference anywhere under `doc/source` targets a dropped namespace, since those reftypes are *not* covered by the blanket ignore. Worth recording the flip side, because it makes a tempting shortcut a non-starter: the `python` target can never be dropped. Sphinx's `parse_reftarget` assigns `reftype = 'obj'` rather than `'class'` for `None` and for every `typing.*` annotation, and nothing ignores `py:obj` generically. That is 2,856 `None` references plus 2,676 `typing.*` references -- 5,532 hard `-W` failures. "Strip intersphinx, then add back what's valuable" does not survive contact with the build. ## Related changes - Drops the `pytorch_lightning` inventory-pinning comment, which documented a workaround for a target that no longer exists. - Corrects the target counts and the now-singular `object-mirror-*` reference in `conf.py` and in `doc/source/_intersphinx/README.md`. - `refresh.py` reads the target list straight out of `conf.py`, so it needs no change. Confirmed it now parses 18 targets, matching the 18 remaining snapshots on disk exactly. Follow-up, not in this PR: 11 of the surviving targets resolve only 1-3 references each and are worth a separate keep-or-drop audit. ## Related issue number Follows #64977, which pre-baked the inventory snapshots. ## Checks - [x] I've signed off every commit (`-s`). - [x] I've included any doc changes needed for the change. - Testing strategy - [ ] Unit tests - [ ] Release tests - [x] Verified by the Read the Docs `-W` build on this PR, which is the gate that exercises `intersphinx_mapping`. Also verified locally that `refresh.py` parses 18 targets matching the 18 snapshots on disk, and that no reference under `doc/source` targets a dropped namespace via a reftype outside the `py:class` blanket ignore. Signed-off-by: Douglas Strodtman <[email protected]>
) ## Why are these changes needed? `torch` is one of the four intersphinx targets that set an explicit inventory URL instead of deriving it from `base_url`. #63038 pinned it to `docs/2.7/objects.inv` to match `torch==2.7.0` in `python/requirements/ml/dl-{cpu,gpu}-requirements.txt`, so cross-references would only resolve to symbols the version Ray ships actually has. That PR flagged the tradeoff explicitly: the URL has to bump alongside the requirements pin. Those requirements now pin `torch==2.9.0`. The inventory pin stayed at 2.7, so two minor versions of torch API surface stopped resolving. `torch` resolves 96 cross-references, the fourth-highest of the 18 targets remaining after #65644, so it's the pin worth keeping current. This repoints the pin to `docs/2.9/objects.inv` and re-runs `_intersphinx/refresh.py torch`. The snapshot is what actually resolves references since #64977, so bumping the URL alone would have changed only the unused fallback. `base_url` stays at `docs/stable/`, so the link URLs Sphinx emits don't change. A comment now records that the pin tracks the requirements file, since that coupling is the thing that went unmaintained. ### Verification that 2.9 doesn't drop a symbol Ray references Bumping a pinned inventory forward can break the `-W` build if upstream removed a symbol Ray cross-references, so I checked before pushing rather than leaving it to CI: - The 2.7 snapshot carried 11,851 objects, the 2.9 snapshot carries 13,139. Between them, 1,874 objects were added and 586 removed. - 140 of the 586 removals are in the `torch.*` Python namespace. The rest are documentation page anchors and C++ index entries. - Of those 140, all but one sit under `torch.ao.ns._numeric_suite`, a private module. Nothing under `python/ray` or `doc/source` references any of them. - The single remaining name, `torch.cuda.empty_cache`, appears three times in the tree (`python/ray/train/torch/config.py:164` and two example scripts), and all three are plain Python calls rather than Sphinx cross-references. 2.9 moved the documented object to `torch.cuda.memory.empty_cache`, which is irrelevant because nothing cross-references it. ## Related changes Three documentation corrections in the same directory, bundled here rather than opened as separate trivial PRs: - `_intersphinx/refresh.py` said four targets set an explicit inventory URL. #65644 dropped `scipy`, leaving three. - `_intersphinx/README.md` recorded the old `docs/2.7/` pin. - `_intersphinx/README.md` gained a "Before you drop a target" section. It records the reftype rules that decide whether dropping a target is safe: third-party annotations resolve as `py:class`, which `nitpick_ignore_regex` blanket-ignores, while `:external:` and explicit `py:obj`/`py:func`/`py:meth`/`py:mod` references aren't covered. It also records why `python` can never be dropped, since `parse_reftarget` assigns `obj` rather than `class` to `None` and to `typing.*` annotations. That reasoning came out of #65644 and is worth having where someone editing the target list will see it. ## Related issue number Follows #63038 (which established the pin), #64977 (which committed the snapshots), and #65644 (which reduced the target set to 18). Not a duplicate: no open PR or issue touches the torch intersphinx pin. Checked `gh pr list --repo ray-project/ray --state open --search "intersphinx"`, the same for `"torch pin objects.inv"`, and the open-issue search for `"intersphinx torch inventory"`. The one open PR in this area, #65646, changes CI step routing for the directory and doesn't touch `conf.py` or the snapshots. ## Checks - [x] I've signed off every commit (`-s`). - [x] I've included any doc changes needed for the change. - Testing strategy - [ ] Unit tests - [ ] Release tests - [x] The Read the Docs `-W` build on this PR is the gate that exercises `intersphinx_mapping`, and it's what would surface a removed symbol as a hard failure. Locally I ran `python doc/source/_intersphinx/refresh.py torch`, which fetched 162,579 bytes from the new URL and confirmed the script picks the pin up out of `conf.py`. I then ran the inventory diff described above against the previous snapshot. I did not run a full local Sphinx build. AI assistance was used for this change. Signed-off-by: Douglas Strodtman <[email protected]>
…ay-project#65391) ## Why this change `ci/ray_ci/doc/` holds the documentation site build and the API-reference guards, but there's no orientation for anyone opening it. Nine modules, three of which are entry points, and the wiring that decides which is which lives in three other files (`.buildkite/doc.rayci.yml`, `.buildkite/lint.rayci.yml`, `ci/lint/lint.sh`). Reading the directory alone gives you the wrong model of it. The same is true one level up: `doc.rayci.yml` opens straight at `group: doc` with no statement of what the pipeline does, and the two rules files that decide what CI runs for *every* PR in the repo don't say anywhere that that's what they do. This PR is descriptive only. No step, rule, tag, or target changes behavior. ## What's here **New `ci/ray_ci/doc/README.md`.** What each entry point does and where it's invoked from, what the shared libraries contribute, and two things the layout actively misleads on: - `cmd_check_api_discrepancy` and `cmd_check_api_param_coverage` have `py_binary` targets but don't run through Bazel in CI. `lint.sh` invokes them with the docbuild image's interpreter, because the Bazel targets resolve `@py_deps_py310` wheels that can't import under the py3.11 docbuild image. There's already a `TODO(elliot-barn)` on ray-project#64070 to undo this once hermetic py3.11 lands. - The `doc: check API annotations` step isn't this package at all — it runs `ci/lint/check_api_annotations.py`. Easy to assume otherwise, since it sits next to `doc: check API doc consistency`, which *is* this package. **Header comment on `.buildkite/doc.rayci.yml`** listing the steps in order and what each is for, and noting that tag rules, not this file, decide what runs on a given PR. **Scope notes on `.buildkite/test.rules.txt` and `always.rules.txt`.** Both decide what CI runs for every pull request in the repository, so an edit is a repo-wide change rather than a local one. The note also records that rules are first-match-wins in file order, which makes rule *position* as load-bearing as rule content, and points at the in-repo check to run. **Two removals.** - `ci/ray_ci/doc/test_update_cache_env.py` imports `ci.ray_ci.doc.cmd_update_cache_env`, which was deleted in ray-project#47233 (Aug 2024). The test was added later, in ray-project#64277, so it has never been able to import since the day it landed. It also has no `py_test` target, which is why nothing ran it and nothing reported it was broken. - A stale cross-repo pointer in the `api_param_coverage` module docstring, referencing a path outside this repository that readers here can't follow. The paragraphs above it already describe the check's scope, so nothing is lost. ## Not a duplicate Checked open PRs for the touched areas per `AGENTS.md`: ``` gh pr list --repo ray-project/ray --state open --search "ray_ci/doc README" gh pr list --repo ray-project/ray --state open --search "test_update_cache_env" gh pr list --repo ray-project/ray --state open --search "test.rules.txt header comment" ``` No open PR adds a README here, touches the dead test, or comments these files. Two PRs matched the third search on body text only (ray-project#65342, ray-project#64977); I confirmed against their file lists that neither touches `doc.rayci.yml`, `test.rules.txt`, or `always.rules.txt`. ray-project#65211 touches `ci/ray_ci/doc/api.py`, a different file in the same directory, and doesn't conflict. ## Testing ``` bazel test //ci/pipeline:test_doc_api_rules_sync //ci/ray_ci/doc/... ``` 7/7 pass (`test_doc_api_rules_sync`, `test_api`, `test_api_param_coverage`, `test_autodoc`, `test_build_cache`, `test_cmd_check_api_discrepancy`, `test_module`). Because the comments land on rule files, I also confirmed the rules still parse and emit identical tags, loading both files through `ci/pipeline/determine_tests_to_run.py` and comparing `match_tags` output before and after. Comments are ignored by the parser and nothing moved. `pre-commit run` passes on every changed file. ## AI assistance This change was written with AI assistance. I reviewed every line, ran the tests above myself, and can defend the change end-to-end. Every technical claim in the added comments was verified against the source rather than inferred: the invocation paths from `lint.sh` and the pipeline YAML, the first-match-wins ordering from `TagRuleSet.match_tags`, and the dead import from `git log` on the deleted module plus a direct import attempt. --------- Signed-off-by: Douglas Strodtman <[email protected]>
## Summary Pre-bakes the third-party intersphinx inventories so Sphinx no longer fetches ~two dozen `objects.inv` files over the network at the start of every docs build. - Commits 26 `objects.inv` snapshots under `doc/source/_intersphinx/` (~1.7 MB total). - Rewires `intersphinx_mapping` in `doc/source/conf.py` to prefer the **local snapshot**, falling back to the existing upstream URL (or the `<base_url>objects.inv` default) if a snapshot is missing. Sphinx tries inventory locations in order and stops at the first that loads, so a present snapshot means **no network fetch**, and a missing one degrades to today's remote behavior — an info message, not a `-W`-breaking warning. The human-readable target list stays intact as `_intersphinx_targets`; the mapping is derived from it. - Adds `doc/source/_intersphinx/refresh.py` to rebuild the snapshots (it reads `_intersphinx_targets` straight from `conf.py`, so it can't drift from the build config) and a `README.md` documenting the refresh mechanism. Resolves **DOC-1050** (parent epic DOC-1046, "Reduce Ray docs Sphinx/RtD build time"). Estimated impact: ~20–60s per build, plus removal of an intermittent network-flake failure mode. ### Why The build fetches every inventory up front on every run — slow, and a real source of build-time variance. Two of them (pandas, scipy) go through GitHub release-asset redirects to signed, expiring Azure blob URLs — the most fragile of the set and the most plausible cause of intermittent silent timeouts. Snapshotting moves the staleness window into our control. Cross-reference *links* still point at each project's live docs site; only *resolution* uses the local snapshot, so the URLs Sphinx emits are unchanged. ### What staleness costs, and the refresh mechanism This is the load-bearing part of the change, so it's worth being explicit about the trade. `intersphinx_cache_limit` is unset, so Sphinx's 5-day default applies today: | | Staleness bound | Upstream **adds** a symbol | Upstream **removes/renames** a symbol | |---|---|---|---| | **Today** | published builds fetch fresh; PR builds ≤5 days | new xref resolves | xref fails → **loud `-W` failure** | | **With snapshots** | until someone refreshes | new xref fails → loud `-W` failure, fix = `refresh.py` | stale snapshot still resolves → **silent dead outbound link** | The second column is fine — it's self-announcing and one command to fix. The third is the real cost: a stale snapshot keeps resolving a symbol upstream has deleted, so the build stays green while emitting a link to a page that no longer exists. Ray CI does run the `linkcheck` builder (`doc: linkcheck` in `.buildkite/doc.rayci.yml`), but it can't catch this: the step is `skip-on-premerge` with `soft_fail: true`, so it runs only after merge and never blocks, and `linkcheck_anchors = False` in `conf.py` means it checks that the target page resolves, not the `#anchor` a symbol-level cross-reference points at. Most targets resolve against upstream's *moving* docs, so their inventory changes when the upstream project *releases*, independently of anything Ray pins — there is no Ray-side event to refresh against, which is why it has to be a clock rather than a ride-along with Ray's dependency bumps. Four targets are exceptions that set an explicit inventory URL: `pandas` and `scipy` read frozen `object-mirror-*` release assets under `ray-project`, `torch` is pinned to `docs/2.7/` while its links point at `docs/stable/`, and `tensorflow` reads a third-party GPflow mirror tracking its own `master`. For the three frozen ones a refresh is a no-op and committing a snapshot changes nothing about their staleness. All pre-existing `conf.py` behavior, unchanged here. How fast does this actually drift? Re-running `refresh.py` six days after the initial capture changed **4 of 26** — `grpc` 1.82.0 → 1.83.0 (a real minor release), plus content changes in `pydantic`, `python` 3.14, and `transformers` `main`. That rate is the argument for a scheduled refresh in one line. The mechanism, therefore: **a scheduled monthly job runs `refresh.py` and opens a PR when any snapshot drifted.** That bounds staleness at ~1 month, and it restores the loud failure — once the fresh inventory drops a removed symbol, the stale cross-reference fails on the *refresh PR's* `-W` build. That is why a refresh must land as a reviewed PR and must never be auto-merged: that build is the entire safety net for the silent case. That job is **[anyscale/docs#2441](anyscale/docs#2441 — a GitHub Actions workflow modeled on the existing `bump-ray-template-pins.yml`, which already refreshes Ray's docs template pins the same way. It reuses that workflow's fork and PAT, so it opens its PR from a fork and **needs no changes to this repo and no new permissions here**. It commits only `doc/source/_intersphinx/*.inv` (a guard fails the run otherwise), signs off with DCO, and reuses one `auto-refresh-intersphinx-snapshots` branch so monthly runs can't stack up PRs. > **Merge order:** land this PR first, then [anyscale/docs#2441](anyscale/docs#2441). The workflow errors out by design if `doc/source/_intersphinx/refresh.py` isn't on `master` yet, so merging it early just produces one noisy failed run. `README.md` and `refresh.py` describe that job as the mechanism, so ray-project#2441 should not be left indefinitely unmerged either. ### Refreshing by hand ```bash python doc/source/_intersphinx/refresh.py # refresh all python doc/source/_intersphinx/refresh.py numpy torch # refresh a subset ``` Needed after adding a target, or when a cross-reference to a symbol that does exist upstream stops resolving. ### Also included `doc/.claude/skills/sphinx-fix/rules.yaml` — two rules gave advice this change invalidates: - `intersphinx-inventory-unreachable` said to re-run the build first, as a transient network blip. With snapshots committed, reaching `failed to reach any of the inventories` means **both** locations failed: the snapshot is missing or unreadable *and* the network fetch failed. A green re-run then just means the network came back while the missing snapshot is still missing, so a missing snapshot is now the first thing to check. - `py-xref-target-not-found` now notes that a third-party target which *does* exist upstream points at a stale snapshot — fix by refreshing, not by editing the reference. ### Not a duplicate Checked open PRs for `intersphinx` / `objects.inv` / `_intersphinx`: nothing in flight touches inventory pre-baking. (ray-project#60886 is a dependabot `nbconvert` bump; ray-project#64944 is the Sphinx 9.1 upgrade, which mentions `objects.inv` only incidentally and does not change the mapping.) ### Testing - `python -m py_compile doc/source/conf.py` — passes under Python 3.11 (Sphinx 8.2.3, current) and 3.12 (Sphinx 9.1.0, the in-progress upgrade target). - Offline verification driving Sphinx's own inventory loader (`_fetch_inventory_group`) with the network fetch path monkeypatched to raise: **all 26 inventories resolve from local files, 0 network calls, 157,320 cross-reference targets** — identical on Sphinx 8.2.3 and 9.1.0. (9.1's new `cache_dir` arg only affects remote fetches, so local-first is unchanged.) - `refresh.py` successfully re-fetches all 26 inventories, including the pandas/scipy GitHub-redirect mirrors. Re-run immediately before requesting review so the snapshots don't land stale: 26/26 succeeded, 4 drifted, all 26 verified as valid v2 inventories afterwards (`# Sphinx inventory version` banner present, upstream project/version parsed from each header). - `python sphinx_fix.py --selftest` → `SELFTEST OK (16 fixtures, 15 rules, 4 suppressions)` after regenerating the three affected goldens. The rule IDs, tiers, safety levels and unclassified count are unchanged; only the fix text moved. - `rules.yaml` parses under real PyYAML (the `check-yaml` hook's parser) as well as the skill's built-in fallback parser. - Read the Docs `-W` build: **green** on the first two commits; rebuilding on the snapshot refresh. I have not run the full local docs HTML build; the RtD `-W` build on this PR is the end-to-end check. ### Repo size The snapshots add ~1.62 MiB, and each refresh adds new blobs for whichever files changed. `.inv` files are already zlib-compressed so delta compression barely helps. On the observed drift rate that's roughly 0.5–1.5 MiB per refresh — call it 6–18 MiB/year — permanently, against ~20–60s saved on every build plus the removal of a flake class. Worth stating explicitly rather than leaving to be discovered. ### AI assistance This PR was prepared with AI assistance (Claude Code). I have reviewed the change line by line and can defend it end-to-end; the commands run and their results are listed under Testing above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Ronny Roland <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
…oject#65644) ## Why are these changes needed? Eight of the 26 entries in `_intersphinx_targets` resolve **zero** cross-references anywhere in the rendered documentation: `aiohttp`, `composer`, `distributed`, `horovod`, `pydantic`, `pytorch_lightning`, `scipy`, and `torchvision`. Each one still costs a committed `.inv` snapshot in the tree, a slot in the refresh cadence that `doc/source/_intersphinx/README.md` describes, and -- on any branch cut before ray-project#64977 -- a network fetch at build startup that can fail the `-W` build outright. Three of the eight (`torchvision`, `scipy`, and `pytorch_lightning`) were implicated in the Read the Docs failures on 2026-08-19/20 while resolving nothing. `pytorch_lightning` is the clearest case: `lightning.ai` serves an SPA shell for `objects.inv`, which ray-project#65604 proposed fixing by dropping the target before it was closed as superseded by ray-project#64977. Snapshots removed the urgency; nothing linking to it is the reason to drop it anyway. ### How this was measured When intersphinx resolves a cross-reference it stamps the anchor with `title="(in <Project> v<X>)"`. Counting those over a full 4,009-page HTML build gives an exhaustive per-target usage census. The 18 surviving targets: | Target | Refs | | Target | Refs | |---|---:|---|---|---:| | `python` | 10,690 | | `transformers` | 2 | | `pyarrow` | 132 | | `sklearn` | 2 | | `numpy` | 97 | | `nevergrad` | 2 | | `torch` | 96 | | `modin` | 2 | | `tensorflow` | 83 | | `mars` | 2 | | `pandas` | 55 | | `lightgbm` | 2 | | `gymnasium` | 18 | | `datasets` | 2 | | `pyspark` | 3 | | `dask` | 2 | | `grpc` | 3 | | `pymongoarrow` | 1 | The eight dropped targets appear nowhere in that census. ### Why this is safe under `-W` `conf.py` sets `nitpicky = True`, but `nitpick_ignore_regex` blanket-ignores `("py:class", ".*")`. Third-party type annotations resolve as `py:class`, so an unresolved one degrades to plain text instead of failing the build -- which is also what `ray-contribute/docs.md` promises contributors. Verified in addition that no `:external:` role and no explicit `py:obj` / `py:func` / `py:meth` / `py:mod` reference anywhere under `doc/source` targets a dropped namespace, since those reftypes are *not* covered by the blanket ignore. Worth recording the flip side, because it makes a tempting shortcut a non-starter: the `python` target can never be dropped. Sphinx's `parse_reftarget` assigns `reftype = 'obj'` rather than `'class'` for `None` and for every `typing.*` annotation, and nothing ignores `py:obj` generically. That is 2,856 `None` references plus 2,676 `typing.*` references -- 5,532 hard `-W` failures. "Strip intersphinx, then add back what's valuable" does not survive contact with the build. ## Related changes - Drops the `pytorch_lightning` inventory-pinning comment, which documented a workaround for a target that no longer exists. - Corrects the target counts and the now-singular `object-mirror-*` reference in `conf.py` and in `doc/source/_intersphinx/README.md`. - `refresh.py` reads the target list straight out of `conf.py`, so it needs no change. Confirmed it now parses 18 targets, matching the 18 remaining snapshots on disk exactly. Follow-up, not in this PR: 11 of the surviving targets resolve only 1-3 references each and are worth a separate keep-or-drop audit. ## Related issue number Follows ray-project#64977, which pre-baked the inventory snapshots. ## Checks - [x] I've signed off every commit (`-s`). - [x] I've included any doc changes needed for the change. - Testing strategy - [ ] Unit tests - [ ] Release tests - [x] Verified by the Read the Docs `-W` build on this PR, which is the gate that exercises `intersphinx_mapping`. Also verified locally that `refresh.py` parses 18 targets matching the 18 snapshots on disk, and that no reference under `doc/source` targets a dropped namespace via a reftype outside the `py:class` blanket ignore. Signed-off-by: Douglas Strodtman <[email protected]>
…-project#65647) ## Why are these changes needed? `torch` is one of the four intersphinx targets that set an explicit inventory URL instead of deriving it from `base_url`. ray-project#63038 pinned it to `docs/2.7/objects.inv` to match `torch==2.7.0` in `python/requirements/ml/dl-{cpu,gpu}-requirements.txt`, so cross-references would only resolve to symbols the version Ray ships actually has. That PR flagged the tradeoff explicitly: the URL has to bump alongside the requirements pin. Those requirements now pin `torch==2.9.0`. The inventory pin stayed at 2.7, so two minor versions of torch API surface stopped resolving. `torch` resolves 96 cross-references, the fourth-highest of the 18 targets remaining after ray-project#65644, so it's the pin worth keeping current. This repoints the pin to `docs/2.9/objects.inv` and re-runs `_intersphinx/refresh.py torch`. The snapshot is what actually resolves references since ray-project#64977, so bumping the URL alone would have changed only the unused fallback. `base_url` stays at `docs/stable/`, so the link URLs Sphinx emits don't change. A comment now records that the pin tracks the requirements file, since that coupling is the thing that went unmaintained. ### Verification that 2.9 doesn't drop a symbol Ray references Bumping a pinned inventory forward can break the `-W` build if upstream removed a symbol Ray cross-references, so I checked before pushing rather than leaving it to CI: - The 2.7 snapshot carried 11,851 objects, the 2.9 snapshot carries 13,139. Between them, 1,874 objects were added and 586 removed. - 140 of the 586 removals are in the `torch.*` Python namespace. The rest are documentation page anchors and C++ index entries. - Of those 140, all but one sit under `torch.ao.ns._numeric_suite`, a private module. Nothing under `python/ray` or `doc/source` references any of them. - The single remaining name, `torch.cuda.empty_cache`, appears three times in the tree (`python/ray/train/torch/config.py:164` and two example scripts), and all three are plain Python calls rather than Sphinx cross-references. 2.9 moved the documented object to `torch.cuda.memory.empty_cache`, which is irrelevant because nothing cross-references it. ## Related changes Three documentation corrections in the same directory, bundled here rather than opened as separate trivial PRs: - `_intersphinx/refresh.py` said four targets set an explicit inventory URL. ray-project#65644 dropped `scipy`, leaving three. - `_intersphinx/README.md` recorded the old `docs/2.7/` pin. - `_intersphinx/README.md` gained a "Before you drop a target" section. It records the reftype rules that decide whether dropping a target is safe: third-party annotations resolve as `py:class`, which `nitpick_ignore_regex` blanket-ignores, while `:external:` and explicit `py:obj`/`py:func`/`py:meth`/`py:mod` references aren't covered. It also records why `python` can never be dropped, since `parse_reftarget` assigns `obj` rather than `class` to `None` and to `typing.*` annotations. That reasoning came out of ray-project#65644 and is worth having where someone editing the target list will see it. ## Related issue number Follows ray-project#63038 (which established the pin), ray-project#64977 (which committed the snapshots), and ray-project#65644 (which reduced the target set to 18). Not a duplicate: no open PR or issue touches the torch intersphinx pin. Checked `gh pr list --repo ray-project/ray --state open --search "intersphinx"`, the same for `"torch pin objects.inv"`, and the open-issue search for `"intersphinx torch inventory"`. The one open PR in this area, ray-project#65646, changes CI step routing for the directory and doesn't touch `conf.py` or the snapshots. ## Checks - [x] I've signed off every commit (`-s`). - [x] I've included any doc changes needed for the change. - Testing strategy - [ ] Unit tests - [ ] Release tests - [x] The Read the Docs `-W` build on this PR is the gate that exercises `intersphinx_mapping`, and it's what would surface a removed symbol as a hard failure. Locally I ran `python doc/source/_intersphinx/refresh.py torch`, which fetched 162,579 bytes from the new URL and confirmed the script picks the pin up out of `conf.py`. I then ran the inventory diff described above against the previous snapshot. I did not run a full local Sphinx build. AI assistance was used for this change. Signed-off-by: Douglas Strodtman <[email protected]>
Summary
Pre-bakes the third-party intersphinx inventories so Sphinx no longer fetches ~two dozen
objects.invfiles over the network at the start of every docs build.objects.invsnapshots underdoc/source/_intersphinx/(~1.7 MB total).intersphinx_mappingindoc/source/conf.pyto prefer the local snapshot, falling back to the existing upstream URL (or the<base_url>objects.invdefault) if a snapshot is missing. Sphinx tries inventory locations in order and stops at the first that loads, so a present snapshot means no network fetch, and a missing one degrades to today's remote behavior — an info message, not a-W-breaking warning. The human-readable target list stays intact as_intersphinx_targets; the mapping is derived from it.doc/source/_intersphinx/refresh.pyto rebuild the snapshots (it reads_intersphinx_targetsstraight fromconf.py, so it can't drift from the build config) and aREADME.mddocumenting the refresh mechanism.Resolves DOC-1050 (parent epic DOC-1046, "Reduce Ray docs Sphinx/RtD build time"). Estimated impact: ~20–60s per build, plus removal of an intermittent network-flake failure mode.
Why
The build fetches every inventory up front on every run — slow, and a real source of build-time variance. Two of them (pandas, scipy) go through GitHub release-asset redirects to signed, expiring Azure blob URLs — the most fragile of the set and the most plausible cause of intermittent silent timeouts. Snapshotting moves the staleness window into our control.
Cross-reference links still point at each project's live docs site; only resolution uses the local snapshot, so the URLs Sphinx emits are unchanged.
What staleness costs, and the refresh mechanism
This is the load-bearing part of the change, so it's worth being explicit about the trade.
intersphinx_cache_limitis unset, so Sphinx's 5-day default applies today:-Wfailure-Wfailure, fix =refresh.pyThe second column is fine — it's self-announcing and one command to fix. The third is the real cost: a stale snapshot keeps resolving a symbol upstream has deleted, so the build stays green while emitting a link to a page that no longer exists. Ray CI does run the
linkcheckbuilder (doc: linkcheckin.buildkite/doc.rayci.yml), but it can't catch this: the step isskip-on-premergewithsoft_fail: true, so it runs only after merge and never blocks, andlinkcheck_anchors = Falseinconf.pymeans it checks that the target page resolves, not the#anchora symbol-level cross-reference points at.Most targets resolve against upstream's moving docs, so their inventory changes when the upstream project releases, independently of anything Ray pins — there is no Ray-side event to refresh against, which is why it has to be a clock rather than a ride-along with Ray's dependency bumps. Four targets are exceptions that set an explicit inventory URL:
pandasandscipyread frozenobject-mirror-*release assets underray-project,torchis pinned todocs/2.7/while its links point atdocs/stable/, andtensorflowreads a third-party GPflow mirror tracking its ownmaster. For the three frozen ones a refresh is a no-op and committing a snapshot changes nothing about their staleness. All pre-existingconf.pybehavior, unchanged here.How fast does this actually drift? Re-running
refresh.pysix days after the initial capture changed 4 of 26 —grpc1.82.0 → 1.83.0 (a real minor release), plus content changes inpydantic,python3.14, andtransformersmain. That rate is the argument for a scheduled refresh in one line.The mechanism, therefore: a scheduled monthly job runs
refresh.pyand opens a PR when any snapshot drifted. That bounds staleness at ~1 month, and it restores the loud failure — once the fresh inventory drops a removed symbol, the stale cross-reference fails on the refresh PR's-Wbuild. That is why a refresh must land as a reviewed PR and must never be auto-merged: that build is the entire safety net for the silent case.That job is anyscale/docs#2441 — a GitHub Actions workflow modeled on the existing
bump-ray-template-pins.yml, which already refreshes Ray's docs template pins the same way. It reuses that workflow's fork and PAT, so it opens its PR from a fork and needs no changes to this repo and no new permissions here. It commits onlydoc/source/_intersphinx/*.inv(a guard fails the run otherwise), signs off with DCO, and reuses oneauto-refresh-intersphinx-snapshotsbranch so monthly runs can't stack up PRs.Refreshing by hand
Needed after adding a target, or when a cross-reference to a symbol that does exist upstream stops resolving.
Also included
doc/.claude/skills/sphinx-fix/rules.yaml— two rules gave advice this change invalidates:intersphinx-inventory-unreachablesaid to re-run the build first, as a transient network blip. With snapshots committed, reachingfailed to reach any of the inventoriesmeans both locations failed: the snapshot is missing or unreadable and the network fetch failed. A green re-run then just means the network came back while the missing snapshot is still missing, so a missing snapshot is now the first thing to check.py-xref-target-not-foundnow notes that a third-party target which does exist upstream points at a stale snapshot — fix by refreshing, not by editing the reference.Not a duplicate
Checked open PRs for
intersphinx/objects.inv/_intersphinx: nothing in flight touches inventory pre-baking. (#60886 is a dependabotnbconvertbump; #64944 is the Sphinx 9.1 upgrade, which mentionsobjects.invonly incidentally and does not change the mapping.)Testing
python -m py_compile doc/source/conf.py— passes under Python 3.11 (Sphinx 8.2.3, current) and 3.12 (Sphinx 9.1.0, the in-progress upgrade target)._fetch_inventory_group) with the network fetch path monkeypatched to raise: all 26 inventories resolve from local files, 0 network calls, 157,320 cross-reference targets — identical on Sphinx 8.2.3 and 9.1.0. (9.1's newcache_dirarg only affects remote fetches, so local-first is unchanged.)refresh.pysuccessfully re-fetches all 26 inventories, including the pandas/scipy GitHub-redirect mirrors. Re-run immediately before requesting review so the snapshots don't land stale: 26/26 succeeded, 4 drifted, all 26 verified as valid v2 inventories afterwards (# Sphinx inventory versionbanner present, upstream project/version parsed from each header).python sphinx_fix.py --selftest→SELFTEST OK (16 fixtures, 15 rules, 4 suppressions)after regenerating the three affected goldens. The rule IDs, tiers, safety levels and unclassified count are unchanged; only the fix text moved.rules.yamlparses under real PyYAML (thecheck-yamlhook's parser) as well as the skill's built-in fallback parser.-Wbuild: green on the first two commits; rebuilding on the snapshot refresh.I have not run the full local docs HTML build; the RtD
-Wbuild on this PR is the end-to-end check.Repo size
The snapshots add ~1.62 MiB, and each refresh adds new blobs for whichever files changed.
.invfiles are already zlib-compressed so delta compression barely helps. On the observed drift rate that's roughly 0.5–1.5 MiB per refresh — call it 6–18 MiB/year — permanently, against ~20–60s saved on every build plus the removal of a flake class. Worth stating explicitly rather than leaving to be discovered.AI assistance
This PR was prepared with AI assistance (Claude Code). I have reviewed the change line by line and can defend it end-to-end; the commands run and their results are listed under Testing above.
🤖 Generated with Claude Code