Skip to content

[ci/doc] Guard against annotated subpackages that escape the API walk - #64514

Closed
dstrodtman wants to merge 2 commits into
ray-project:masterfrom
dstrodtman:doc-1313-apiref-coverage-guard
Closed

dstrodtman wants to merge 2 commits into
ray-project:masterfrom
dstrodtman:doc-1313-apiref-coverage-guard

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Why

The API doc consistency check (ci/ray_ci/doc/cmd_check_api_discrepancy.py)
only sees APIs that its module walk reaches, and the walk only follows
submodules a parent __init__ actually imports. A public,
@PublicAPI-annotated subpackage that its parent does not import is invisible
to the check — its APIs can silently rot undocumented.

ray.serve.llm and ray.data.llm are both such surfaces today: documented and
annotated, but reached by no walk.

What

  • Onboard ray.serve.llm by adding it to the serve head_modules. It is
    import-safe in the docbuild image (transformers is a soft try_import, and
    vLLM is only imported lazily), so it can be its own walk root.
  • Add a cross-team coverage guard that enumerates one level of subpackages
    under every configured head module and fails when an annotated subpackage is
    neither reached by any walk nor knowingly excluded. A reviewed allowlist
    records the intentional exclusions and the reason for each.
  • Allowlist ray.data.llm. Unlike ray.serve.llm, it eagerly imports the
    vLLM/SGLang engine processor configs, which do a hard import transformers
    at module load. transformers is absent from the docbuild image
    (python/deplocks/docs/docbuild_depset_py3.11.lock), so ray.data.llm
    cannot be imported by this check. Its surface stays documented in
    doc/source/data/api/llm.rst.
  • Track reachable module names on Module so the guard distinguishes "actually
    walked" from "merely name-prefixed" (ray.data.llm is prefixed by ray.data
    yet never imported by ray/data/__init__.py).
  • Unit-test the guard's decision core and helpers against the mock module.

Stacking

This PR is stacked on top of the API-ref consistency-policy work and should be
reviewed/merged after it (its diff transitively shows those commits until they
land):

Kept as a draft until the base PRs merge; it will be rebased onto master
afterward.

Checks

The decisive check is doc: check API doc consistency — it exercises the new
guard, ray.serve.llm in head_modules, and the ray.data.llm allowlist
against the real docbuild image.

🤖 Generated with Claude Code

@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 optimizes the API documentation consistency check by generating only the necessary autosummary stub files via a new standalone script (api_autogen.py), eliminating the need to build the entire HTML documentation. It also introduces Policy 02 (ensuring documented APIs resolve to public code) and Policy 04 (preventing duplicate documentation), along with a coverage guard to catch unwalked annotated subpackages. The feedback suggests adding exception handling around dynamic attribute inspection and module iteration in cmd_check_api_discrepancy.py to prevent crashes from lazy imports or invalid paths.

Comment on lines +185 to +191
for attr in dir(mod):
obj = getattr(mod, attr, None)
origin = getattr(obj, "__module__", None)
if not origin or (origin != module and not origin.startswith(f"{module}.")):
continue
if hasattr(obj, "_annotated"):
return (True, True)

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.

high

Accessing attributes dynamically via getattr on a module can trigger lazy imports or properties that raise exceptions (such as ModuleNotFoundError for missing optional dependencies). Wrapping the attribute inspection in a try-except block ensures that optional dependency failures or buggy attributes do not crash the entire API consistency check.

Suggested change
for attr in dir(mod):
obj = getattr(mod, attr, None)
origin = getattr(obj, "__module__", None)
if not origin or (origin != module and not origin.startswith(f"{module}.")):
continue
if hasattr(obj, "_annotated"):
return (True, True)
for attr in dir(mod):
try:
obj = getattr(mod, attr, None)
origin = getattr(obj, "__module__", None)
if not origin or (origin != module and not origin.startswith(f"{module}.")):
continue
if hasattr(obj, "_annotated"):
return (True, True)
except Exception:
continue

Comment on lines +166 to +170
children = []
for info in pkgutil.iter_modules(pkg.__path__, prefix=f"{package}."):
if info.name.rsplit(".", 1)[-1].startswith("_"):
continue
children.append(info.name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Calling pkgutil.iter_modules on pkg.__path__ can raise exceptions if any of the paths in __path__ are invalid, non-existent, or inaccessible (e.g., due to permission issues or virtual environment configurations). Wrapping this in a try-except block makes the subpackage discovery more robust.

Suggested change
children = []
for info in pkgutil.iter_modules(pkg.__path__, prefix=f"{package}."):
if info.name.rsplit(".", 1)[-1].startswith("_"):
continue
children.append(info.name)
children = []
try:
for info in pkgutil.iter_modules(pkg.__path__, prefix=f"{package}."):
if info.name.rsplit(".", 1)[-1].startswith("_"):
continue
children.append(info.name)
except Exception:
pass

@dstrodtman
dstrodtman force-pushed the doc-1313-apiref-coverage-guard branch from 17028a4 to 02f54be Compare July 2, 2026 18:50
@dstrodtman

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Two notes:

Scope: this PR only adds three things — ray.serve.llm to the serve head_modules, an UNWALKED_ANNOTATED_ALLOWLIST entry for ray.data.llm, and the cross-team coverage guard (_check_unwalked_annotated_subpackages) plus its tests. The api_autogen.py script and Policies 02/04 mentioned in the summary belong to the PRs this one is stacked on (#64423 → #64420); they show up here only because GitHub can't base a fork PR on another fork branch, so the diff is against master until those land.

Both inline suggestions adopted in the latest push:

  • _import_status: wrapped the per-attribute getattr/inspection in try/except … continue. This is exactly the right call for this guard — a module with a PEP 562 __getattr__ (e.g. the batch processor package) can trigger a heavy optional-dep import on attribute access, which would otherwise crash the check for every team. Added a regression test with an "exploding" lazy attribute.
  • _immediate_child_modules: wrapped pkgutil.iter_modules(pkg.__path__, …) so a bad/inaccessible __path__ entry yields no children instead of raising.

Both are consistent with the guard's own principle: an optional-dependency failure should downgrade coverage of one module, never crash the whole consistency check.

@dstrodtman
dstrodtman force-pushed the doc-1313-apiref-coverage-guard branch 3 times, most recently from 6fa7e38 to 87c4429 Compare July 6, 2026 20:50
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jul 21, 2026
@dstrodtman dstrodtman added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Jul 24, 2026
The code<->docs API consistency check only sees APIs that its module walk
reaches, and the walk only follows submodules a parent `__init__` actually
imports. A public, `@PublicAPI`-annotated subpackage that its parent does not
import is invisible to the check, so its APIs can silently rot undocumented.
`ray.serve.llm` and `ray.data.llm` are both such surfaces today: they are
documented and annotated, but no walk reaches them.

- Add `ray.serve.llm` to the serve `head_modules` so its public surface is
  walked. It is import-safe in the docbuild image (transformers is a soft
  `try_import`, vLLM is only imported lazily).
- Add a cross-team guard that enumerates one level of subpackages under every
  configured head module and fails when an annotated subpackage is neither
  reached by any walk nor knowingly excluded. A reviewed allowlist records the
  intentional exclusions and why.
- Allowlist `ray.data.llm`: it eagerly imports the vLLM/SGLang engine
  processor configs, which do a hard `import transformers` at module load, and
  transformers is absent from the docbuild image, so it cannot be imported by
  this check. Its surface stays documented in `doc/source/data/api/llm.rst`.
- Track reachable module names on `Module` so the guard can tell "walked" from
  "merely name-prefixed" (`ray.data.llm` is prefixed by `ray.data` yet never
  imported).
- Unit-test the guard's decision core and helpers against the mock module.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman force-pushed the doc-1313-apiref-coverage-guard branch from 87c4429 to 1875119 Compare July 24, 2026 17:09
@dstrodtman
dstrodtman marked this pull request as ready for review July 27, 2026 13:51
@dstrodtman
dstrodtman requested a review from a team as a code owner July 27, 2026 13:51
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Jul 27, 2026

@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 introduces a cross-team coverage guard to detect annotated public subpackages that are not reached by any team's walk during the API consistency check, along with corresponding unit tests and tracking updates in the Module class. The reviewer identified a critical issue where running the entire coverage guard outside of the backend mock environment could cause head modules with optional dependencies to fail to import, silently disabling the guard for their subpackages. To resolve this, the reviewer suggested collecting the covered modules and immediate children inside the mock block while keeping the actual import status checks outside of it.

Comment on lines +365 to +385
def _check_unwalked_annotated_subpackages() -> bool:
"""Guard: fail when an annotated public subpackage escapes every team's walk.

The code<->docs consistency check only sees APIs the walk reaches, and the walk
only follows submodules a parent __init__ actually imports. A public subpackage
that its parent does not import (e.g. ray.data.llm, ray.serve.llm) is invisible to
the check -- its APIs can silently rot undocumented. This guard enumerates one
level of subpackages under every configured head module and fails on any that is
neither walked nor knowingly excluded via UNWALKED_ANNOTATED_ALLOWLIST.
"""
print(
"--- Validating that annotated subpackages are reachable by some walk...",
file=sys.stderr,
)
covered = _covered_module_names()

child_status: Dict[str, Tuple[bool, bool]] = {}
for head in _team_head_modules():
for child in _immediate_child_modules(head):
if child not in child_status:
child_status[child] = _import_status(child)

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.

high

Running the entire coverage guard outside of _mock_uninstalled_backends introduces a silent coverage gap. If a head module itself (e.g., ray.rllib or ray.train) fails to import without the backend mocks, _immediate_child_modules(head) will catch the exception and return []. This silently disables the guard for all of its subpackages, meaning any new unwalked public subpackages under those teams will go completely unnoticed.

To fix this, we should collect the covered module names and children list inside the mock block (where head modules can import successfully), and then pass them to _check_unwalked_annotated_subpackages to perform the actual import status checks outside the mock block.

Suggested change
def _check_unwalked_annotated_subpackages() -> bool:
"""Guard: fail when an annotated public subpackage escapes every team's walk.
The code<->docs consistency check only sees APIs the walk reaches, and the walk
only follows submodules a parent __init__ actually imports. A public subpackage
that its parent does not import (e.g. ray.data.llm, ray.serve.llm) is invisible to
the check -- its APIs can silently rot undocumented. This guard enumerates one
level of subpackages under every configured head module and fails on any that is
neither walked nor knowingly excluded via UNWALKED_ANNOTATED_ALLOWLIST.
"""
print(
"--- Validating that annotated subpackages are reachable by some walk...",
file=sys.stderr,
)
covered = _covered_module_names()
child_status: Dict[str, Tuple[bool, bool]] = {}
for head in _team_head_modules():
for child in _immediate_child_modules(head):
if child not in child_status:
child_status[child] = _import_status(child)
def _check_unwalked_annotated_subpackages(covered: Set[str], children: List[str]) -> bool:
"""Guard: fail when an annotated public subpackage escapes every team's walk.
The code<->docs consistency check only sees APIs the walk reaches, and the walk
only follows submodules a parent __init__ actually imports. A public subpackage
that its parent does not import (e.g. ray.data.llm, ray.serve.llm) is invisible to
the check -- its APIs can silently rot undocumented. This guard fails on any
unwalked annotated subpackage that is not knowingly excluded via
UNWALKED_ANNOTATED_ALLOWLIST.
"""
print(
"--- Validating that annotated subpackages are reachable by some walk...",
file=sys.stderr,
)
child_status: Dict[str, Tuple[bool, bool]] = {}
for child in children:
if child not in child_status:
child_status[child] = _import_status(child)

Comment on lines 591 to +603
continue
if not _check_team(ray_checkout_dir, team):
all_pass = False
if not all_pass:
exit(1)

# Cross-team guard: catch annotated subpackages that no team's walk reaches.
# It runs outside _mock_uninstalled_backends on purpose. The guard reasons
# about real import behavior in the docbuild image -- an optional-dependency
# subpackage that genuinely can't be imported (e.g. ray.data.llm, whose eager
# `import transformers` fails there) is categorized "unverifiable" and recorded
# in UNWALKED_ANNOTATED_ALLOWLIST. Running it under the backend mock would make
# those modules import cleanly and silently defeat that reasoning.
if not _check_unwalked_annotated_subpackages():
all_pass = False

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.

high

Collect the covered module names and immediate children inside the _mock_uninstalled_backends block to ensure head modules with optional dependencies can be imported successfully, and then pass them to _check_unwalked_annotated_subpackages outside the mock block.

Suggested change
continue
if not _check_team(ray_checkout_dir, team):
all_pass = False
if not all_pass:
exit(1)
# Cross-team guard: catch annotated subpackages that no team's walk reaches.
# It runs outside _mock_uninstalled_backends on purpose. The guard reasons
# about real import behavior in the docbuild image -- an optional-dependency
# subpackage that genuinely can't be imported (e.g. ray.data.llm, whose eager
# `import transformers` fails there) is categorized "unverifiable" and recorded
# in UNWALKED_ANNOTATED_ALLOWLIST. Running it under the backend mock would make
# those modules import cleanly and silently defeat that reasoning.
if not _check_unwalked_annotated_subpackages():
all_pass = False
continue
if not _check_team(ray_checkout_dir, team):
all_pass = False
# Collect covered modules and immediate children under the mock environment
# so that head modules with optional dependencies can be imported successfully.
covered = _covered_module_names()
children = []
for head in _team_head_modules():
children.extend(_immediate_child_modules(head))
# Cross-team guard: catch annotated subpackages that no team's walk reaches.
# It runs outside _mock_uninstalled_backends on purpose. The guard reasons
# about real import behavior in the docbuild image -- an optional-dependency
# subpackage that genuinely can't be imported (e.g. ray.data.llm, whose eager
# `import transformers` fails there) is categorized "unverifiable" and recorded
# in UNWALKED_ANNOTATED_ALLOWLIST. Running it under the backend mock would make
# those modules import cleanly and silently defeat that reasoning.
if not _check_unwalked_annotated_subpackages(covered, children):
all_pass = False

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit a111945. Configure here.

# (transformers is a soft try_import; vllm is only imported lazily), so it can
# be a walk root of its own. The unwalked-subpackage guard would otherwise flag
# it. (Its sibling ray.data.llm is NOT import-safe -- see UNWALKED_*_ALLOWLIST.)
"head_modules": {"ray.serve", "ray.serve.llm"},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Serve LLM children trip coverage guard

High Severity

Adding ray.serve.llm as a head_modules entry makes the new guard enumerate its immediate children. Those children (deployment, ingress, openai_api_models, request_router) define @PublicAPI symbols, are import-safe, are never imported by ray.serve.llm’s __init__ (so no walk reaches them), and are absent from UNWALKED_ANNOTATED_ALLOWLIST. The guard therefore fails the consistency check it was meant to pass.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a111945. Configure here.

@ray-gardener ray-gardener Bot added serve Ray Serve Related Issue docs An issue or change related to documentation devprod labels Jul 27, 2026
dstrodtman added a commit that referenced this pull request Aug 3, 2026
…ting it (#65040)

## Why

This is an **alternative** to #64514. Same goal — no `@PublicAPI`
subpackage silently escapes the code↔docs consistency walk — but it
walks `ray.data.llm` instead of allowlisting it.

#64514 allowlists `ray.data.llm` on the premise that its eager `import
transformers` (via the vLLM/SGLang engine processor configs) can't be
imported in the docbuild image. That premise predates the
`_mock_uninstalled_backends` wrapper now on `master`, which mocks
exactly the backends the docbuild image lacks. Under that mock,
`ray.data.llm` imports cleanly and can be a walk root like
`ray.serve.llm` — so its documented surface gets checked rather than
merely excluded.

## What

- Add `ray.data.llm` to the data team `head_modules`. Its surface is
documented in `doc/source/data/api/llm.rst`, reachable from `api.rst`'s
toctree, so the walk checks the code surface against the real docs.
- Run the cross-team coverage guard **inside**
`_mock_uninstalled_backends` so its coverage check and import probes see
the same mocks as the walks; a promoted head like `ray.data.llm` is
counted as covered, not flagged.
- Empty `UNWALKED_ANNOTATED_ALLOWLIST`: both known escapees
(`ray.serve.llm`, `ray.data.llm`) are now walked. The list stays as the
reviewed record for any future subpackage that genuinely can't be a walk
root.
- Decouple the guard decision-core unit tests from real module names.

## Relationship to #64514

Pick one, not both. This branch carries #64514's guard commit plus one
delta commit; if this approach is preferred, the two squash into one
before un-drafting.

## Checks

The decisive check is **doc: check API doc consistency** — it exercises
the mocked `ray.data.llm` import path this approach depends on, against
the real docbuild image. Kept as a draft until that check is confirmed
green.

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

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
@dstrodtman

Copy link
Copy Markdown
Contributor Author

Superseded by #65040

@dstrodtman dstrodtman closed this Aug 3, 2026
@dstrodtman
dstrodtman deleted the doc-1313-apiref-coverage-guard branch August 3, 2026 18:01
goutamvenkat-anyscale pushed a commit to goutamvenkat-anyscale/ray that referenced this pull request Aug 3, 2026
…ting it (ray-project#65040)

## Why

This is an **alternative** to ray-project#64514. Same goal — no `@PublicAPI`
subpackage silently escapes the code↔docs consistency walk — but it
walks `ray.data.llm` instead of allowlisting it.

ray-project#64514 allowlists `ray.data.llm` on the premise that its eager `import
transformers` (via the vLLM/SGLang engine processor configs) can't be
imported in the docbuild image. That premise predates the
`_mock_uninstalled_backends` wrapper now on `master`, which mocks
exactly the backends the docbuild image lacks. Under that mock,
`ray.data.llm` imports cleanly and can be a walk root like
`ray.serve.llm` — so its documented surface gets checked rather than
merely excluded.

## What

- Add `ray.data.llm` to the data team `head_modules`. Its surface is
documented in `doc/source/data/api/llm.rst`, reachable from `api.rst`'s
toctree, so the walk checks the code surface against the real docs.
- Run the cross-team coverage guard **inside**
`_mock_uninstalled_backends` so its coverage check and import probes see
the same mocks as the walks; a promoted head like `ray.data.llm` is
counted as covered, not flagged.
- Empty `UNWALKED_ANNOTATED_ALLOWLIST`: both known escapees
(`ray.serve.llm`, `ray.data.llm`) are now walked. The list stays as the
reviewed record for any future subpackage that genuinely can't be a walk
root.
- Decouple the guard decision-core unit tests from real module names.

## Relationship to ray-project#64514

Pick one, not both. This branch carries ray-project#64514's guard commit plus one
delta commit; if this approach is preferred, the two squash into one
before un-drafting.

## Checks

The decisive check is **doc: check API doc consistency** — it exercises
the mocked `ray.data.llm` import path this approach depends on, against
the real docbuild image. Kept as a draft until that check is confirmed
green.

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

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Artimislyy pushed a commit to Artimislyy/ray that referenced this pull request Aug 11, 2026
…ting it (ray-project#65040)

## Why

This is an **alternative** to ray-project#64514. Same goal — no `@PublicAPI`
subpackage silently escapes the code↔docs consistency walk — but it
walks `ray.data.llm` instead of allowlisting it.

ray-project#64514 allowlists `ray.data.llm` on the premise that its eager `import
transformers` (via the vLLM/SGLang engine processor configs) can't be
imported in the docbuild image. That premise predates the
`_mock_uninstalled_backends` wrapper now on `master`, which mocks
exactly the backends the docbuild image lacks. Under that mock,
`ray.data.llm` imports cleanly and can be a walk root like
`ray.serve.llm` — so its documented surface gets checked rather than
merely excluded.

## What

- Add `ray.data.llm` to the data team `head_modules`. Its surface is
documented in `doc/source/data/api/llm.rst`, reachable from `api.rst`'s
toctree, so the walk checks the code surface against the real docs.
- Run the cross-team coverage guard **inside**
`_mock_uninstalled_backends` so its coverage check and import probes see
the same mocks as the walks; a promoted head like `ray.data.llm` is
counted as covered, not flagged.
- Empty `UNWALKED_ANNOTATED_ALLOWLIST`: both known escapees
(`ray.serve.llm`, `ray.data.llm`) are now walked. The list stays as the
reviewed record for any future subpackage that genuinely can't be a walk
root.
- Decouple the guard decision-core unit tests from real module names.

## Relationship to ray-project#64514

Pick one, not both. This branch carries ray-project#64514's guard commit plus one
delta commit; if this approach is preferred, the two squash into one
before un-drafting.

## Checks

The decisive check is **doc: check API doc consistency** — it exercises
the mocked `ray.data.llm` import path this approach depends on, against
the real docbuild image. Kept as a draft until that check is confirmed
green.

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

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…ting it (ray-project#65040)

## Why

This is an **alternative** to ray-project#64514. Same goal — no `@PublicAPI`
subpackage silently escapes the code↔docs consistency walk — but it
walks `ray.data.llm` instead of allowlisting it.

ray-project#64514 allowlists `ray.data.llm` on the premise that its eager `import
transformers` (via the vLLM/SGLang engine processor configs) can't be
imported in the docbuild image. That premise predates the
`_mock_uninstalled_backends` wrapper now on `master`, which mocks
exactly the backends the docbuild image lacks. Under that mock,
`ray.data.llm` imports cleanly and can be a walk root like
`ray.serve.llm` — so its documented surface gets checked rather than
merely excluded.

## What

- Add `ray.data.llm` to the data team `head_modules`. Its surface is
documented in `doc/source/data/api/llm.rst`, reachable from `api.rst`'s
toctree, so the walk checks the code surface against the real docs.
- Run the cross-team coverage guard **inside**
`_mock_uninstalled_backends` so its coverage check and import probes see
the same mocks as the walks; a promoted head like `ray.data.llm` is
counted as covered, not flagged.
- Empty `UNWALKED_ANNOTATED_ALLOWLIST`: both known escapees
(`ray.serve.llm`, `ray.data.llm`) are now walked. The list stays as the
reviewed record for any future subpackage that genuinely can't be a walk
root.
- Decouple the guard decision-core unit tests from real module names.

## Relationship to ray-project#64514

Pick one, not both. This branch carries ray-project#64514's guard commit plus one
delta commit; if this approach is preferred, the two squash into one
before un-drafting.

## Checks

The decisive check is **doc: check API doc consistency** — it exercises
the mocked `ray.data.llm` import path this approach depends on, against
the real docbuild image. Kept as a draft until that check is confirmed
green.

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

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: 400Ping <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ting it (ray-project#65040)

## Why

This is an **alternative** to ray-project#64514. Same goal — no `@PublicAPI`
subpackage silently escapes the code↔docs consistency walk — but it
walks `ray.data.llm` instead of allowlisting it.

ray-project#64514 allowlists `ray.data.llm` on the premise that its eager `import
transformers` (via the vLLM/SGLang engine processor configs) can't be
imported in the docbuild image. That premise predates the
`_mock_uninstalled_backends` wrapper now on `master`, which mocks
exactly the backends the docbuild image lacks. Under that mock,
`ray.data.llm` imports cleanly and can be a walk root like
`ray.serve.llm` — so its documented surface gets checked rather than
merely excluded.

## What

- Add `ray.data.llm` to the data team `head_modules`. Its surface is
documented in `doc/source/data/api/llm.rst`, reachable from `api.rst`'s
toctree, so the walk checks the code surface against the real docs.
- Run the cross-team coverage guard **inside**
`_mock_uninstalled_backends` so its coverage check and import probes see
the same mocks as the walks; a promoted head like `ray.data.llm` is
counted as covered, not flagged.
- Empty `UNWALKED_ANNOTATED_ALLOWLIST`: both known escapees
(`ray.serve.llm`, `ray.data.llm`) are now walked. The list stays as the
reviewed record for any future subpackage that genuinely can't be a walk
root.
- Decouple the guard decision-core unit tests from real module names.

## Relationship to ray-project#64514

Pick one, not both. This branch carries ray-project#64514's guard commit plus one
delta commit; if this approach is preferred, the two squash into one
before un-drafting.

## Checks

The decisive check is **doc: check API doc consistency** — it exercises
the mocked `ray.data.llm` import path this approach depends on, against
the real docbuild image. Kept as a draft until that check is confirmed
green.

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

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devprod docs An issue or change related to documentation go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant