Repository navigation
[data] Apply ruff D212 and D200 docstring auto-fixes - #67539
Merged
Merged
Conversation
Run ruff 0.8.4 `check --fix --unsafe-fixes --select D212,D200,D210` under the Google pydocstyle convention over python/ray/data/, excluding python/ray/data/llm.py and test code. The diff is formatter output only. @rtd-build Signed-off-by: Douglas Strodtman <[email protected]>
Contributor
There was a problem hiding this comment.
Code Review
This pull request standardizes docstring formatting across various files in the Ray Data module. Specifically, it updates multi-line docstrings to start on the same line as the opening triple quotes, improving consistency and adherence to standard Python docstring conventions. As there are no review comments, I have no feedback to provide.
AarryaSaraf
approved these changes
Oct 29, 2026
sai-miduthuri
added a commit
that referenced
this pull request
Oct 31, 2026
…able by pandas (#67576) (#67648) Cherry-pick of #67576 (master commit d6974fe) onto `releases/2.60.0`. ## Why Since #61733 (2.56), the batch a pandas UDF returns becomes an Arrow block built by `pa.Table.from_pandas`, which records each column's pandas dtype name in the block's metadata. pandas cannot parse the names of parametrized Arrow-backed dtypes. So when `enable_arrow_backed_pandas_conversion` is off, a UDF that returns an Arrow-backed list, struct or map column makes the next `to_pandas()` fail with `TypeError: data type 'list<item: int64>[pyarrow]' not understood`. `pd.read_parquet` fails the same way on files written from these blocks. A customer hit this upgrading from 2.55 to 2.59. #67576 rewrites each unparsable dtype name to `object` when `_from_pandas_safe` builds the block, and leaves names that parse, such as `Int64`, alone. ## Cherry-pick details Applied cleanly with `git cherry-pick -x`. The same 2 files, +114/-1, and the added and removed lines are identical to master's. `git patch-id` differs only because of one context line: master reformatted the `PandasRow` docstring in #67539, which isn't on this branch. No prerequisite commits are missing. After the pick, `_from_pandas_safe`, `_with_parsable_pandas_metadata` and `_parsable_pandas_metadata` are identical to master's. Not a duplicate: this branch doesn't contain #67576, and no PR against `releases/2.60.0` references it. #67649 picks the same commit onto `releases/2.59.1`. ## Testing | Command | Result | |---|---| | `pre-commit run --files python/ray/data/_internal/pandas_block.py python/ray/data/tests/test_pandas_block.py` | Passed | | `pytest python/ray/data/tests/test_pandas_block.py python/ray/data/tests/test_arrow_block.py` | 102 passed | | #67576's repro (pandas UDF returning an Arrow-backed list column, flag off), without and with the pick | Without: `TypeError: data type 'list<item: int64>[pyarrow]' not understood`. With: returns the lists as an `object` column | I ran these against the `releases/2.60.0` release wheel built at the branch head (85ad153), with this branch's `python/ray/data` copied over it, on Python 3.12 and pandas 2.3.3 (the version CI pins). Building Ray from source for `bazel test` wasn't practical on my machine. AI assistance was used to prepare this cherry-pick. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Marwan Sarieddine <[email protected]> Signed-off-by: Sai Miduthuri <[email protected]> Co-authored-by: Marwan Sarieddine <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]> Co-authored-by: Ayush Kumar <[email protected]>
sai-miduthuri
added a commit
that referenced
this pull request
Nov 13, 2026
…ble across blocks (#67579) (#67999) ## Description Cherry-pick of #67579 (master commit 1acc2c3) onto `releases/2.60.1`. **Middle of a 3-PR stack on `releases/2.60.1`:** #67995 (the #66521 pick), then this PR, then #68019 (the #67806 pick, which fixes this change on pyarrow 26). Merge the stack with `gh stack merge 68019`, which lands all three in order. Since #61733 (2.56), a batch that spans blocks whose tensor column is null in one of them fails with `ValueError: Trying to unify unsupported tensor type: null`. A pandas UDF that returns `None` for some rows and an ndarray for others is enough to hit it. It worked in 2.55. #67579 lets tensor arrays carry null rows, so these blocks merge, the column stays a tensor column, and missing rows read back as `None`. ## Related issues Related to #67579. Depends on #67995, the #66521 pick. ## Additional information ### Cherry-pick details Applied with `git cherry-pick -x`. 9 of the 10 files merged cleanly. `tensor_extensions/pandas.py` conflicted only on the `TensorArray.dtype` docstring. Master had reformatted it in #67539 (ruff D212/D200), which isn't on this branch. I kept this branch's docstring and added the PR's one new line, `first = _first_non_null(self._tensor)`. The added and removed lines are identical to the master commit. `git patch-id` differs only because of that docstring context line. Prerequisite: #66521. Without it, `test_arrow_concat_tensor_with_null_keeps_tensor_type[last_shape1]` and `test_unify_schemas_tensor_with_null_keeps_tensor_type[other_shape1]` fail on this branch. These are the cases where the tensor blocks have different shapes. I applied each master-only commit that touched `transform_pyarrow.py` or the tensor extensions between the branch cut and #67579 on top of this pick. #66521 alone fixes both tests. The other files differ from master only by master commits this change doesn't use. Not a duplicate: this branch doesn't contain #67579, and no PR against `releases/2.60.1` references it. ### Testing All of these ran with the #66521 pick applied underneath. | Command | Result | |---|---| | `pre-commit run --files <the 10 changed files>` | Passed | | `pytest test_arrow_block.py test_tensor_extension.py test_torch_tensor_utils.py unit/test_transform_pyarrow.py test_transform_pyarrow.py test_pandas_block.py` (under `python/ray/data/tests/`) | 526 passed, 3 skipped | | The same test files from this PR, against the code with only #66521 (no #67579) | 60 failed, 155 passed, and `test_tensor_extension.py` fails to collect, because it imports a helper this PR adds | | This pick directly on `releases/2.60.1`, without #66521 | The 2 tests above fail | | `test_arrow_block.py test_pandas_block.py test_tensor_extension.py` with the #67566 pick (#67994) also applied | 397 passed | `test_tensor_column_no_memory_leak` needs `scipy`, which my environment didn't have at first. The 526 passed is from a run with scipy installed. I ran these against the Ray 2.60.0 release wheel, with this branch's `python/ray/data` and `python/ray/tests` copied over it. The wheel was built from `releases/2.60.0` at b7f4259, and its Python sources match `releases/2.60.1` except for `_version.py`. The environment was Python 3.12 with pandas 2.3.3 and pyarrow 23.0.1, the versions CI pins, plus numpy 2.2.6 and torch 2.9.0+cpu. Building Ray from source for `bazel test` wasn't practical on my machine. AI assistance was used to prepare this cherry-pick. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Marwan Sarieddine <[email protected]> Signed-off-by: Elliot Barnwell <[email protected]> Signed-off-by: Sai Miduthuri <[email protected]> Co-authored-by: Marwan Sarieddine <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]> Co-authored-by: Elliot Barnwell <[email protected]>
sai-miduthuri
added a commit
that referenced
this pull request
Nov 13, 2026
…ble across blocks (#67579) (#68025) ## Description Cherry-pick of #67579 (master commit 1acc2c3) onto `releases/2.59.2`. **Middle of a 3-PR stack on `releases/2.59.2`:** #68024 (the #66521 pick), then this PR, then #68026 (the #67806 pick, which fixes this change on pyarrow 26). Merge the stack with `gh stack merge 68026`, which lands all three in order. Since #61733 (2.56), a batch that spans blocks whose tensor column is null in one of them fails with `ValueError: Trying to unify unsupported tensor type: null`. A pandas UDF that returns `None` for some rows and an ndarray for others is enough to hit it. It worked in 2.55. #67579 lets tensor arrays carry null rows, so these blocks merge, the column stays a tensor column, and missing rows read back as `None`. ## Related issues Related to #67579. Depends on #68024, the #66521 pick. The same pick for 2.60.1 is #67999. ## Additional information ### Cherry-pick details Applied with `git cherry-pick -x`. 5 of the 10 files merged cleanly. In the other 5, each conflict was master-only code that sits next to #67579's additions: | File | Master-only context | Kept from #67579 | |---|---|---| | `arrow_ops/transform_pyarrow.py` | the `chunked_tensor_take` imports (#64961) | the `create_ragged_ndarray` import | | `tensor_extensions/arrow.py` | `tensor_array_to_numpy` and `_to_dense_ndarray_or_none` (#66122) | `native_tensor_array_to_numpy` | | `tensor_extensions/pandas.py` | the `TensorArray.dtype` docstring reformat (#67539) | `first = _first_non_null(self._tensor)`, under this branch's docstring | | `tests/test_arrow_block.py` | earlier tests, such as #65539's | the 68 lines of new tests | | `tests/test_tensor_extension.py` | #66122's tests | the 280 lines of new tests | I resolved each conflict by applying only #67579's change relative to its parent, which was a pure insertion every time, and dropping the master-only lines. Across all 10 files, the added and removed lines are identical to the master commit. `git patch-id` differs only because of the context lines. Prerequisite: #66521. Without it, `test_arrow_concat_tensor_with_null_keeps_tensor_type[last_shape1]` and `test_unify_schemas_tensor_with_null_keeps_tensor_type[other_shape1]` fail on this branch, as they do on 2.60.1. Not a duplicate: this branch doesn't contain #67579, and no PR against `releases/2.59.2` references it. #67999 picks the same commit onto `releases/2.60.1`. ### Testing The six test files, under `python/ray/data/tests/`, are `test_arrow_block.py test_tensor_extension.py test_torch_tensor_utils.py unit/test_transform_pyarrow.py test_transform_pyarrow.py test_pandas_block.py`. | Command | Result | |---|---| | `pre-commit run --files <the 10 changed files>` | Passed | | `pytest <the six files>`, with the whole stack (#66521, this PR, #67806) | 478 passed | | `pytest --continue-on-collection-errors <the six files>`, with this PR's tests against the code with only #66521 | 60 failed, 203 passed, and `test_tensor_extension.py` fails to collect, because it imports a helper this PR adds | | `pytest <the six files>`, with this pick directly on `releases/2.59.2`, without #66521 | The 2 tests above fail, 465 passed | | `pytest test_arrow_block.py test_pandas_block.py test_tensor_extension.py`, with the stack and the #67566 pick (#68022) applied together | 365 passed | I ran these against the Ray 2.59.1 release wheel, with this branch's `python/ray/data` and `python/ray/tests` copied over it. The wheel was built from `releases/2.59.1` at 7bdaad7, and its Python sources match `releases/2.59.2` except for `_version.py`. The environment was Python 3.12 with pandas 2.3.3, pyarrow 23.0.1, numpy 2.1.3, scipy 1.17.1 and torch 2.9.0+cpu, the versions CI pins on this branch. Building Ray from source for `bazel test` wasn't practical on my machine. AI assistance was used to prepare this cherry-pick. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Marwan Sarieddine <[email protected]> Signed-off-by: Elliot Barnwell <[email protected]> Signed-off-by: Sai Miduthuri <[email protected]> Co-authored-by: Marwan Sarieddine <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]> Co-authored-by: Elliot Barnwell <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
Ray's code style guide says a docstring's first sentence starts on the opening quotes, and nothing enforces it yet. This PR clears ruff's auto-fixable docstring format rules from
python/ray/data/, exceptpython/ray/data/llm.py, which@ray-project/ray-llmowns and which gets its own PR, so a later config PR can turn them on without a baseline. Ruff has no baseline mechanism, so every library has to be clean first. Each library gets its own PR so that one code-owner team can review it.The diff is formatter output only. It moves summaries onto the opening quotes (
D212) and collapses one-line docstrings onto one line (D200). There are noD210violations in this tree. Nothing else changes, and no docstring text is reworded.To reproduce:
Ruff marks every
D200fix as unsafe, so--unsafe-fixesis needed to apply them. The scope guard below confirms the result changes only docstrings, and a second check confirms it doesn't change what any docstring renders as.Duplicate check
No open PR applies ruff
Dfixes to this code. I searched open PRs forD212,pydocstyle, anddocstring-only.Testing
python ci/ray_ci/doc/check_docstring_only.py --base "$(git merge-base upstream/master HEAD)":docstring-only guard: 60 file(s), docstrings only.inspect.cleandoc(__doc__), the text Sphinx autodoc renders, is identical before and after for every docstring in the changed files: 60 files, 0 docstrings changed.--fix: 0 violations remaining.AI assistance (Claude Code) was used to prepare this PR.
🤖 Generated with Claude Code