Skip to content

[ci/doc] Add reverse and dedup API-ref consistency policies - #64420

Merged
elliot-barn merged 4 commits into
ray-project:masterfrom
dstrodtman:doc-1151-api-ref-bypass-routes
Jul 15, 2026
Merged

elliot-barn merged 4 commits into
ray-project:masterfrom
dstrodtman:doc-1151-api-ref-bypass-routes

Conversation

@dstrodtman

@dstrodtman dstrodtman commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Why

The API-doc consistency check (ci/ray_ci/doc/, run as the doc: check API doc consistency premerge step) enforces only one direction of the contract: every annotated public API must be documented. It does not verify the converse — that every documented entry resolves to a real, public object — nor that an API is documented only once. A stale .. autosummary:: line (deleted/renamed/misspelled symbol) or a duplicate entry passes today; only the full Sphinx render catches those, late and expensively.

This PR adds two deterministic, Sphinx-free policies over the same parsed doc surface. It is the first of a planned stack; a follow-up will decouple stub generation from the full make html (coordinated separately, as it touches a shared premerge surface).

What

Docs ⊆ code. Every documented name must resolve to a live object; a name resolving to a deprecated or private object fails.

  • New API.resolve() reports a resolution miss as None instead of swallowing it into the raw name string the way get_canonical_name() does — this is what makes stale entries detectable.
  • New API.introspect_annotation_type() reads the live annotation off the resolved object, rather than the placeholder PUBLIC_API that from_autosummary/from_autoclass stamp on every parsed entry.
  • Design note: documented methods (e.g. Dataset.map_batches) are not individually annotated — they are public via their annotated class. So the hard failure is non-resolution (the gap the render's autosummary import warning covers); the annotation check is a secondary gate that only fires on objects that are themselves annotated. This avoids false-flagging the many method entries in the real surface.

No duplicate documentation. A canonical name may not appear in more than one autosummary/autoclass block in a team's walked doc surface. A per-team intentional_duplicate_apis allowlist holds ray.actor.ActorMethod.bind (documented in both the Core and Compiled Graph APIs), mirroring conf.py's DuplicateObjectFilter, which is left in place.

Both run per team in _check_team and fail the team on violation.

Tests

  • test_api.py: resolution, live re-introspection (incl. a case proving the placeholder annotation is overridden), and both policy splits.
  • New test_cmd_check_api_discrepancy.py: _check_team-level coverage of all policies over the mock module, with a new py_test target.
bazel test //ci/ray_ci/doc:test_api //ci/ray_ci/doc:test_cmd_check_api_discrepancy

@dstrodtman
dstrodtman requested a review from a team as a code owner June 29, 2026 19:45

@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 implements documentation validation policies (Policy 02 and Policy 04) to ensure documented APIs resolve to live, public objects and are not duplicated. It introduces API resolution, live annotation introspection, and duplicate detection, along with comprehensive unit tests. The review feedback suggests adding defensive guards against malformed API names and ValueError exceptions during imports, as well as optimizing performance by caching resolved canonical names to avoid redundant traversals.

Comment thread ci/ray_ci/doc/api.py
Comment on lines +139 to +157
tokens = self.name.split(".")
try:
attribute = importlib.import_module(tokens[0])
except ImportError:
return None

walked = tokens[0]
for token in tokens[1:]:
walked = f"{walked}.{token}"
if hasattr(attribute, token):
attribute = getattr(attribute, token)
continue
# The token may be a submodule that has not been imported yet;
# importing it explicitly mirrors how Sphinx resolves the name.
try:
attribute = importlib.import_module(walked)
except ImportError:
return None
return attribute

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

Add defensive guards against empty or malformed API names and catch ValueError during module imports. importlib.import_module can raise ValueError if the module name is empty or contains invalid relative path characters, which could crash the CI run if a malformed doc entry is parsed.

        tokens = self.name.split(".")
        if not tokens or not tokens[0]:
            return None

        try:
            attribute = importlib.import_module(tokens[0])
        except (ImportError, ValueError):
            return None

        walked = tokens[0]
        for token in tokens[1:]:
            walked = f"{walked}.{token}"
            if hasattr(attribute, token):
                attribute = getattr(attribute, token)
                continue
            # The token may be a submodule that has not been imported yet;
            # importing it explicitly mirrors how Sphinx resolves the name.
            try:
                attribute = importlib.import_module(walked)
            except (ImportError, ValueError):
                return None
        return attribute

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in the latest commit (24f7535). Guarded the empty-first-token case and now catch ValueError alongside ImportError in both import sites, so a malformed doc entry is reported as unresolved instead of crashing the checker. Added regression cases ("", .leading.dot, ..double.dot). Thanks for catching this.

Comment thread ci/ray_ci/doc/api.py
Comment on lines +260 to +278
for api in api_in_docs:
canonical_name = api.get_canonical_name()

if canonical_name in white_list_apis or api.name in white_list_apis:
continue

obj = api.resolve()
if obj is None:
unresolved.append(api.name)
continue

annotation_type = API.introspect_annotation_type(obj)
resolved_api = API(
name=canonical_name,
annotation_type=annotation_type,
code_type=api.code_type,
)
if resolved_api.is_deprecated() or resolved_api._is_private_name():
non_public.append(canonical_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

Optimize the resolution and canonical name lookup. Currently, get_canonical_name() is called first (which does a full traversal/import), and then resolve() is called (which does another full traversal/import). By resolving first, we can determine the canonical name directly from the resolved object (if it's a class or function) with a single traversal. Additionally, we can cache this canonical name on the API object so that subsequent policies (like Policy 04) can reuse it without any redundant traversals.

        for api in api_in_docs:
            if api.name in white_list_apis:
                continue

            obj = api.resolve()
            if obj is None:
                unresolved.append(api.name)
                continue

            if inspect.isclass(obj) or inspect.isfunction(obj):
                canonical_name = f"{obj.__module__}.{obj.__qualname__}"
            else:
                canonical_name = api.name

            # Cache the canonical name on the API object to avoid redundant resolution/imports in subsequent policies
            api._canonical_name = canonical_name

            if canonical_name in white_list_apis:
                continue

            annotation_type = API.introspect_annotation_type(obj)
            resolved_api = API(
                name=canonical_name,
                annotation_type=annotation_type,
                code_type=api.code_type,
            )
            if resolved_api.is_deprecated() or resolved_api._is_private_name():
                non_public.append(canonical_name)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Holding off on this one. The perf premise doesn't really apply here: importlib caches imported modules, so resolve() running after get_canonical_name() is a handful of microsecond getattr chains, not a second import — over a bounded doc set that the checker walks once per PR, dwarfed by the cost of importing ray itself.

Against ~no measurable gain it adds two costs I'd rather avoid:

  1. Deriving the canonical name from the resolved object diverges from get_canonical_name() for the re-export-shadowing case fixed in 5573f72 (e.g. ray.util.placement_group, where the function shadows the submodule). Keeping a single canonicalization path matters because Policy 01 matches its whitelist against get_canonical_name() output — two different canonicalizations risk inconsistent whitelist behavior between policies.
  2. Caching _canonical_name as an ad-hoc attribute on the API dataclass couples Policy 04 to Policy 02 having run first on the same objects.

For a CI gate where correctness/consistency outweigh a non-bottleneck micro-optimization, I think the single-path version is the safer call.

Comment thread ci/ray_ci/doc/api.py
Comment on lines +297 to +300
counts = {}
for api in api_in_docs:
canonical_name = api.get_canonical_name()
counts[canonical_name] = counts.get(canonical_name, 0) + 1

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

Reuse the cached canonical name (if available) to avoid redundant imports and traversals during duplicate detection.

Suggested change
counts = {}
for api in api_in_docs:
canonical_name = api.get_canonical_name()
counts[canonical_name] = counts.get(canonical_name, 0) + 1
counts = {}
for api in api_in_docs:
canonical_name = getattr(api, "_canonical_name", None) or api.get_canonical_name()
counts[canonical_name] = counts.get(canonical_name, 0) + 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Declining for the same reasons as the canonical-name caching suggestion above — this reuse depends on the _canonical_name cache, which I'd rather not introduce (perf gain is negligible given module-level import caching, and it would couple Policy 04 to Policy 02 plus diverge from get_canonical_name() for re-export-shadowed names). Policy 04 keeps calling get_canonical_name() so both policies share one canonicalization path.

Comment thread ci/ray_ci/doc/api.py Resolved
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation devprod labels Jun 30, 2026
@dstrodtman
dstrodtman force-pushed the doc-1151-api-ref-bypass-routes branch from 51ef6c0 to f6ac973 Compare July 6, 2026 19:03
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Jul 6, 2026
@dstrodtman
dstrodtman force-pushed the doc-1151-api-ref-bypass-routes branch from f6ac973 to acf231b Compare July 6, 2026 19:47

@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 acf231b. Configure here.

dstrodtman and others added 4 commits July 6, 2026 16:37
The API-doc consistency checker enforced only one direction of the
contract: every annotated public API must be documented. Extend it with
two deterministic, Sphinx-free checks over the same parsed doc surface.

Docs subset of code: every documented name must resolve to a live object,
and a name that resolves to a deprecated or private object fails.
Resolution is strict -- a miss is reported instead of being swallowed into
the raw name string the way get_canonical_name does -- and each documented
name's annotation is read live from the resolved object rather than the
placeholder PUBLIC_API stamped by the autosummary and autoclass parsers.
This catches stale doc entries (renamed, deleted, or misspelled symbols)
that previously only the full Sphinx render flagged. Documented but
un-annotated methods are accepted, since they are public by virtue of
their annotated class.

No duplicate documentation: a canonical name may not appear in more than
one autosummary or autoclass block in a team's walked doc surface. An
intentional-duplicate allowlist holds ray.actor.ActorMethod.bind
(documented in both the Core and Compiled Graph APIs), mirroring conf.py's
DuplicateObjectFilter.

Both checks run per team in _check_team and fail the team on violation.
Adds unit tests for resolution, live re-introspection, and both check
splits, plus _check_team-level tests over the mock module and a new
py_test target.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Found by running the new policies end-to-end for the core team against a
matching ray build:

- API.resolve() walked names with getattr first, so a re-exported function
  that shadows a same-named submodule (e.g. ray.util.placement_group, the
  function, shadows the ray.util.placement_group submodule) caused the
  remaining tokens to fail to resolve -- a false "documented API does not
  resolve". Import the dotted path first and fall back to getattr, matching
  how Sphinx autosummary resolves the name.

- ray.remote (canonical ray._private.worker.remote) is intentionally
  cross-listed under both Tasks and Actors in ray-core/api/core.rst, since
  @ray.remote defines both. Add it to core's intentional-duplicate allowlist
  next to ActorMethod.bind.

With these, the core team passes all three policies.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Address review feedback: a malformed doc entry (an empty name, or one with
a leading/double dot that splits to an empty first token) would make
importlib.import_module("") raise ValueError and crash the checker. Guard
the empty-first-token case and catch ValueError alongside ImportError so a
malformed entry is reported as unresolved instead. Adds regression cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
The docs-subset-of-code check derived an entry's identity from
get_canonical_name() (a getattr-only walk) while reading its annotation
from resolve() (an import-first walk). When a dotted segment is shadowed
-- e.g. a re-exported function sharing a name with a submodule -- those two
walks can land on different objects, so the annotation could be read off
one object while the reported / white-list-checked name came from another.

Resolve each documented name once and derive the canonical name from that
object (new API.canonical_name_of), so identity and annotation share one
walk. The duplicate-documentation check uses the same path, which also
collapses two spellings of a shadowed object to one canonical key.
get_canonical_name() is unchanged and still backs the documented-coverage
check.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@elliot-barn
elliot-barn merged commit 8115b2d into ray-project:master Jul 15, 2026
3 checks passed
elliot-barn pushed a commit that referenced this pull request Jul 15, 2026
…ist (#64783)

## Why are these changes needed?

The per-team API-doc consistency check
(`ci/ray_ci/doc/cmd_check_api_discrepancy.py`) crashes on the `rllib`
team:

```
File "ci/ray_ci/doc/cmd_check_api_discrepancy.py", line 166, in _check_team
    doc_only_whitelist = white_list_apis | config.get("doc_only_whitelist", set())
TypeError: unsupported operand type(s) for |: 'dict' and 'set'
```

The `rllib` config declared its empty whitelist as `{}`, which Python
parses as an empty **dict**, not an empty set. Every other team uses a
non-empty set literal, so `rllib` was the only team whose
`white_list_apis` was a dict.

The mismatch stayed latent while `white_list_apis` was used only in `in`
membership tests, where an empty dict and an empty set behave
identically. The reverse/dedup policy work (#64420) added a
`white_list_apis | config.get("doc_only_whitelist", set())` union, and
`dict | set` raises `TypeError` — breaking the check for every
doc-scoped PR that reaches the `rllib` team.

The fix declares the empty whitelist as `set()` so its type matches the
other teams and the union operand.

## Related issue number

N/A — regression from #64420.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests.
- Testing Strategy
   - [x] Unit tests

Signed-off-by: Douglas Strodtman <[email protected]>
ArturNiederfahrenhorst added a commit that referenced this pull request Jul 20, 2026
…ies (#64807)

#64420 added reverse (documented-must-resolve-to-public) and dedup
(documented-exactly-once) policies to the API-doc consistency check, and
#64783/#64786 populated per-team exemptions for every team except RLlib
(whose white_list_apis was left empty). The stricter check now flags ~30
pre-existing RLlib doc entries, failing the "doc: check API doc
consistency" premerge job on every PR that merges current master.

This fixes the RLlib side:

Unresolved doc entries:
- De-double autoclass targets that combined `.. currentmodule::` with a
fully-qualified name (RLlink, ConnectorV2, ConnectorPipelineV2, the
observation preprocessors, and the RLModule `apis` classes) by making
the autoclass argument relative to its currentmodule.
- RLModuleSpec dataclass fields -> `.. autoattribute:: ... :no-index:`
(mirrors the existing MultiRLModuleSpec block).
- RLModule instance attributes (observation_space, action_space,
inference_only, model_config) are assigned in setup(), not on the class,
so they resolve to None; exempt them via doc_only_whitelist.

Documented private/dunder objects:
- Whitelist the intentional override contract (RLModule._forward*,
Learner._make_module).
- Remove doc entries for internal helpers (Learner._check_is_built /
_check_registered_optimizer / _set_optimizer_lr / _get_clip_function,
Scheduler._create_tensor_variable, OfflineData/OfflinePreLearner
privates, SingleAgentEpisode/MultiAgentEpisode.__len__).

Duplicate documentation:
- Mark intentional cross-page duplicates as intentional_duplicate_apis
(AlgorithmConfig.build_learner / build_learner_group / learners;
Checkpointable.save_to_path / restore_from_path, inherited and shown on
each subclass page).

---------

Signed-off-by: Artur Niederfahrenhorst <[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
…ect#64420)

## Why

The API-doc consistency check (`ci/ray_ci/doc/`, run as the `doc: check
API doc consistency` premerge step) enforces only **one direction** of
the contract: every annotated public API must be documented. It does
**not** verify the converse — that every documented entry resolves to a
real, public object — nor that an API is documented only once. A stale
`.. autosummary::` line (deleted/renamed/misspelled symbol) or a
duplicate entry passes today; only the full Sphinx render catches those,
late and expensively.

This PR adds two deterministic, **Sphinx-free** policies over the same
parsed doc surface. It is the first of a planned stack; a follow-up will
decouple stub generation from the full `make html` (coordinated
separately, as it touches a shared premerge surface).

## What

**Docs ⊆ code.** Every documented name must resolve to a live object; a
name resolving to a deprecated or private object fails.
- New `API.resolve()` reports a resolution miss as `None` instead of
swallowing it into the raw name string the way `get_canonical_name()`
does — this is what makes stale entries detectable.
- New `API.introspect_annotation_type()` reads the **live** annotation
off the resolved object, rather than the placeholder `PUBLIC_API` that
`from_autosummary`/`from_autoclass` stamp on every parsed entry.
- Design note: documented **methods** (e.g. `Dataset.map_batches`) are
not individually annotated — they are public via their annotated class.
So the hard failure is *non-resolution* (the gap the render's
autosummary import warning covers); the annotation check is a secondary
gate that only fires on objects that are themselves annotated. This
avoids false-flagging the many method entries in the real surface.

**No duplicate documentation.** A canonical name may not appear in more
than one autosummary/autoclass block in a team's walked doc surface. A
per-team `intentional_duplicate_apis` allowlist holds
`ray.actor.ActorMethod.bind` (documented in both the Core and Compiled
Graph APIs), mirroring conf.py's `DuplicateObjectFilter`, which is left
in place.

Both run per team in `_check_team` and fail the team on violation.

## Tests

- `test_api.py`: resolution, live re-introspection (incl. a case proving
the placeholder annotation is overridden), and both policy splits.
- New `test_cmd_check_api_discrepancy.py`: `_check_team`-level coverage
of all policies over the mock module, with a new `py_test` target.

```
bazel test //ci/ray_ci/doc:test_api //ci/ray_ci/doc:test_cmd_check_api_discrepancy
```

---------

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

## Why are these changes needed?

The per-team API-doc consistency check
(`ci/ray_ci/doc/cmd_check_api_discrepancy.py`) crashes on the `rllib`
team:

```
File "ci/ray_ci/doc/cmd_check_api_discrepancy.py", line 166, in _check_team
    doc_only_whitelist = white_list_apis | config.get("doc_only_whitelist", set())
TypeError: unsupported operand type(s) for |: 'dict' and 'set'
```

The `rllib` config declared its empty whitelist as `{}`, which Python
parses as an empty **dict**, not an empty set. Every other team uses a
non-empty set literal, so `rllib` was the only team whose
`white_list_apis` was a dict.

The mismatch stayed latent while `white_list_apis` was used only in `in`
membership tests, where an empty dict and an empty set behave
identically. The reverse/dedup policy work (ray-project#64420) added a
`white_list_apis | config.get("doc_only_whitelist", set())` union, and
`dict | set` raises `TypeError` — breaking the check for every
doc-scoped PR that reaches the `rllib` team.

The fix declares the empty whitelist as `set()` so its type matches the
other teams and the union operand.

## Related issue number

N/A — regression from ray-project#64420.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests.
- Testing Strategy
   - [x] Unit tests

Signed-off-by: Douglas Strodtman <[email protected]>
Signed-off-by: 400Ping <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…ies (ray-project#64807)

ray-project#64420 added reverse (documented-must-resolve-to-public) and dedup
(documented-exactly-once) policies to the API-doc consistency check, and
ray-project#64783/ray-project#64786 populated per-team exemptions for every team except RLlib
(whose white_list_apis was left empty). The stricter check now flags ~30
pre-existing RLlib doc entries, failing the "doc: check API doc
consistency" premerge job on every PR that merges current master.

This fixes the RLlib side:

Unresolved doc entries:
- De-double autoclass targets that combined `.. currentmodule::` with a
fully-qualified name (RLlink, ConnectorV2, ConnectorPipelineV2, the
observation preprocessors, and the RLModule `apis` classes) by making
the autoclass argument relative to its currentmodule.
- RLModuleSpec dataclass fields -> `.. autoattribute:: ... :no-index:`
(mirrors the existing MultiRLModuleSpec block).
- RLModule instance attributes (observation_space, action_space,
inference_only, model_config) are assigned in setup(), not on the class,
so they resolve to None; exempt them via doc_only_whitelist.

Documented private/dunder objects:
- Whitelist the intentional override contract (RLModule._forward*,
Learner._make_module).
- Remove doc entries for internal helpers (Learner._check_is_built /
_check_registered_optimizer / _set_optimizer_lr / _get_clip_function,
Scheduler._create_tensor_variable, OfflineData/OfflinePreLearner
privates, SingleAgentEpisode/MultiAgentEpisode.__len__).

Duplicate documentation:
- Mark intentional cross-page duplicates as intentional_duplicate_apis
(AlgorithmConfig.build_learner / build_learner_group / learners;
Checkpointable.save_to_path / restore_from_path, inherited and shown on
each subclass page).

---------

Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: 400Ping <[email protected]>
dstrodtman added a commit that referenced this pull request Sep 30, 2026
#66612)

## Why

The [API
policy](https://docs.ray.io/en/latest/ray-contribute/api-policy.html)
says deprecated APIs must be documented. The docs-side half of `doc:
check API doc consistency`, added in #64420, did the opposite: it failed
any documented autosummary or autoclass entry that resolved to a
`@Deprecated` object. That's what blocked #66308, which deprecates
`read_clickhouse` and `write_clickhouse` and leaves them documented with
a deprecation notice, which is what the policy asks for.

Teams have been working around the rule instead. Ray Data kept its
deprecated APIs in `tracked_doc_debt` under a comment asking for them to
be removed from the docs.

## What

- `API.split_resolvable_and_broken_doc_apis` no longer flags deprecated
objects. It still fails documented names that don't resolve and
documented names that resolve to private objects (`_foo` or
`._internal.`), with the existing override-hook and `__all__` re-export
exemptions unchanged.
- It returns `(unresolved, private)` instead of `(unresolved,
non_public)`, and the error output says "private" instead of "deprecated
/ private."
- `API.introspect_annotation_type` is removed. The deprecated check was
its only caller. The inherited-annotation behavior it tested is still
covered through `Module` in `test_module.py`.
- The four Ray Data `tracked_doc_debt` entries for deprecated APIs are
removed: `AggregateFn`, `Dataset.iter_tf_batches`,
`Dataset.to_random_access_dataset`, and `read_unity_catalog`. All four
are `@Deprecated` in source, so the entries only existed to get around
this rule.

Out of scope: the policy also implies the code-side check should
*require* deprecated APIs to be documented. Today that check skips them.
There are about 90 `@Deprecated` decorators under `python/ray`, many on
undocumented methods, so turning that on is a per-team burndown and
belongs in a follow-up.

## Duplicate check

No open PR touches this rule. I searched open PRs for
`api_policy_check`, `cmd_check_api_discrepancy`, and "API doc
consistency" together with deprecation. #66308 is the PR this unblocks,
not a duplicate.

## Testing

```
python -m pytest ci/ray_ci/doc/test_api.py ci/ray_ci/doc/test_cmd_check_api_discrepancy.py ci/ray_ci/doc/test_module.py
40 passed
pre-commit run --files <changed files>   # ruff, black, docstyle, import order: all passed
```

I didn't run the checker end to end against a real Ray install. This
PR's `doc: check API doc consistency` step does that, and should pass
with the four Data exemptions removed.

This PR was written with AI assistance (Claude Code). I reviewed the
change.

🤖 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]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
ray-project#66612)

## Why

The [API
policy](https://docs.ray.io/en/latest/ray-contribute/api-policy.html)
says deprecated APIs must be documented. The docs-side half of `doc:
check API doc consistency`, added in ray-project#64420, did the opposite: it failed
any documented autosummary or autoclass entry that resolved to a
`@Deprecated` object. That's what blocked ray-project#66308, which deprecates
`read_clickhouse` and `write_clickhouse` and leaves them documented with
a deprecation notice, which is what the policy asks for.

Teams have been working around the rule instead. Ray Data kept its
deprecated APIs in `tracked_doc_debt` under a comment asking for them to
be removed from the docs.

## What

- `API.split_resolvable_and_broken_doc_apis` no longer flags deprecated
objects. It still fails documented names that don't resolve and
documented names that resolve to private objects (`_foo` or
`._internal.`), with the existing override-hook and `__all__` re-export
exemptions unchanged.
- It returns `(unresolved, private)` instead of `(unresolved,
non_public)`, and the error output says "private" instead of "deprecated
/ private."
- `API.introspect_annotation_type` is removed. The deprecated check was
its only caller. The inherited-annotation behavior it tested is still
covered through `Module` in `test_module.py`.
- The four Ray Data `tracked_doc_debt` entries for deprecated APIs are
removed: `AggregateFn`, `Dataset.iter_tf_batches`,
`Dataset.to_random_access_dataset`, and `read_unity_catalog`. All four
are `@Deprecated` in source, so the entries only existed to get around
this rule.

Out of scope: the policy also implies the code-side check should
*require* deprecated APIs to be documented. Today that check skips them.
There are about 90 `@Deprecated` decorators under `python/ray`, many on
undocumented methods, so turning that on is a per-team burndown and
belongs in a follow-up.

## Duplicate check

No open PR touches this rule. I searched open PRs for
`api_policy_check`, `cmd_check_api_discrepancy`, and "API doc
consistency" together with deprecation. ray-project#66308 is the PR this unblocks,
not a duplicate.

## Testing

```
python -m pytest ci/ray_ci/doc/test_api.py ci/ray_ci/doc/test_cmd_check_api_discrepancy.py ci/ray_ci/doc/test_module.py
40 passed
pre-commit run --files <changed files>   # ruff, black, docstyle, import order: all passed
```

I didn't run the checker end to end against a real Ray install. This
PR's `doc: check API doc consistency` step does that, and should pass
with the four Data exemptions removed.

This PR was written with AI assistance (Claude Code). I reviewed the
change.

🤖 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]>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants