Skip to content

[Data] Deprecate ray_remote_args_fn - #64963

Merged
bveeramani merged 10 commits into
ray-project:masterfrom
yuhuan130:deprecate/data-ray-remote-args-fn
Aug 3, 2026
Merged

bveeramani merged 10 commits into
ray-project:masterfrom
yuhuan130:deprecate/data-ray-remote-args-fn

Conversation

@yuhuan130

@yuhuan130 yuhuan130 commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Deprecate ray_remote_args_fn across the public Ray Data transformation APIs.

  • Emits a RayDeprecationWarning when ray_remote_args_fn is passed to
    Dataset.map, map_batches, flat_map, filter, or GroupedData.map_groups

  • Marks the argument for removal in Ray 2.64.

  • Renames _map_batches_without_batch_size_validation to the developer API
    map_batches_internal.

  • Routes internal Ray Data LLM stages through map_batches_internal so they
    don't trigger a user-facing deprecation warning.

  • Adds a warning to the documentation section that recommends creating placement groups
    through ray_remote_args_fn.


Follow-up to #64631

@yuhuan130
yuhuan130 requested review from a team as code owners July 23, 2026 14:17

@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 deprecates the ray_remote_args_fn parameter across several dataset transformation methods (such as map, map_batches, flat_map, filter, and map_groups), introducing a deprecation warning. It also renames the internal helper _map_batches_without_batch_size_validation to map_batches_internal under the @DeveloperAPI decorator and updates its usages. Relevant tests are updated to assert the deprecation warnings. One critical issue was identified in the new test file where ray is referenced but not imported, which will cause a NameError during test execution.

Comment thread doc/source/data/transforming-data.rst Resolved
Comment thread python/ray/data/dataset.py Resolved
@richardliaw richardliaw added the data Ray Data-related issues label Jul 23, 2026
Comment thread python/ray/data/tests/test_map.py Resolved
Comment thread python/ray/data/tests/test_map.py Resolved
Comment thread doc/source/data/transforming-data.rst Resolved
Comment thread doc/source/data/transforming-data.rst Resolved
Comment thread python/ray/data/dataset.py Resolved
@yuhuan130

Copy link
Copy Markdown
Contributor Author

@bveeramani Thanks for the review. I’ve addressed the test feedback in 68dd82a, I left the documentation and removal-date wording unchanged for now while those discussions are still being settled. Thank you.

@bveeramani
bveeramani self-requested a review August 2, 2026 04:08
@bveeramani bveeramani changed the title [Data] Deprecate ray_remote_args_fn [Data] Deprecate ray_remote_args_fn Aug 2, 2026
@bveeramani
bveeramani enabled auto-merge (squash) August 2, 2026 04:25
@github-actions github-actions Bot added the go add ONLY when ready to merge, run all tests label Aug 2, 2026
@github-actions
github-actions Bot disabled auto-merge August 3, 2026 01: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 9745a01. Configure here.

Comment thread python/ray/data/dataset.py Resolved

@dstrodtman dstrodtman 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.

docs lgtm

@bveeramani
bveeramani merged commit e1583e4 into ray-project:master Aug 3, 2026
5 of 6 checks passed
goutamvenkat-anyscale pushed a commit to goutamvenkat-anyscale/ray that referenced this pull request Aug 3, 2026
### Description

Deprecate `ray_remote_args_fn` across the public Ray Data transformation
APIs.

- Emits a `RayDeprecationWarning` when `ray_remote_args_fn` is passed to
`Dataset.map`, `map_batches`, `flat_map`, `filter`, or
`GroupedData.map_groups`

- Marks the argument for removal in Ray 2.64.
- Renames `_map_batches_without_batch_size_validation` to the developer
API
  `map_batches_internal`.
- Routes internal Ray Data LLM stages through `map_batches_internal` so
they
  don't trigger a user-facing deprecation warning.
- Adds a warning to the documentation section that recommends creating
placement groups
  through `ray_remote_args_fn`.
---

Follow-up to ray-project#64631

---------

Signed-off-by: Alex Chien <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
dstrodtman added a commit to dstrodtman/ray that referenced this pull request Aug 7, 2026
…asses

A method of an @publicapi class was pulled into the checked surface regardless
of its own annotation, so an @DeveloperAPI or @deprecated method was treated as
public API. Replaying the check over the last 200 merged commits touching
python/ray surfaced this as its only false positive: ray-project#64963 flagged
Dataset.map_batches_internal, an @DeveloperAPI method, with 15 parameters.

Skip methods carrying their own non-public annotation, while letting an explicit
@publicapi on the method win over both. This matches what has_publicapi_decorator
already documented but only enforced at class and module level.

Signed-off-by: Douglas Strodtman <[email protected]>
Artimislyy pushed a commit to Artimislyy/ray that referenced this pull request Aug 11, 2026
### Description

Deprecate `ray_remote_args_fn` across the public Ray Data transformation
APIs.

- Emits a `RayDeprecationWarning` when `ray_remote_args_fn` is passed to
`Dataset.map`, `map_batches`, `flat_map`, `filter`, or
`GroupedData.map_groups`

- Marks the argument for removal in Ray 2.64.
- Renames `_map_batches_without_batch_size_validation` to the developer
API
  `map_batches_internal`.
- Routes internal Ray Data LLM stages through `map_batches_internal` so
they
  don't trigger a user-facing deprecation warning.
- Adds a warning to the documentation section that recommends creating
placement groups
  through `ray_remote_args_fn`.
---

Follow-up to ray-project#64631

---------

Signed-off-by: Alex Chien <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
dstrodtman added a commit that referenced this pull request Aug 11, 2026
## Why

Ray's public API reference accretes undocumented parameters over time: a
new
`@PublicAPI` callable, or a new parameter on an existing one, can ship
without a
docstring `Args:` entry, and nothing fails. This adds a **static,
diff-scoped**
check that blocks *new* debt on the `@PublicAPI` surface while
grandfathering the
standing backlog.

### What pydoclint already covers, and the gap it leaves

pydoclint (pinned at `0.8.3` in `.pre-commit-config.yaml`) already runs
its
argument-completeness checks `DOC101`/`DOC103` repo-wide across
`python/ray`,
against an **empty** `ci/lint/pydoclint-baseline.txt`. So that class of
violation
is already fully enforced with zero grandfathering, and the tree is
essentially
clean: a repo-wide run under the exact pre-commit config flags exactly
**one**
callable, `_find_imported_submodules` in vendored
`python/ray/cloudpickle/cloudpickle.py`, which is private. The
per-module
cleanups (#63500, #63509,
#63518, #63541, #63571, #63632, #63633, #63634, #63639) are what got it
there.

The gap is `--skip-checking-short-docstrings`, which defaults to `True`
and is not
overridden. It makes pydoclint skip any callable whose docstring is
absent or is a
bare one-line summary with no sections. Those callables can gain
parameters
indefinitely without any check firing.

Flipping that one flag is not a viable fix. Repo-wide with
`--skip-checking-short-docstrings=False`, `DOC101`/`DOC103` fire on
**8,285**
callables across `python/ray` (public and private alike; 16,570
violations, since
each callable trips both codes) -- precisely the "baseline the size of
the
codebase" that the config comment on master already says the team
doesn't want,
and it has no `@PublicAPI` awareness to narrow it.

Measured on the `@PublicAPI` surface, the same unit for comparison: of
815 public
callables that take parameters, **230** have at least one undocumented
parameter,
totalling **505** undocumented parameters. So the public surface is
roughly 3% of
what a repo-wide flag flip would drag in.

**All 230 of them sit in pydoclint's blind spot** -- zero overlap with
what
`DOC101`/`DOC103` catch today. That falls out of the numbers above
without relying
on any modelling of pydoclint's "short docstring" rule: if any
`@PublicAPI`
callable had a section-bearing docstring missing a param, pydoclint
would already
report `DOC101` on it, and the only such callable in the tree is a
private
cloudpickle function. The two checks partition the problem rather than
duplicating
it.

This check therefore scopes exactly to the `@PublicAPI` surface with
**no baseline
file**: it parses the base-branch and working-tree versions of the
changed files
and diffs their undocumented-parameter sets, so it needs **no Ray build
or import
environment**.

## What it does

- Enumerates the `@PublicAPI` callables changed by the PR (module-level
`@PublicAPI` functions and methods of `@PublicAPI` classes). A method
that
carries its own `@DeveloperAPI` or `@Deprecated` is out of scope even on
a
  public class, since it isn't part of the rendered surface; an explicit
  `@PublicAPI` on the method wins over both.
- For each, computes the signature parameters missing from the docstring
`Args:`/`Arguments:` block (for `__init__`, also the class docstring,
matching
the default `autoclass_content="class"`), resolving docstring
inheritance so an
override with no own docstring isn't flagged when a base documents the
param.
- Fails only on parameters that are **newly** undocumented versus the
base
branch. Pre-existing gaps are grandfathered; the gate fires on new
public
callables, newly-added params, and doc entries removed from an existing
param.

**Scope and limits (intentional):** all signature params, not only
annotated
ones. Presence only -- a param counts as documented if its name appears
in
`Args:`; description prose is not inspected (empty-description detection
would
need `numpydoc.validate` and is out of scope). Static source analysis,
so it does
not confirm what the reference actually renders.

## Where it lives / rollout

Sits in the `ci/ray_ci/doc` guard family next to
`cmd_check_api_discrepancy.py`,
and runs in the **lint group** (static, no docbuild). It starts as a
`soft_fail: true` step -- **visible but non-blocking** -- so the
measured
false-positive rate above can be confirmed against live traffic before
the check
gates anything. Flipping it to a required check is a one-line removal of
`soft_fail`.

One caveat for reviewers on the warn phase: the pipeline passes
`--blocking` and
relies on `soft_fail` to absorb the exit code, so an environment failure
(an
unfetched base branch, a shallow clone deeper than `--depth=500`)
surfaces the
same way a finding does. Happy to drop `--blocking` from the pipeline
command
instead, so the script's own warn mode carries the phase and
infrastructure
errors stay distinguishable from real findings.

Because the check is AST-based, it matches only *directly* applied
`@PublicAPI`
decorators, which lines up with the direct-annotation policy established
in
#65196 and #65208.

## Testing

- `python -m pytest ci/ray_ci/doc/test_api_param_coverage.py` -- **28
passed**.
Covers new API, new param, grandfathered gap, removed doc entry,
non-public /
private skips, `@PublicAPI(...)` call form,
`__init__`-on-class-docstring,
`Args:` block termination on dedent, docstring-inheritance recovery, and
the
  `@DeveloperAPI`/`@Deprecated`-method scoping rule.
- End-to-end on the pydoclint blind spot, which is the case this check
exists
  for: adding an undocumented `strict` param to `RayError.from_bytes` (a
`@PublicAPI` method with no docstring) fired on exactly `strict`, while
pydoclint under the pre-commit config reported no violations on the same
file.
  `--blocking` exits 1; documenting the param cleared it.
- End-to-end on a case pydoclint *does* cover, to confirm agreement
rather than
contradiction: adding an undocumented `seed` param to `tune.loguniform`
fired
on exactly `seed` and correctly grandfathered the pre-existing gaps in
the same
  file. pydoclint independently blocks this one at pre-commit.
- `shellcheck ci/lint/lint.sh` clean; `.buildkite/lint.rayci.yml`
parses.
- Renaming `python/ray/exceptions.py` with no content change reported 22
violations across 11 callables before rename detection was added, and
reports
none after. A rename that also adds an undocumented param still fires on
  exactly that param.

### False-positive rate, measured against real history

Replayed the check over the **200** most recent merged commits touching
`python/ray/**/*.py`, each evaluated against its own parent. **Two**
fired (1%):

- #64963 flagged `Dataset.map_batches_internal` with 15 parameters. A
genuine
false positive: the method is `@DeveloperAPI`, but the check was pulling
in
every non-underscore method of an `@PublicAPI` class regardless of the
method's
own annotation. Fixed in this PR, with regression tests; the commit is
clean on
  the replay now.
- #64519 flagged `mode`, a newly added and undocumented parameter on
`Catalog.resolve` (`@PublicAPI(stability="alpha")`, one-line docstring).
A true
positive, and squarely the blind-spot class this check exists for. It
correctly
grandfathered the pre-existing `table` and `reader` gaps on the same
callable.

Post-fix that is **one firing across 200 commits, and it is a real
finding**.

### False-negative probe

Coverage was probed independently of the replay: for every `@PublicAPI`
callable
on the surface, inject a new undocumented keyword parameter and assert
the check
reports it. **815 callables probed, 0 misses** -- 585 that are currently
fully
documented, plus the 230 that already carry gaps, which verifies that
grandfathering an existing gap doesn't mask a newly added parameter.
Broken out
by shape: 176 module-level functions, 470 methods, 157 `__init__`, and
12 async
methods, with no misses in any group.

## Alternatives considered

- **Flip `--skip-checking-short-docstrings=False` repo-wide.** 8,285
callables, no
  `@PublicAPI` scoping. Rejected above.
- **A second pydoclint invocation with that flag plus its own
baseline.**
pre-commit is already diff-scoped, so this is closer than it looks, but
it
requires committing a baseline on the order of 8,000 entries and still
gates all
  of `python/ray` rather than the rendered public surface.

## Relationship to other open work

No open PR builds a parameter-coverage gate. #64779 changes how type
hints render
into the Parameters list, which is a separate deliverable and does not
gate new
undocumented params.

## AI assistance

This change was developed with AI assistance. The submitter has reviewed
every
changed line and run the tests above locally.

---------

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

Deprecate `ray_remote_args_fn` across the public Ray Data transformation
APIs.

- Emits a `RayDeprecationWarning` when `ray_remote_args_fn` is passed to
`Dataset.map`, `map_batches`, `flat_map`, `filter`, or
`GroupedData.map_groups`

- Marks the argument for removal in Ray 2.64.
- Renames `_map_batches_without_batch_size_validation` to the developer
API
  `map_batches_internal`.
- Routes internal Ray Data LLM stages through `map_batches_internal` so
they
  don't trigger a user-facing deprecation warning.
- Adds a warning to the documentation section that recommends creating
placement groups
  through `ray_remote_args_fn`.
---

Follow-up to ray-project#64631

---------

Signed-off-by: Alex Chien <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
Signed-off-by: 400Ping <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…ject#64788)

## Why

Ray's public API reference accretes undocumented parameters over time: a
new
`@PublicAPI` callable, or a new parameter on an existing one, can ship
without a
docstring `Args:` entry, and nothing fails. This adds a **static,
diff-scoped**
check that blocks *new* debt on the `@PublicAPI` surface while
grandfathering the
standing backlog.

### What pydoclint already covers, and the gap it leaves

pydoclint (pinned at `0.8.3` in `.pre-commit-config.yaml`) already runs
its
argument-completeness checks `DOC101`/`DOC103` repo-wide across
`python/ray`,
against an **empty** `ci/lint/pydoclint-baseline.txt`. So that class of
violation
is already fully enforced with zero grandfathering, and the tree is
essentially
clean: a repo-wide run under the exact pre-commit config flags exactly
**one**
callable, `_find_imported_submodules` in vendored
`python/ray/cloudpickle/cloudpickle.py`, which is private. The
per-module
cleanups (ray-project#63500, ray-project#63509,
ray-project#63518, ray-project#63541, ray-project#63571, ray-project#63632, ray-project#63633, ray-project#63634, ray-project#63639) are what got it
there.

The gap is `--skip-checking-short-docstrings`, which defaults to `True`
and is not
overridden. It makes pydoclint skip any callable whose docstring is
absent or is a
bare one-line summary with no sections. Those callables can gain
parameters
indefinitely without any check firing.

Flipping that one flag is not a viable fix. Repo-wide with
`--skip-checking-short-docstrings=False`, `DOC101`/`DOC103` fire on
**8,285**
callables across `python/ray` (public and private alike; 16,570
violations, since
each callable trips both codes) -- precisely the "baseline the size of
the
codebase" that the config comment on master already says the team
doesn't want,
and it has no `@PublicAPI` awareness to narrow it.

Measured on the `@PublicAPI` surface, the same unit for comparison: of
815 public
callables that take parameters, **230** have at least one undocumented
parameter,
totalling **505** undocumented parameters. So the public surface is
roughly 3% of
what a repo-wide flag flip would drag in.

**All 230 of them sit in pydoclint's blind spot** -- zero overlap with
what
`DOC101`/`DOC103` catch today. That falls out of the numbers above
without relying
on any modelling of pydoclint's "short docstring" rule: if any
`@PublicAPI`
callable had a section-bearing docstring missing a param, pydoclint
would already
report `DOC101` on it, and the only such callable in the tree is a
private
cloudpickle function. The two checks partition the problem rather than
duplicating
it.

This check therefore scopes exactly to the `@PublicAPI` surface with
**no baseline
file**: it parses the base-branch and working-tree versions of the
changed files
and diffs their undocumented-parameter sets, so it needs **no Ray build
or import
environment**.

## What it does

- Enumerates the `@PublicAPI` callables changed by the PR (module-level
`@PublicAPI` functions and methods of `@PublicAPI` classes). A method
that
carries its own `@DeveloperAPI` or `@Deprecated` is out of scope even on
a
  public class, since it isn't part of the rendered surface; an explicit
  `@PublicAPI` on the method wins over both.
- For each, computes the signature parameters missing from the docstring
`Args:`/`Arguments:` block (for `__init__`, also the class docstring,
matching
the default `autoclass_content="class"`), resolving docstring
inheritance so an
override with no own docstring isn't flagged when a base documents the
param.
- Fails only on parameters that are **newly** undocumented versus the
base
branch. Pre-existing gaps are grandfathered; the gate fires on new
public
callables, newly-added params, and doc entries removed from an existing
param.

**Scope and limits (intentional):** all signature params, not only
annotated
ones. Presence only -- a param counts as documented if its name appears
in
`Args:`; description prose is not inspected (empty-description detection
would
need `numpydoc.validate` and is out of scope). Static source analysis,
so it does
not confirm what the reference actually renders.

## Where it lives / rollout

Sits in the `ci/ray_ci/doc` guard family next to
`cmd_check_api_discrepancy.py`,
and runs in the **lint group** (static, no docbuild). It starts as a
`soft_fail: true` step -- **visible but non-blocking** -- so the
measured
false-positive rate above can be confirmed against live traffic before
the check
gates anything. Flipping it to a required check is a one-line removal of
`soft_fail`.

One caveat for reviewers on the warn phase: the pipeline passes
`--blocking` and
relies on `soft_fail` to absorb the exit code, so an environment failure
(an
unfetched base branch, a shallow clone deeper than `--depth=500`)
surfaces the
same way a finding does. Happy to drop `--blocking` from the pipeline
command
instead, so the script's own warn mode carries the phase and
infrastructure
errors stay distinguishable from real findings.

Because the check is AST-based, it matches only *directly* applied
`@PublicAPI`
decorators, which lines up with the direct-annotation policy established
in
ray-project#65196 and ray-project#65208.

## Testing

- `python -m pytest ci/ray_ci/doc/test_api_param_coverage.py` -- **28
passed**.
Covers new API, new param, grandfathered gap, removed doc entry,
non-public /
private skips, `@PublicAPI(...)` call form,
`__init__`-on-class-docstring,
`Args:` block termination on dedent, docstring-inheritance recovery, and
the
  `@DeveloperAPI`/`@Deprecated`-method scoping rule.
- End-to-end on the pydoclint blind spot, which is the case this check
exists
  for: adding an undocumented `strict` param to `RayError.from_bytes` (a
`@PublicAPI` method with no docstring) fired on exactly `strict`, while
pydoclint under the pre-commit config reported no violations on the same
file.
  `--blocking` exits 1; documenting the param cleared it.
- End-to-end on a case pydoclint *does* cover, to confirm agreement
rather than
contradiction: adding an undocumented `seed` param to `tune.loguniform`
fired
on exactly `seed` and correctly grandfathered the pre-existing gaps in
the same
  file. pydoclint independently blocks this one at pre-commit.
- `shellcheck ci/lint/lint.sh` clean; `.buildkite/lint.rayci.yml`
parses.
- Renaming `python/ray/exceptions.py` with no content change reported 22
violations across 11 callables before rename detection was added, and
reports
none after. A rename that also adds an undocumented param still fires on
  exactly that param.

### False-positive rate, measured against real history

Replayed the check over the **200** most recent merged commits touching
`python/ray/**/*.py`, each evaluated against its own parent. **Two**
fired (1%):

- ray-project#64963 flagged `Dataset.map_batches_internal` with 15 parameters. A
genuine
false positive: the method is `@DeveloperAPI`, but the check was pulling
in
every non-underscore method of an `@PublicAPI` class regardless of the
method's
own annotation. Fixed in this PR, with regression tests; the commit is
clean on
  the replay now.
- ray-project#64519 flagged `mode`, a newly added and undocumented parameter on
`Catalog.resolve` (`@PublicAPI(stability="alpha")`, one-line docstring).
A true
positive, and squarely the blind-spot class this check exists for. It
correctly
grandfathered the pre-existing `table` and `reader` gaps on the same
callable.

Post-fix that is **one firing across 200 commits, and it is a real
finding**.

### False-negative probe

Coverage was probed independently of the replay: for every `@PublicAPI`
callable
on the surface, inject a new undocumented keyword parameter and assert
the check
reports it. **815 callables probed, 0 misses** -- 585 that are currently
fully
documented, plus the 230 that already carry gaps, which verifies that
grandfathering an existing gap doesn't mask a newly added parameter.
Broken out
by shape: 176 module-level functions, 470 methods, 157 `__init__`, and
12 async
methods, with no misses in any group.

## Alternatives considered

- **Flip `--skip-checking-short-docstrings=False` repo-wide.** 8,285
callables, no
  `@PublicAPI` scoping. Rejected above.
- **A second pydoclint invocation with that flag plus its own
baseline.**
pre-commit is already diff-scoped, so this is closer than it looks, but
it
requires committing a baseline on the order of 8,000 entries and still
gates all
  of `python/ray` rather than the rendered public surface.

## Relationship to other open work

No open PR builds a parameter-coverage gate. ray-project#64779 changes how type
hints render
into the Parameters list, which is a separate deliverable and does not
gate new
undocumented params.

## AI assistance

This change was developed with AI assistance. The submitter has reviewed
every
changed line and run the tests above locally.

---------

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

Deprecate `ray_remote_args_fn` across the public Ray Data transformation
APIs.

- Emits a `RayDeprecationWarning` when `ray_remote_args_fn` is passed to
`Dataset.map`, `map_batches`, `flat_map`, `filter`, or
`GroupedData.map_groups`

- Marks the argument for removal in Ray 2.64.
- Renames `_map_batches_without_batch_size_validation` to the developer
API
  `map_batches_internal`.
- Routes internal Ray Data LLM stages through `map_batches_internal` so
they
  don't trigger a user-facing deprecation warning.
- Adds a warning to the documentation section that recommends creating
placement groups
  through `ray_remote_args_fn`.
---

Follow-up to ray-project#64631

---------

Signed-off-by: Alex Chien <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ject#64788)

## Why

Ray's public API reference accretes undocumented parameters over time: a
new
`@PublicAPI` callable, or a new parameter on an existing one, can ship
without a
docstring `Args:` entry, and nothing fails. This adds a **static,
diff-scoped**
check that blocks *new* debt on the `@PublicAPI` surface while
grandfathering the
standing backlog.

### What pydoclint already covers, and the gap it leaves

pydoclint (pinned at `0.8.3` in `.pre-commit-config.yaml`) already runs
its
argument-completeness checks `DOC101`/`DOC103` repo-wide across
`python/ray`,
against an **empty** `ci/lint/pydoclint-baseline.txt`. So that class of
violation
is already fully enforced with zero grandfathering, and the tree is
essentially
clean: a repo-wide run under the exact pre-commit config flags exactly
**one**
callable, `_find_imported_submodules` in vendored
`python/ray/cloudpickle/cloudpickle.py`, which is private. The
per-module
cleanups (ray-project#63500, ray-project#63509,
ray-project#63518, ray-project#63541, ray-project#63571, ray-project#63632, ray-project#63633, ray-project#63634, ray-project#63639) are what got it
there.

The gap is `--skip-checking-short-docstrings`, which defaults to `True`
and is not
overridden. It makes pydoclint skip any callable whose docstring is
absent or is a
bare one-line summary with no sections. Those callables can gain
parameters
indefinitely without any check firing.

Flipping that one flag is not a viable fix. Repo-wide with
`--skip-checking-short-docstrings=False`, `DOC101`/`DOC103` fire on
**8,285**
callables across `python/ray` (public and private alike; 16,570
violations, since
each callable trips both codes) -- precisely the "baseline the size of
the
codebase" that the config comment on master already says the team
doesn't want,
and it has no `@PublicAPI` awareness to narrow it.

Measured on the `@PublicAPI` surface, the same unit for comparison: of
815 public
callables that take parameters, **230** have at least one undocumented
parameter,
totalling **505** undocumented parameters. So the public surface is
roughly 3% of
what a repo-wide flag flip would drag in.

**All 230 of them sit in pydoclint's blind spot** -- zero overlap with
what
`DOC101`/`DOC103` catch today. That falls out of the numbers above
without relying
on any modelling of pydoclint's "short docstring" rule: if any
`@PublicAPI`
callable had a section-bearing docstring missing a param, pydoclint
would already
report `DOC101` on it, and the only such callable in the tree is a
private
cloudpickle function. The two checks partition the problem rather than
duplicating
it.

This check therefore scopes exactly to the `@PublicAPI` surface with
**no baseline
file**: it parses the base-branch and working-tree versions of the
changed files
and diffs their undocumented-parameter sets, so it needs **no Ray build
or import
environment**.

## What it does

- Enumerates the `@PublicAPI` callables changed by the PR (module-level
`@PublicAPI` functions and methods of `@PublicAPI` classes). A method
that
carries its own `@DeveloperAPI` or `@Deprecated` is out of scope even on
a
  public class, since it isn't part of the rendered surface; an explicit
  `@PublicAPI` on the method wins over both.
- For each, computes the signature parameters missing from the docstring
`Args:`/`Arguments:` block (for `__init__`, also the class docstring,
matching
the default `autoclass_content="class"`), resolving docstring
inheritance so an
override with no own docstring isn't flagged when a base documents the
param.
- Fails only on parameters that are **newly** undocumented versus the
base
branch. Pre-existing gaps are grandfathered; the gate fires on new
public
callables, newly-added params, and doc entries removed from an existing
param.

**Scope and limits (intentional):** all signature params, not only
annotated
ones. Presence only -- a param counts as documented if its name appears
in
`Args:`; description prose is not inspected (empty-description detection
would
need `numpydoc.validate` and is out of scope). Static source analysis,
so it does
not confirm what the reference actually renders.

## Where it lives / rollout

Sits in the `ci/ray_ci/doc` guard family next to
`cmd_check_api_discrepancy.py`,
and runs in the **lint group** (static, no docbuild). It starts as a
`soft_fail: true` step -- **visible but non-blocking** -- so the
measured
false-positive rate above can be confirmed against live traffic before
the check
gates anything. Flipping it to a required check is a one-line removal of
`soft_fail`.

One caveat for reviewers on the warn phase: the pipeline passes
`--blocking` and
relies on `soft_fail` to absorb the exit code, so an environment failure
(an
unfetched base branch, a shallow clone deeper than `--depth=500`)
surfaces the
same way a finding does. Happy to drop `--blocking` from the pipeline
command
instead, so the script's own warn mode carries the phase and
infrastructure
errors stay distinguishable from real findings.

Because the check is AST-based, it matches only *directly* applied
`@PublicAPI`
decorators, which lines up with the direct-annotation policy established
in
ray-project#65196 and ray-project#65208.

## Testing

- `python -m pytest ci/ray_ci/doc/test_api_param_coverage.py` -- **28
passed**.
Covers new API, new param, grandfathered gap, removed doc entry,
non-public /
private skips, `@PublicAPI(...)` call form,
`__init__`-on-class-docstring,
`Args:` block termination on dedent, docstring-inheritance recovery, and
the
  `@DeveloperAPI`/`@Deprecated`-method scoping rule.
- End-to-end on the pydoclint blind spot, which is the case this check
exists
  for: adding an undocumented `strict` param to `RayError.from_bytes` (a
`@PublicAPI` method with no docstring) fired on exactly `strict`, while
pydoclint under the pre-commit config reported no violations on the same
file.
  `--blocking` exits 1; documenting the param cleared it.
- End-to-end on a case pydoclint *does* cover, to confirm agreement
rather than
contradiction: adding an undocumented `seed` param to `tune.loguniform`
fired
on exactly `seed` and correctly grandfathered the pre-existing gaps in
the same
  file. pydoclint independently blocks this one at pre-commit.
- `shellcheck ci/lint/lint.sh` clean; `.buildkite/lint.rayci.yml`
parses.
- Renaming `python/ray/exceptions.py` with no content change reported 22
violations across 11 callables before rename detection was added, and
reports
none after. A rename that also adds an undocumented param still fires on
  exactly that param.

### False-positive rate, measured against real history

Replayed the check over the **200** most recent merged commits touching
`python/ray/**/*.py`, each evaluated against its own parent. **Two**
fired (1%):

- ray-project#64963 flagged `Dataset.map_batches_internal` with 15 parameters. A
genuine
false positive: the method is `@DeveloperAPI`, but the check was pulling
in
every non-underscore method of an `@PublicAPI` class regardless of the
method's
own annotation. Fixed in this PR, with regression tests; the commit is
clean on
  the replay now.
- ray-project#64519 flagged `mode`, a newly added and undocumented parameter on
`Catalog.resolve` (`@PublicAPI(stability="alpha")`, one-line docstring).
A true
positive, and squarely the blind-spot class this check exists for. It
correctly
grandfathered the pre-existing `table` and `reader` gaps on the same
callable.

Post-fix that is **one firing across 200 commits, and it is a real
finding**.

### False-negative probe

Coverage was probed independently of the replay: for every `@PublicAPI`
callable
on the surface, inject a new undocumented keyword parameter and assert
the check
reports it. **815 callables probed, 0 misses** -- 585 that are currently
fully
documented, plus the 230 that already carry gaps, which verifies that
grandfathering an existing gap doesn't mask a newly added parameter.
Broken out
by shape: 176 module-level functions, 470 methods, 157 `__init__`, and
12 async
methods, with no misses in any group.

## Alternatives considered

- **Flip `--skip-checking-short-docstrings=False` repo-wide.** 8,285
callables, no
  `@PublicAPI` scoping. Rejected above.
- **A second pydoclint invocation with that flag plus its own
baseline.**
pre-commit is already diff-scoped, so this is closer than it looks, but
it
requires committing a baseline on the order of 8,000 entries and still
gates all
  of `python/ray` rather than the rendered public surface.

## Relationship to other open work

No open PR builds a parameter-coverage gate. ray-project#64779 changes how type
hints render
into the Parameters list, which is a separate deliverable and does not
gate new
undocumented params.

## AI assistance

This change was developed with AI assistance. The submitter has reviewed
every
changed line and run the tests above locally.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants