Repository navigation
[doc] Move autodoc out of guide pages into the API reference - #66756
Conversation
There was a problem hiding this comment.
Code Review
This pull request reorganizes and consolidates Ray's API documentation by moving several API references (such as job submission, autoscaler, compiled graph, and state APIs) under the Core API directory, and creating a dedicated API reference section for library integrations (Ray on Spark, Ray Collective, and Dask on Ray). It also cleans up user guides by replacing inline API definitions with references to these consolidated pages and updates build rules, redirects, and configuration files accordingly. Feedback on these changes suggests avoiding the listing of individual private hook methods of RayDaskCallback in a top-level autosummary to prevent fragmented stub pages, and removing internal implementation details like GroupManager and get_group_handle from the public Ray Collective API reference.
| ~ray.util.dask.RayDaskCallback | ||
| ~ray.util.dask.callbacks.RayDaskCallback._ray_presubmit | ||
| ~ray.util.dask.callbacks.RayDaskCallback._ray_postsubmit | ||
| ~ray.util.dask.callbacks.RayDaskCallback._ray_pretask | ||
| ~ray.util.dask.callbacks.RayDaskCallback._ray_posttask | ||
| ~ray.util.dask.callbacks.RayDaskCallback._ray_postsubmit_all | ||
| ~ray.util.dask.callbacks.RayDaskCallback._ray_finish |
There was a problem hiding this comment.
Listing individual private/hook methods (like _ray_presubmit) in a top-level autosummary creates separate stub pages for each method, which leads to a fragmented user experience.\n\nInstead, consider documenting these hook methods directly on the RayDaskCallback class page. You can achieve this by using the :members: option or a custom template like autosummary/class_without_autosummary.rst (similar to how RLlib's algorithm configs are handled in this PR), and ensuring that private members starting with _ray_ are included in the class's autodoc configuration.\n\nAdditionally, if they must be listed here, they should use the public path ray.util.dask.RayDaskCallback instead of exposing the internal callbacks submodule path (e.g., ray.util.dask.RayDaskCallback._ray_presubmit instead of ray.util.dask.callbacks.RayDaskCallback._ray_presubmit).
There was a problem hiding this comment.
These entries move verbatim from the Dask on Ray guide page, which carried the same autosummary block. The _ray_* methods are the documented override points for subclassing RayDaskCallback, so they stay documented. Switching to the public path or a class-page template would change the generated stub URLs, so that belongs in a follow-up rather than this move.
| ray.util.collective.collective.get_group_handle | ||
| ray.util.collective.collective.GroupManager |
There was a problem hiding this comment.
The classes/functions GroupManager and get_group_handle appear to be internal implementation details of the collective library rather than public-facing APIs. Exposing them in the public API reference increases the maintenance burden and might confuse users.\n\nConsider removing them from this public API reference page unless they are explicitly intended to be part of the public API surface.
There was a problem hiding this comment.
The guide page previously ran automodule:: ray.util.collective.collective with :members:, and the module has no __all__, so both GroupManager and get_group_handle were already in the rendered docs. This page keeps that surface unchanged. get_group_handle is in ray.util.collective.__all__. Whether GroupManager should stay public is a call for the collective owners in a separate PR.
fb23958 to
cae9891
Compare
7a40195 to
a6bbb8c
Compare
a6bbb8c to
423257c
Compare
cae9891 to
58eb64a
Compare
Guide pages that ran autodoc directives either duplicated an API reference entry or were the only documented home for an API. Move every such API into an API reference page and replace the guide-page directives with cross-references, so autodoc runs only on pages under API_PATH_PREFIXES: - Add a Ray integrations API section (ray-more-libs/api/) for Ray on Spark, Ray Collective, and Dask on Ray, and register it as an API path. - Add the nine algorithm-specific RLlib config classes to the algorithm config reference, MemoryTrackingCallbacks to the callback reference, and OldAPIStack to the RLlib utilities reference. - Add the PublicAPI, DeveloperAPI, and Deprecated annotations and AutoscalingCluster to the Ray Core utility reference. - Give ray.autoscaler.sdk.request_resources an indexed entry. - Replace guide-page and notebook autodoc with cross-references; describe the private DockerCluster test utility with a source link instead. Signed-off-by: Douglas Strodtman <[email protected]>
58eb64a to
a8aeb68
Compare
## Why are these changes needed? RLlib is the only Ray library whose API reference lives outside the `<lib>/api/` path that Data, Train, Tune, Serve, and Core use. This PR renames `doc/source/rllib/package_ref/` to `doc/source/rllib/api/` so RLlib matches. Like the other libraries, the per-symbol stubs now land under `rllib/api/doc/`. RLlib keeps its `api/env/` subsection. This is a pure path change. All 20 files are git renames with no content edits, so file history carries over. > [!NOTE] > This PR is stacked on #66756, which edits several of the same files, so its base is `doc-1747-autodoc-into-api-ref`. Review only the top commit. After #66756 merges, this PR retargets to `master`. ### What changed besides the renames These are the path-based references that move with the directory: - `doc/source/apis/index.md`: the APIs-landing toctree entry. This is the only toctree that links the RLlib API index. - `doc/source/_ext/api_sidebar.py`: `API_PATH_PREFIXES` and its docstring. - `doc/source/conf.py`: the `remove_from_toctrees` and `llms_txt_exclude` stub patterns. - `.buildkite/test.rules.txt` and `.buildkite/test.rules.test.txt`: the `doc_api` directory rule and its expectations. `test_doc_api_rules_sync` keeps the rule aligned with `API_PATH_PREFIXES`. - `ci/ray_ci/doc/cmd_check_api_discrepancy.py`: the hardcoded RLlib `head_doc_file`. - `doc/Makefile` (`clean`) and `doc/.gitignore`: same patterns, new path. - `doc/source/rllib/index.md`: a path inside the HTML-comment outline at the top of the page. It isn't rendered. Every RLlib cross-reference into these pages is a `:ref:` label, and labels don't depend on the file path, so no labels changed. ### Redirects - A new rule sends `/rllib/package_ref/*` to `/rllib/api/:splat`. - The existing catch-all now matches `/rllib/api/*` instead of `/rllib/package_ref/*`. Its `to:` is unchanged, so a missing RLlib API page still lands on the RLlib API index, like the `/serve/api/*` and `/data/api/*` catch-alls. - Existing rules that point at old `package_ref` paths are unchanged, so they keep working on releases that still serve those paths. The rules use the default `force: false`. They're inert on `/en/latest/` and older releases until a release ships the rename. ## Verification - **Local RtD-faithful build:** `make -C doc rtd-build` succeeded with zero Sphinx warnings under `-W`. RLlib pages and 510 per-symbol stubs render under `rllib/api/`. - **`rtd-redirects validate`:** 0 errors, 0 warnings. Chain notes went from 181 to 183, from the two old-path rules that now take a second hop. - **`rtd-redirects simulate`:** run with `--prefix /rllib/package_ref/` against master, latest, releases-2.50.0, and releases-2.40.0. Every version had 0 regressions, 0 wrong landings, and 0 new loops. On master: - 609 live pages reach their new `rllib/api/` page in 1 hop. - 705 generated stubs reach their matching `rllib/api/doc/` or `rllib/api/env/doc/` page in 1 or 2 hops. - 698 URLs for pages that no longer exist landed on the RLlib API index before this PR and still do, now in 3 hops instead of 1. - Latest and both older releases resolve exactly as before. - **CI rules:** `pytest ci/pipeline/test_doc_api_rules_sync.py` passes, and `rayci test-rules` passes against the updated `test.rules.test.txt`. - **Reference sweep:** `git grep package_ref` outside `doc/redirects/` finds only unrelated Hugging Face `package_reference` URLs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
The autosummary in dask-on-ray.rst writes 8 per-symbol stub pages to ray-more-libs/doc/. No llms_txt_exclude pattern covers that directory, so llms.txt lists them like guide pages, as 2.59.0 already does. Master doesn't need this: #66756 moved these stubs under ray-more-libs/api/doc/, which master excludes. Signed-off-by: Ronny Roland <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g the build environment and restore full Sphinx parallelism on Read the Docs (#66784, #66793) (#67797) ## Description Cherry-picks #66784 and #66793 onto `releases/2.60.0`, so the release branch builds its docs on Read the Docs the same way master does. The `releases-2.60.0` docs have never built on Read the Docs. All four attempts on 2026-11-03 were cancelled partway through `make html` with "Build terminated due to inactivity", so RtD kept no Sphinx output: [4668524](https://app.readthedocs.com/projects/anyscale-ray/builds/4668524/), [4668563](https://app.readthedocs.com/projects/anyscale-ray/builds/4668563/), [4668796](https://app.readthedocs.com/projects/anyscale-ray/builds/4668796/), and [4668932](https://app.readthedocs.com/projects/anyscale-ray/builds/4668932/). The branch was cut on 2026-09-30, before these two master changes: - #66784 stops MyST `{eval-rst}` blocks from pickling the whole build environment into each page's doctree, which every Sphinx worker then loaded back. - #66793 drops the `SPHINX_JOBS=2` pin from #65643, which the leak had made necessary, so RtD builds with one Sphinx worker per CPU again. Without them, this branch still builds with the leak and two workers. 2.59.0 built that way in 811 and 912 seconds, against about 500 seconds for master's builds on 2026-11-03. This may not be the whole fix. Master has both changes and still lost about 1 in 5 RtD builds to the same inactivity kill on 2026-11-03. But 2.60.0 lost all four of its builds in the same period, so its build setup is the likeliest difference. ## Changes This is `git cherry-pick -x -s` of c6d7e72 (#66784) and then cec3972 (#66793), with no conflicts. The diff matches the two PRs exactly: 6 files, +219/−24. Only the docs build and its CI change, and nothing that ships in the wheel: - `doc/source/_ext/myst_eval_rst_doctree.py` and its test, registered in `doc/source/conf.py`. - `.buildkite/doc.rayci.yml`, which runs the new test. - `.readthedocs.yaml` and `doc/Makefile`, which drop `SPHINX_JOBS=2`. The two commits need to land together. #66793 on its own would run the leaky build at full parallelism, which RtD sometimes OOM-killed before #66784. This branch pins the same Sphinx 8.2.3, myst-parser 5.1.0, myst-nb 1.4.0, and docutils 0.21.2 that #66784 was built against. The docs lock differs only in `certifi`. Master's only later changes to these files, #66807 and #66756, update `doc/Makefile` cleanup paths for pages that moved after the cut, so they aren't included. ## Testing Both commands ran on this branch in a Python 3.11.15 venv built from `doc/requirements-doc.lock.txt`. ``` $ python doc/source/_ext/test_myst_eval_rst_doctree.py PASS: myst_eval_rst_doctree re-points nested eval-rst nodes, and the pickled doctree no longer carries the build environment. ``` ``` $ make -C doc rtd-build SPHINX_JOBS=4 ... ✓ Environment matches the Read the Docs build. sphinx-build --keep-going -b html -d _build/doctrees -a -E -W -j 4 -T -D language=en source _build/html ... build succeeded. ``` `rtd-build` first checks the venv against the RtD build. Python, Sphinx, myst-parser, myst-nb, and the theme all match; only the operating system differs, since this ran on macOS. The build is the clean `-a -E -W` build that RtD runs. `-j 4` matches the RtD builder's 4 CPUs, which is what the default `SPHINX_JOBS=auto` gives there. It succeeded in 458 seconds with no warnings. Summed RSS across the Sphinx processes, sampled every 2 seconds, peaked at 3.56 GB. Summed RSS overstates real use, because forked workers share pages. #66793 measured 4.74 GB the same way on master at `-j 4`. ## Not a duplicate No open PR targets `releases/2.60.0`, and no other PR references #66784 or #66793. AI assistance: Claude Code investigated the failed builds, made the cherry-pick, ran the tests above, and drafted this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Signed-off-by: Ronny Roland <[email protected]> Co-authored-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Why are these changes needed?
Fourteen guide pages and notebooks run Sphinx autodoc directly. Some of them repeat an API reference entry, and others are the only place an API is documented at all. This PR moves every one of those APIs into an API reference page under
API_PATH_PREFIXESand replaces the guide-page directives with cross-references. After it merges, autodoc runs only on API reference pages, which is what a future move of the API reference off Sphinx autodoc needs.New API reference entries
ray-more-libs/api/, new): Ray on Spark (setup_ray_cluster,shutdown_ray_cluster,setup_global_ray_cluster), Ray Collective, and Dask on Ray (RayDaskCallbackand its_ray_*hook methods). The section is registered inAPI_PATH_PREFIXES, thedoc_apirule, the APIs landing toctree, and thellms_txt_excludeandremove_from_toctreesstub patterns.automodule ... :members:rendered (26 documented functions inray.util.collective.collective, plusregister_collective_backend), grouped by purpose. Onlyregister_collective_backendcarries an annotation (PublicAPI(stability="alpha")), so Ray Core reviewers might want to trim internals such asGroupManagerandget_group_handle.PPOConfigthroughMARWILConfig) go intoalgorithm-config.rst. They use the existingclass_without_autosummary.rsttemplate, so each class gets one page and no per-member stubs.MemoryTrackingCallbacksgoes intocallback.rst, also with the one-page template, andOldAPIStackintoutils.rst.PublicAPI,DeveloperAPI, andDeprecatedgo into a new "API stability annotations" section, andAutoscalingClusterinto a new "Testing utilities" section, both incore/api/utility.rst.ray.autoscaler.sdk.request_resourcesloses its:noindex:, because it had no indexed entry anywhere.Guide pages now cross-reference instead of rendering
rllib/algorithms.md,rllib/callback.md,rllib/dev.md,ray-contribute/stability.md(itspublic-api-deflabels are kept),ray-contribute/fake-autoscaler.md,core/miscellaneous.md,serve/advanced-guides/gang-scheduling.md,cluster/vms/user-guides/community/spark.md,ray-more-libs/ray-collective.md,ray-more-libs/dask-on-ray.md, and the Aim, Comet, MLflow, and Wandb Tune notebooks.DockerClusterlives inray.autoscaler._private, so instead of an API entry,fake-autoscaler.mdnow links to its source.Redirects:
/ray-more-libs/doc/*→/ray-more-libs/api/doc/:splatcovers the Dask stubs that moved. The other APIs were rendered inline on guide pages, so they had no standalone URL to redirect.Base: #66605 and #66751 have merged, so this PR is rebased onto master as a single commit. The content is unchanged from the version reviewed against #66751.
Related issue number
None. This follows up #66751.
Checks
gh pr list --repo ray-project/ray --state open --search "<area keywords>"found no open PR covering these moves.doc/source/on this branch: no autodoc directive outsideAPI_PATH_PREFIXESexcept a syntax example inside a code fence inray-contribute/docs.md, which Sphinx never runs.ci/ray_ci/doc/autodoc.py, the API consistency check's own doc parser, over the Core and RLlib walks. Every new entry parses to a resolvable dotted name. An early draft listed fully qualified names under an unrelatedcurrentmodule, which the parser reads as unresolvable; each new block now sets its owncurrentmodule. The only duplicate names are ones already documented twice on master. I couldn't run the code-side half of the check locally, so premerge is the gate for that half.bazel test //ci/pipeline:test_doc_api_rules_sync: PASSED with the newray-more-libs/api/prefix.ray-more-libs/api/*emitsdoc_api, and the edited guide pages hit the prose skip rule.rtd-redirects validate: 0 errors.make -C doc rtd-build(RtD-faithful,-W), with the base branch's orphaned_includes/_help.rstset aside ([doc] Delete the orphaned _includes/_help.rst #66750 already deleted it on master). The full build flagged one warning:BCConfiginheritstraining()fromMARWILConfigrather than overriding it, so the BC line now links to the class and toMARWILConfig.training(). After that fix, an incremental-Wrebuild reportsbuild succeeded.I confirmed in the HTML that every new cross-reference resolves to its API page or stub.MemoryTrackingCallbacksuses the one-page template. The default template generated 20 stubs, almost all for members inherited fromRLlibCallback, which would have shadowed theRLlibCallbackentries.rtd-redirects simulatefor the Dask stub rule on master, latest, andreleases-2.40.0: no regressions, wrong landings, or new loops. Old stub URLs reach the new stubs in one hop.AI assistance (Claude Code) was used to prepare this change. I reviewed every changed line.