Skip to content

[doc] Remove tensorflow and tf-keras from the docs build dependencies - #65947

Merged
dstrodtman merged 2 commits into
masterfrom
doc-remove-tensorflow-docbuild
Sep 8, 2026
Merged

dstrodtman merged 2 commits into
masterfrom
doc-remove-tensorflow-docbuild

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Why

doc/requirements-doc.txt installs tensorflow==2.20.0 and tf-keras==2.20.1 for real in the docs build environment (docbuild_depset_311), against the file's own guidance that ML libraries should be mocked, not installed. Neither is needed to build the docs:

  • conf.py already mocks tensorflow (THIRD_PARTY_MOCK_MODULES), because importing real TF breaks the autodoc import of ray.rllib.algorithms.algorithm. The real install does nothing for the Sphinx build.
  • No doc-surfaced module imports TF at load time. Every import tensorflow in ray.data, ray.train.tensorflow, etc. is under TYPE_CHECKING, inside a function, or in a testcode docstring block.
  • The API/doc consistency check self-heals. ci/ray_ci/doc mocks via absent_mock_modules(), which mocks anything find_spec can't locate, so removing the install auto-mocks TF there too — no code change needed.
  • The doctest environment is unaffected. doctest_depset installs TF independently from python/requirements/ml/*, so the executable testcode examples that import TF keep working. Its lock regenerates byte-for-byte unchanged.

What

  • Remove tensorflow and tf-keras from doc/requirements-doc.txt.
  • Pin numpy directly. numpy is imported at module load by ~115 documented modules (e.g. ray.data.dataset) and is not mocked, but was only present transitively via the TF stack. Pinning it removes that latent fragility.
  • Update the conf.py comment that described TF as installed-but-mocked.
  • Regenerate python/deplocks/docs/docbuild_depset_py3.11.lock.

Impact

The docbuild deplock drops from 2267 to 1693 lines (~25% fewer pinned packages), pruning the whole TF transitive stack (keras, tensorboard, h5py, libclang, ml-dtypes, grpcio, protobuf, pillow, …). Smaller install, faster Read the Docs build, and fewer packages to keep current or that can flake or carry advisories.

Verification

  • raydepsets --check clean; the doctest lock regenerates unchanged.
  • Full make -C doc rtd-build (RtD-faithful, -W fail-on-warning): build succeeded, zero warnings. The TF-dependent API pages (e.g. ray.train.tensorflow.TensorflowTrainer) render correctly with TF mocked.

Checks

  • Signed-off (DCO)
  • Docs-only deplock change; tags doc doc_api python_dependencies

tensorflow and tf-keras were installed for real in the docbuild
environment (docbuild_depset_311) despite requirements-doc.txt's own
guidance that ML libraries should be mocked, not installed. They aren't
needed for the HTML build:

- conf.py already mocks tensorflow (THIRD_PARTY_MOCK_MODULES) because
  importing real TF breaks the autodoc import of
  ray.rllib.algorithms.algorithm. The real install did nothing for the
  Sphinx build.
- No doc-surfaced module imports TF at load time; the imports are all
  under TYPE_CHECKING, inside functions, or in testcode blocks.
- The API/doc consistency check mocks via absent_mock_modules(), which
  mocks anything find_spec can't locate, so removing the install
  auto-mocks TF there too.
- The doctest environment (doctest_depset) installs TF independently
  from python/requirements/ml/*, so executable examples are unaffected;
  its lock regenerates byte-for-byte unchanged.

Pin numpy directly. It's imported at module load by many documented
modules (e.g. ray.data) and is not mocked, but was only present
transitively via the TF stack. Pinning it removes that latent fragility.

Regenerate docbuild_depset_py3.11.lock: it drops from 2267 to 1693
lines, pruning the TF transitive stack (keras, tensorboard, h5py,
libclang, ml-dtypes, grpcio, protobuf, pillow, ...).

Verified with raydepsets --check (doctest lock unchanged) and a full
make -C doc rtd-build (build succeeded, zero warnings).

Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman requested review from a team as code owners September 4, 2026 19:23

@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 removes tensorflow and tf-keras from the documentation build requirements (doc/requirements-doc.txt) and updates the documentation configuration (doc/source/conf.py) to reflect that heavy ML libraries are mocked instead of installed during the doc build. To prevent build failures, numpy is now pinned directly since it was previously pulled in transitively by TensorFlow. Consequently, the lock file python/deplocks/docs/docbuild_depset_py3.11.lock has been regenerated, removing TensorFlow, Keras, and all of their transitive dependencies. There are no review comments, so I have no feedback to provide.

@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Sep 4, 2026
numpy is installed (not mocked) in the docs build only to satisfy load-time
imports in documented modules such as ray.data. Pin it to the numpy Ray tests
its modules against (python/requirements/test-requirements.txt, numpy==2.2.6)
instead of 2.4.6, so the docs render against the same numpy Ray validates. Only
numpy moves in the regenerated lock; no transitive versions change.

Signed-off-by: Douglas Strodtman <[email protected]>
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core labels Sep 5, 2026
@dstrodtman
dstrodtman merged commit 3c92192 into master Sep 8, 2026
6 checks passed
@dstrodtman
dstrodtman deleted the doc-remove-tensorflow-docbuild branch September 8, 2026 15:57
NightWing1998 pushed a commit to NightWing1998/ray that referenced this pull request Sep 11, 2026
…ray-project#65947)

## Why

`doc/requirements-doc.txt` installs `tensorflow==2.20.0` and
`tf-keras==2.20.1` for real in the docs build environment
(`docbuild_depset_311`), against the file's own guidance that ML
libraries should be mocked, not installed. Neither is needed to build
the docs:

- **`conf.py` already mocks tensorflow** (`THIRD_PARTY_MOCK_MODULES`),
because importing real TF breaks the autodoc import of
`ray.rllib.algorithms.algorithm`. The real install does nothing for the
Sphinx build.
- **No doc-surfaced module imports TF at load time.** Every `import
tensorflow` in `ray.data`, `ray.train.tensorflow`, etc. is under
`TYPE_CHECKING`, inside a function, or in a `testcode` docstring block.
- **The API/doc consistency check self-heals.** `ci/ray_ci/doc` mocks
via `absent_mock_modules()`, which mocks anything `find_spec` can't
locate, so removing the install auto-mocks TF there too — no code change
needed.
- **The doctest environment is unaffected.** `doctest_depset` installs
TF independently from `python/requirements/ml/*`, so the executable
`testcode` examples that import TF keep working. Its lock regenerates
byte-for-byte unchanged.

## What

- Remove `tensorflow` and `tf-keras` from `doc/requirements-doc.txt`.
- **Pin `numpy` directly.** numpy is imported at module load by ~115
documented modules (e.g. `ray.data.dataset`) and is not mocked, but was
only present transitively via the TF stack. Pinning it removes that
latent fragility.
- Update the `conf.py` comment that described TF as
installed-but-mocked.
- Regenerate `python/deplocks/docs/docbuild_depset_py3.11.lock`.

## Impact

The docbuild deplock drops from **2267 to 1693 lines (~25% fewer pinned
packages)**, pruning the whole TF transitive stack (keras, tensorboard,
h5py, libclang, ml-dtypes, grpcio, protobuf, pillow, …). Smaller
install, faster Read the Docs build, and fewer packages to keep current
or that can flake or carry advisories.

## Verification

- `raydepsets --check` clean; the doctest lock regenerates unchanged.
- Full `make -C doc rtd-build` (RtD-faithful, `-W` fail-on-warning):
**build succeeded, zero warnings**. The TF-dependent API pages (e.g.
`ray.train.tensorflow.TensorflowTrainer`) render correctly with TF
mocked.

## Checks

- [x] Signed-off (DCO)
- [x] Docs-only deplock change; tags `doc doc_api python_dependencies`

---------

Signed-off-by: Douglas Strodtman <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ray-project#65947)

## Why

`doc/requirements-doc.txt` installs `tensorflow==2.20.0` and
`tf-keras==2.20.1` for real in the docs build environment
(`docbuild_depset_311`), against the file's own guidance that ML
libraries should be mocked, not installed. Neither is needed to build
the docs:

- **`conf.py` already mocks tensorflow** (`THIRD_PARTY_MOCK_MODULES`),
because importing real TF breaks the autodoc import of
`ray.rllib.algorithms.algorithm`. The real install does nothing for the
Sphinx build.
- **No doc-surfaced module imports TF at load time.** Every `import
tensorflow` in `ray.data`, `ray.train.tensorflow`, etc. is under
`TYPE_CHECKING`, inside a function, or in a `testcode` docstring block.
- **The API/doc consistency check self-heals.** `ci/ray_ci/doc` mocks
via `absent_mock_modules()`, which mocks anything `find_spec` can't
locate, so removing the install auto-mocks TF there too — no code change
needed.
- **The doctest environment is unaffected.** `doctest_depset` installs
TF independently from `python/requirements/ml/*`, so the executable
`testcode` examples that import TF keep working. Its lock regenerates
byte-for-byte unchanged.

## What

- Remove `tensorflow` and `tf-keras` from `doc/requirements-doc.txt`.
- **Pin `numpy` directly.** numpy is imported at module load by ~115
documented modules (e.g. `ray.data.dataset`) and is not mocked, but was
only present transitively via the TF stack. Pinning it removes that
latent fragility.
- Update the `conf.py` comment that described TF as
installed-but-mocked.
- Regenerate `python/deplocks/docs/docbuild_depset_py3.11.lock`.

## Impact

The docbuild deplock drops from **2267 to 1693 lines (~25% fewer pinned
packages)**, pruning the whole TF transitive stack (keras, tensorboard,
h5py, libclang, ml-dtypes, grpcio, protobuf, pillow, …). Smaller
install, faster Read the Docs build, and fewer packages to keep current
or that can flake or carry advisories.

## Verification

- `raydepsets --check` clean; the doctest lock regenerates unchanged.
- Full `make -C doc rtd-build` (RtD-faithful, `-W` fail-on-warning):
**build succeeded, zero warnings**. The TF-dependent API pages (e.g.
`ray.train.tensorflow.TensorflowTrainer`) render correctly with TF
mocked.

## Checks

- [x] Signed-off (DCO)
- [x] Docs-only deplock change; tags `doc doc_api python_dependencies`

---------

Signed-off-by: Douglas Strodtman <[email protected]>
elliot-barn added a commit that referenced this pull request Nov 19, 2026
…r required

release/requirements_py310.txt (the py_deps_py310 bazel lock and the
release-test launcher env) was not regenerated when the docs dropped
tensorflow (#65947) and swapped sphinx plugins (#66957), so it still pins
23 packages that nothing in requirements_py310.in or
requirements-doc.txt requires: the tensorflow/keras stack (tensorflow,
tf-keras, keras, tensorboard, h5py, absl-py, ...), sphinx-jsonschema,
sphinx-llms-txt, sphinxcontrib-redoc, pillow, werkzeug and wheel.

Recompiled with the same tool as //release:requirements_py310.update
(pip-tools 6.6.0 on pip 22.0.4 and python 3.10, --no-upgrade
--generate-hashes). The bazel target doesn't build on master
(rules_python no longer ships pip_compile.py), and requirements-doc.txt
can't resolve on python 3.10 (sphinx 8.2.3 and sphinxcontrib-openapi
0.10.0 need >=3.11). So for the compile, release/requirements-doc.txt
was replaced by the doc requirements at the versions already in the .txt,
then restored. No pins change and nothing is added. No bazel target or
release/ci code references the removed packages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
elliot-barn added a commit that referenced this pull request Nov 20, 2026
…r required (#68050)

## Description

`release/requirements_py310.txt` is the `py_deps_py310` Bazel lock and
the release-test launcher environment. It wasn't regenerated when the
docs dropped TensorFlow (#65947) and swapped sphinx plugins (#66957). It
still pins 23 packages that nothing in `requirements_py310.in` or
`requirements-doc.txt` requires anymore:

- **TensorFlow stack:** tensorflow, tf-keras, keras, tensorboard,
tensorboard-data-server, h5py, absl-py, astunparse, flatbuffers, gast,
google-pasta, libclang, ml-dtypes, namex, opt-einsum, optree, markdown,
werkzeug
- **Doc plugins:** sphinx-jsonschema, sphinx-llms-txt,
sphinxcontrib-redoc
- **Other:** pillow, wheel

This PR recompiles the file and removes them. No pin changes, and
nothing is added.

**Stacked on #68048** (idna and aiohttp security bumps), so the
recompile starts from the fixed floors. Merge #68048 first, then
retarget this PR to `master`.

### How it was recompiled

It uses the same tool and settings as
`//release:requirements_py310.update`: pip-tools 6.6.0 on pip 22.0.4 and
Python 3.10, with `--no-upgrade --generate-hashes`. The Bazel target
itself can't run on master for two reasons:

1. It doesn't build, because
`@rules_python//python/pip_install:pip_compile.py` no longer exists in
the rules_python version master uses.
2. `release/requirements-doc.txt` is a symlink to
`doc/requirements-doc.txt`, which now pins `sphinx==8.2.3` and
`sphinxcontrib-openapi==0.10.0`. Both need Python ≥3.11, so this Python
3.10 environment can't resolve them.

So during the compile, that symlink was temporarily replaced by the same
doc requirements at the versions already in the `.txt`, leaving out doc
packages the `.txt` doesn't have, and then restored. On
`releases/2.57.2`, the same procedure reproduces the existing file byte
for byte.

A longer-term fix is to drop `-r requirements-doc.txt` from this Python
3.10 environment, or move the environment to Python 3.11, and to repair
the Bazel target. I'll leave that for a follow-up.

## Related issues

Follow-up to #65947, #66957 and #68048.

## Testing

- No Bazel `ci_require`/`bk_require`/`requirement` or `@py_deps_py310_*`
reference and no import in `release/ray_release` or `ci/` uses the
removed packages.
- `uv pip install --dry-run --require-hashes` on Python 3.10 covers 198
packages, and a full resolve gives the same 198 with no conflicts.
Before this change, the full resolve needed one package the file didn't
pin.

AI assistance (Claude Code) was used to prepare this change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: elliot-barn <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants