Skip to content

[data] Add missing docstrings to Preprocessor and the built-in preprocessors - #67603

Merged
dstrodtman merged 2 commits into
masterfrom
doc-1920-data-preprocessor-docstrings
Oct 30, 2026
Merged

dstrodtman merged 2 commits into
masterfrom
doc-1920-data-preprocessor-docstrings

Conversation

@dstrodtman

@dstrodtman dstrodtman commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the missing docstrings on the public ray.data.preprocessor.Preprocessor and ray.data.preprocessors surface: 88 symbols in 13 files. Most are the configuration properties on each built-in preprocessor, such as columns, output_columns, and bins. Each property docstring restates the constructor's existing Args: entry. The get_input_columns and get_output_columns overrides, Preprocessor.fit_status, Chain.fit_status, Preprocessor.has_stats, and OneHotEncoder.safe_get now get docstrings with Returns: sections, written from what the code returns.

Before

These properties and methods had no docstring, so the API reference showed only their names and signatures.

After

They have docstrings. Overrides that now carry their own docstring, such as LabelEncoder.get_input_columns, appear in their class's method table, because the class.rst autosummary template lists only methods whose own __doc__ is set.

Behavior is unchanged. The diff touches only docstrings, which the guard below confirms.

Subsystems

API (preprocessors). Docstrings only.

For reviewers

The descriptions of what a method returns, such as fit_status, has_stats, safe_get, and the base get_input_columns and get_output_columns, are the parts worth a technical read. The property docstrings paraphrase each class's Args: section.

While writing these, I found that TorchVisionPreprocessor.preferred_batch_format is missing the @classmethod that the base method and the other overrides carry. That's a code change, so it's in #67602 instead of here, and the two PRs touch adjacent lines.

Duplicate check

No open PR documents these symbols. I searched open PRs for preprocessor docstring and preprocessors. #60533 changes OneHotEncoder and MultiHotEncoder code in encoder.py but doesn't touch these docstrings.

Testing

  • python ci/ray_ci/doc/check_docstring_only.py --base "$(git merge-base upstream/master HEAD)": docstring-only guard: 13 file(s), docstrings only.
  • The full pre-commit suite on the changed files, including ruff, black, pydoclint, and the docstyle hook: passed.
  • The commit carries an @rtd-build line, so the Read the Docs preview renders the new docstrings.

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

🤖 Generated with Claude Code

…cessors

Document the configuration properties, get_input_columns and
get_output_columns overrides, and the remaining undocumented Preprocessor
methods. Each property docstring restates the constructor's Args entry.
Docstring-only: no code changes.

@rtd-build

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman dstrodtman added data Ray Data-related issues go add ONLY when ready to merge, run all tests docstring-only Skip heavy library tests for Ray API docstring edits. labels Oct 30, 2026
@dstrodtman
dstrodtman requested a review from a team as a code owner October 30, 2026 14:05

@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 adds comprehensive docstrings to properties and methods across various preprocessor classes in Ray Data. A review comment suggests updating the docstring for the 'fit_status' method to document 'FitStatus.PARTIALLY_FITTED' as a possible return value.

Comment thread python/ray/data/preprocessor.py Resolved
Chain overrides fit_status and can return FitStatus.PARTIALLY_FITTED, but
it had no docstring, so it inherited the base docstring, which lists only
the three statuses the base implementation returns. Give Chain.fit_status
its own docstring, and point the base docstring at it.

@rtd-build

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman merged commit e6c0339 into master Oct 30, 2026
6 checks passed
@dstrodtman
dstrodtman deleted the doc-1920-data-preprocessor-docstrings branch October 30, 2026 20:23
dstrodtman added a commit that referenced this pull request Oct 30, 2026
…API (#67605)

## Summary

Adds the missing docstrings, `Args:` entries, and `Returns:` sections on
public Ray Data symbols in `aggregate`, `dataset`, `iterator`,
`catalog`, `datasource`, `datatype`, and the public classes under
`_internal`: the Databricks and LeRobot datasources and the object and
tensor extensions. Each describes existing behavior, written from the
code. It follows #67603, which covers the preprocessors.

## Before

These symbols had no docstring, or their docstring had no section for
some parameters or for the return value. `ApproximateQuantile` and
`ApproximateTopK` kept their whole docstring on `__init__`, and the
class reference page doesn't render that, so [their
pages](https://docs.ray.io/en/master/data/api/doc/ray.data.aggregate.ApproximateQuantile.html)
show no description.

## After

The symbols are documented. The `ApproximateQuantile` and
`ApproximateTopK` docstrings move, unchanged, from `__init__` to the
class, so their pages show the description, examples, and arguments, and
`__init__` drops out of their method tables.

Where a base class lacked the docstring an override would inherit, this
PR documents the base instead of each override: `Datasource.get_name`,
`Datasource.estimate_inmemory_data_size`, `AggregateFn.output_field`,
and `Catalog.resolve`.

Behavior is unchanged. The diff touches only docstrings, which the guard
below confirms.

## Subsystems

API, IO, shuffle and aggregation, block and data format. Docstrings
only.

## For reviewers

These docstrings state behavior that looks unintended, so they're the
ones worth a close read:

- `PythonObjectArray.to_numpy` ignores `dtype`.
- `ArrowPythonObjectArray.to_numpy` ignores `zero_copy_only` and
`writable`.
- `Dataset.__init__` now documents its arguments and keeps the note that
the constructor isn't part of the public API.

Three methods can't be documented without a signature change, so their
code fixes and docstrings are in #67602:
`ArrowPythonObjectScalar.as_py`, `ArrowTensorScalar.as_py`, and
`ArrowPythonObjectArray.from_objects`. The `ArrowTensorScalar` class
docstring sits directly above one of those signatures, so it's in #67602
too. #67602 also corrects the return annotation of `TensorArray.isna`,
which this PR documents as returning a boolean NumPy array.

## Duplicate check

No open PR documents these symbols. Open PRs #67600, #66927, #67238, and
#67237 change other parts of `dataset.py`, and none of them edit the
docstrings changed here.

## Testing

- `python ci/ray_ci/doc/check_docstring_only.py --base "$(git merge-base
upstream/master HEAD)"`: `docstring-only guard: 15 file(s), docstrings
only.`
- The full pre-commit suite on the changed files, including ruff, black,
pydoclint, and the docstyle hook: passed.
- The commit carries an `@rtd-build` line, so the Read the Docs preview
renders the changed docstrings.

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

🤖 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

data Ray Data-related issues docstring-only Skip heavy library tests for Ray API docstring edits. 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