Skip to content

[doc] Don't mock installed numpy/pyarrow in autodoc_mock_imports#64457

Merged
richardliaw merged 1 commit into
ray-project:masterfrom
dstrodtman:prune-installed-autodoc-mocks
Jul 1, 2026
Merged

[doc] Don't mock installed numpy/pyarrow in autodoc_mock_imports#64457
richardliaw merged 1 commit into
ray-project:masterfrom
dstrodtman:prune-installed-autodoc-mocks

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Why

autodoc_mock_imports in doc/source/conf.py mocks numpy and pyarrow, but both are installed in the docs build environment (doc/requirements-doc.lock.txt; pyarrow is a direct requirements-doc.txt entry and numpy is foundational to the installed stack).

Mocking a library that's actually installed shadows the real module. An eager import in a documented class body then hits the mock instead of the real library and aborts the whole package import, surfacing as a misleading decoy error. This is the failure class fixed in #63821 (the read_lerobot break), where a mocked-but-needed library broke an unrelated import.

What

Remove numpy, pyarrow, and pyarrow.compute from autodoc_mock_imports so autodoc introspects the real, installed modules. Libraries genuinely absent from the docs lock stay mocked. A comment records the mock-iff-absent policy so the entries aren't re-added.

tensorflow is also installed (a direct requirements-doc entry) but is intentionally left mocked: importing it for real breaks the autodoc import of ray.rllib.algorithms.algorithm at build time. The comment notes this.

Checks

Built the full docs in a faithful Linux environment: the pinned python/deplocks/docs/docbuild_depset_py3.11.lock installed in a container, run with the same python -m sphinx ... -W command (warnings as errors) the RtD config uses. The build completes green — build succeeded. with zero Sphinx warnings; removing the three entries introduces none.

numpy and pyarrow (and pyarrow.compute) are installed in the docs build
environment (doc/requirements-doc.lock.txt); pyarrow is a direct
requirements-doc entry and numpy is foundational to that stack. Mocking a
library that is actually installed shadows the real module: an eager import in a
documented class body hits the mock and aborts the whole package import,
surfacing as a misleading decoy error (the read_lerobot class, ray-project#63821).

Remove these three entries so autodoc introspects the real, installed modules.
Add a comment recording the mock-iff-absent policy so they aren't re-added.

tensorflow is also installed (a direct requirements-doc entry) but is left
mocked on purpose: importing it for real breaks the autodoc import of
ray.rllib.algorithms.algorithm at build time. Libraries genuinely absent from
the docs lock stay mocked.

Signed-off-by: Douglas Strodtman <douglas@anyscale.com>
@dstrodtman dstrodtman requested a review from a team as a code owner June 30, 2026 21:10

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates doc/source/conf.py to remove numpy, pyarrow, and pyarrow.compute from the autodoc_mock_imports list. This prevents mocking libraries that are already installed in the documentation build environment, which can shadow real modules and cause misleading import errors. A detailed explanatory comment has also been added. There are no review comments, so I have no feedback to provide.

@ray-gardener ray-gardener Bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core labels Jul 1, 2026
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Jul 1, 2026

@ronny-anyscale ronny-anyscale left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pow

@richardliaw richardliaw merged commit 2895121 into ray-project:master Jul 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants