Skip to content

[doc][data] Fix Ray Data docstring link text and stale default descriptions - #66604

Merged
dstrodtman merged 9 commits into
masterfrom
doc-1524-data-style-docstrings
Oct 1, 2026
Merged

dstrodtman merged 9 commits into
masterfrom
doc-1524-data-style-docstrings

Conversation

@dstrodtman

@dstrodtman dstrodtman commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

This PR corrects Ray Data source text that disagrees with the renamed docs headings or with the code it describes. It touches comments and docstrings only.

Link text that repeats renamed headings

The Ray Data style-pass stack renamed several headings to sentence case and imperative form. Three docstrings in python/ray/data/ carry explicit :ref: titles that repeat the old heading text. This PR updates them to match:

  • read_api.py, read_sql: "Reading from SQL Databases" → "Read SQL databases"
  • read_api.py, from_huggingface: "Loading Hugging Face datasets" → "Load Hugging Face datasets"
  • dataset.py, repartition: "Advanced: Performance Tips and Tuning" → "Advanced: Performance tips and tuning", and "Changing the number of output files" → "Change the number of output files"
  • dataset.py, random_shuffle: "Optimizing shuffles" → "Optimize shuffles", and lowercases the start of an inline link that sits mid-sentence

The labels don't change, so every reference resolves before and after this PR. The only effect is that the rendered link text matches the target heading.

Source text that contradicts the code

  • context.py, max_hash_shuffle_aggregators: the comment said the default is twice the cluster CPU count. The code in hash_shuffle.py uses min(max(1, ceil(cluster CPUs)), max_hash_shuffle_aggregators or DEFAULT_MAX_HASH_SHUFFLE_AGGREGATORS), and has never doubled since [Data] Switched default shuffle strategy from sort-based to hash-based #55510 added the comment and the code together. The comment now says the CPU count, at least 1.
  • execution_options.py, ExecutionOptions.verbose_progress: [Data] Restructure stdout logging #43360 made the option on by default and added "On by default.", but left the older sentence that described the off state as the default. That sentence now describes the off state explicitly. This matches RAY_DATA_VERBOSE_PROGRESS defaulting to "1".

After this change the API reference agrees with the execution-configurations.md and joining-data.md pages.

The link-text edits used to sit in #66419, #66420, and #66423. They moved here so the docs-only PRs in the stack need only docs review.

Related issue number

None. Follow-up to the stack starting at #66418.

Checks

  • Not a duplicate. No other open PR touches these docstrings or comments.
  • pre-commit passed on all four files, including ruff, black, pydoclint, and the Ray docstyle check.
  • The diff changes comment and docstring text only. No code, defaults, or labels change.
  • AI assistance (Claude Code) was used to prepare this PR. I reviewed every changed line.

🤖 Generated with Claude Code

@dstrodtman
dstrodtman requested a review from a team as a code owner September 30, 2026 14:39

@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 updates several documentation references and links within the Ray Data module (dataset.py and read_api.py) to ensure consistent casing and terminology, such as changing title-cased references to sentence case and using active verbs. There are no review comments, and the changes look correct, so there is no additional feedback to provide.

dstrodtman added a commit that referenced this pull request Sep 30, 2026
## Description

Style and grammar pass on `doc/source/data/loading-data.md` against
Ray's [writing-style
guide](https://docs.ray.io/en/master/ray-contribute/writing-style.html).
Prose only, apart from one code fix: a missing comma in the Snowflake
example. No other code, testcode, code comments, or URLs changed.

Stacked on #66418. Review and merge that stack first. This branch
targets `doc-1524-data-style-core`. It's the second of several PRs that
apply the same pass to the top-level Ray Data pages.

### `loading-data.md`

- Rewords task headings as imperatives, such as "Read files" and "Load
data from ML libraries", and sentence-cases the H1 and tab titles. Each
reworded heading gets an explicit label named after its old slug, such
as `(reading-files-from-cloud-storage)=`, so existing URL fragments keep
resolving. Headings that already had a label, such as
`(loading_huggingface_datasets)=`, keep it with the new one stacked
beneath. The one exception is "Read from MongoDB": its existing
`(reading_mongodb)=` label already generates the `#reading-mongodb` id.
- Replaces the intro's bullet preview of the page's headings with one
sentence that keeps all three links, and adds a lead-in under "Load data
from other libraries".
- Uses "such as" for examples, second person, and active voice. Recasts
"lets" and "enables", and cuts filler such as "simply".
- Uses the vendor spellings "Hugging Face", "pandas", "Parquet", and
"Arrow".
- Puts quoted column names (`item`, `id`, `data`) in inline code.
- Changes "schema" to "scheme" for URI schemes, which matches the S3,
GCS, and Azure tabs.
- Fixes "underly" to "underlie" and adds lead-ins before code blocks.
- Describes the MongoDB `pipeline` as optional. The page said you need
one, but `read_mongo` declares it `Optional` with a `None` default and
reads the entire collection without one. It has been optional since at
least Ray 2.5. This is a factual correction.

### Other files

- Updates link text that quotes the old headings in
`batch-inference.rst`, `working-with-images.md`, and
`train/user-guides/data-loading-preprocessing.rst`. The matching
`read_api.py` docstring edits are in #66604.
- Fixes a link in `working-with-images.md` whose text says "Saving data"
but pointed at `loading_data`. It now points at `saving-data`.

## Questions for reviewers

Apart from the BigQuery and MongoDB corrections, this pass kept the
scope of every claim. These points need a Ray Data maintainer:

- **BigQuery:** "project ID, dataset, and query (if applicable)" now
reads "the project ID and either a dataset or a query". This is a
factual correction. The `read_bigquery` docstring says the two are
mutually exclusive, and `BigQueryDatasource` raises `ValueError` when
both are passed. Please confirm.
- **PostgreSQL:** "It's the most popular PostgreSQL database connector"
has no source.
- **Code the pass didn't touch:**
  - The GCS example uses `gcsfs.GCSFileSystem` without `import gcsfs`.
  - The MongoDB write example uses an undefined `MongoDatasource()`.
- The Azure example passes the filesystem to `read_parquet`
positionally.
  - The Zarr tab is a plain `python` block, not `testcode`.
- **Warnings and contractions:** Ray's guide says to avoid contractions
in warnings, but Vale's `Google.Contractions` rule errors on the
expanded forms, so the warnings keep their contractions. The guide and
the rule disagree.
- **Label placement:** `(reading_kafka)=` sits after the first paragraph
of the Kafka section rather than above the heading. I left it where it
is.

## Verification

- Follow-up commits apply fixes from automated review: the missing comma
in the Snowflake example, Hugging Face in the ML-libraries lead-in, and
`{func}` for `from_tf`.
- A meaning-diff review compared every before-and-after pair. It cleared
51 edits as cosmetic and found that 19 of the remaining 21 kept their
meaning. One drift, a permissive "you can" turned into an instruction,
is fixed in a follow-up commit. The BigQuery change is the intended
correction above.
- `vale` with Vale 3.12, run from the repo root: no warning- or
error-level alerts. Two suggestion-level alerts remain, both acronym
definitions ("HDFS" and "JVM") that the style guide requires.
- `codespell`: no hits.
- The pre-commit hooks passed.
- A structural check against the pre-edit file confirmed the code-fence
count, role targets, and URLs are unchanged. The only anchor changes are
the added old-slug labels. None were removed.
- Before adding each label, I grepped `doc/source` for the label name in
both hyphen and underscore forms. None collide.
- A grep for `{ref}` and Markdown links into this page found the link
text updated above and no other stale text.

## AI assistance

I made these edits with AI assistance (Claude Code).

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

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
dstrodtman added a commit that referenced this pull request Sep 30, 2026
## Description

Style and grammar pass on seven Ray Data operation guides against Ray's
[writing-style
guide](https://docs.ray.io/en/master/ray-contribute/writing-style.html):
`saving-data.md`, `inspecting-data.md`, `iterating-over-data.md`,
`aggregating-data.md`, `joining-data.md`, `mixing-data.md`, and
`shuffling-data.md`. Prose only, apart from one code fix: `import os` in
the partitioned-write example, which used `os` without importing it. No
other code, testcode, code comments, or URLs changed.

Stacked on #66419. Review and merge that stack first. This branch
targets `doc-1524-data-style-loading`. It's the third of several PRs
that apply the same pass to the top-level Ray Data pages.

### All seven pages

- Rewords task headings as imperatives, such as "Write data to files"
and "Configure joins", and conceptual headings as questions, such as
"How does per-block mixing work?". The gerund H1s stay, sentence-cased,
to match the nav titles and the loading page. Each reworded heading gets
an explicit label named after its old slug, such as
`(writing-data-to-files)=`, so existing URL fragments keep resolving.
Headings that already had a label keep it, with the new label stacked
beneath. None of the new labels collide with existing ones.
- Uses second person, active voice, present tense, and "such as" for
examples. Recasts "lets", "allows", and "enables".
- Removes dashes, parentheticals, semicolons, and filler such as
"essentially", "actually", and "note that".
- Fixes list structure and punctuation. Non-sequential numbered lists
become bullets or prose, and ordered lists use `1.`.
- Keeps contractions in warnings, because Vale's `Google.Contractions`
rule errors on the expanded forms.

### Page-specific changes

- `saving-data.md`: Folds the opening heading preview into prose and
adds a lead-in under the stacked H2. Fixes a Mars tab that said "convert
a Dataset from a Mars DataFrame" for `Dataset.to_mars()`.
- `inspecting-data.md`: Adds the missing `{meth}` role on
`Dataset.take_batch()`, which rendered its angle brackets literally.
Sentence-cases the `PyArrow` tab title.
- `iterating-over-data.md`: Adds the missing `{meth}` role on three
method list items (`iter_batches`, `iter_torch_batches`, and `to_tf`)
that had the same problem.
- `aggregating-data.md`: Replaces the marketing-style opening with a
statement of what the page covers.
- `joining-data.md`: Replaces three bold pseudo-headings over one-item
lists with one join-types list.
- `mixing-data.md`: Changes the optional repartitioning advice from a
`note` to a `tip`, and makes the Limitations labels parallel.
- `shuffling-data.md`: Fixes the "read function function" typo, adds alt
text to the push-based shuffle chart from the sentence that introduces
it, and changes "(New in 2.46)" into a sentence.

### Other files

- Updates link text that quotes the old headings in
`inspecting-data.md`, `iterating-over-data.md`, `shuffling-data.md`, and
`train/user-guides/data-loading-preprocessing.rst`. The matching
`dataset.py` docstring edits are in #66604.

## Questions for reviewers

These points need a Ray Data maintainer. Each one predates this PR
unless noted.

- **Push-based shuffle (`shuffling-data.md`):** the note says
`DataContext.use_push_based_shuffle` and `RAY_DATA_PUSH_BASED_SHUFFLE`
are deprecated in favor of `DataContext.shuffle_strategy`, but the same
section still tells you to set both, and its examples use them. Should
the section move to `ShuffleStrategy`?
- **Shuffle order (`shuffling-data.md`):** the intro says the methods
appear "in increasing order of resource consumption and runtime", but
the page's own benchmark shows `map_batches` shuffle, which comes
second, keeping more throughput than local buffer shuffle.
- **Hash shuffle naming (`shuffling-data.md`):** the key-based
repartitioning item says it triggers a "hash-shuffle" operation, while
the tip says it uses shuffle v2 by default and calls hash-shuffle the
previous implementation.
- **Aggregator count (`joining-data.md`):** "Setting
`max_hash_shuffle_aggregators >= num_partitions` allocates one partition
per aggregator." The page also says the count defaults to the smallest
of `num_partitions`, the CPU count, and the cap, so on a cluster with
fewer CPUs than partitions, raising the cap alone might not be enough.
- **Deprecated parameter (`joining-data.md`):** the lead-in "Tune join
performance ... with the following two parameters" includes
`partition_size_hint`, which the page says Ray Data ignores.
- **Random mixing (`mixing-data.md`):** the random-mixing section says
local batches are "each drawn from a single dataset", but an earlier
note says a local batch might contain data from more than one input
dataset.
- **Stats log (`inspecting-data.md`):** the page says Ray Data persists
execution statistics to `ray-data.log`. The streaming executor logs the
stats summary only when `DataContext.enable_auto_log_stats` is set, and
`DEFAULT_AUTO_LOG_STATS` is `False` in `context.py`. Should the sentence
name that condition?
- **Custom aggregators (`aggregating-data.md`):** the page says
`AggregateFnV2` has "three key methods that you implement", including
`finalize`. In `aggregate.py`, only `combine` and `aggregate_block` are
abstract. `finalize` has a default, and the class docstring calls
finalization optional.
- **Head node (`saving-data.md`):** "Your data must fit in memory on the
head node" for `to_pandas()` might mean the driver's node.
- **Removal date (`saving-data.md`):** "Support for this combination
ends after February 2027." Please confirm the date.
- **Code the pass didn't touch:**
- The GCS and Azure examples in `saving-data.md` call `gcsfs` and
`adlfs` without importing them.
- The NumPy example in `inspecting-data.md` prints `"Image shape"`
without the colon its output shows.
- `shuffling-data.md` has a `bash` block with `$` prompts and a plain
`python` block in the fallback tip.
- `aggregating-data.md` and `iterating-over-data.md` use `{class}` on
methods (`max`, `min`, `sum`, and `random_shuffle`).
- The benchmark link in the `aggregating-data.md` note ends its fragment
with a slash, `#performance-benchmarks/`.

## Verification

- A meaning-diff review compared every before-and-after pair. A
conservative filter cleared 22 blocks as cosmetic, and reviewers found
that 146 of the remaining 149 kept their meaning. The Mars tab change is
the intended correction noted above. Two drifts are fixed in a follow-up
commit: the mixing page's skewed-weights limitation had lost its signal
that the limitation is temporary, and the joins page had lost "previous"
for the hash-shuffle implementation.
- `vale` with Vale 3.12, run from the repo root: no warning- or
error-level alerts on the seven pages.
- `codespell`: no hits.
- The pre-commit hooks passed.
- A structural check against each pre-edit file confirmed the code-fence
count and URLs are unchanged. The only role-target changes are the four
added `{meth}` roles, and every target exists on `ray.data.Dataset`. The
only anchor changes are the added old-slug labels. None were removed.
- Before adding each label, I grepped `doc/source` for the label name in
hyphen and underscore forms. None collide.

## AI assistance

I made these edits with AI assistance (Claude Code).

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

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
dstrodtman and others added 6 commits September 30, 2026 11:18
Apply Ray's writing-style guide to the Ray Data performance tips, OOM,
execution configuration, concurrent execution, monitoring, and internals
pages: use imperative task headings and question headings for concepts,
with a label for each specific old heading slug so existing URL fragments
keep resolving; use second person, active voice, and "such as"; recast em
dashes, parentheticals, semicolons, and filler; add lead-ins under stacked
headings; and describe the OOM dashboard charts in their alt text.

Update link text on other pages and in a dataset.py docstring that quotes
the old headings.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
A meaning review found eight edits that changed what the text asserts,
mostly soft recommendations turned into instructions:

- performance-tips: restore "consider repartitioning" and two "you might
  want to" hedges on the resource-limit scenarios.
- how-to-avoid-ooms: keep the 1 GiB buffer host-dependent and hedged.
- concurrent-dataset-execution: describe DataConfig as the more convenient
  entry point again, not the only place to set selectors.
- monitoring-your-workload: restore the "might be more useful" hedge and
  the "advanced users" audience, and list execution states as examples,
  since DatasetState also has PENDING and UNKNOWN.
- internals: name all five subsections in the planning lead-in.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Fix the verbose_progress and max_errored_blocks defaults, the default Prometheus port (9090, as in the cluster metrics guide), and the custom-rule instructions, which now match get_logical_ruleset. Say hash-shuffling is available starting in Ray 2.46, drop "locality" from a heading whose section doesn't cover it, and describe multitenancy on a shared Ray cluster instead of an Anyscale workspace.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Renaming the heading to "Optimize reads" changed its generated anchor, so the
performance-tips.md#optimizing-reads link no longer resolved and failed the
docs build. Reference the explicit label, which doesn't change with the heading.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
…y Data perf pages

The style pass turned five suggestions into instructions: tuning block counts,
the ranked spilling strategy, limiting resource usage, trying
isolate_read_workers, and optimizing the iteration loop. Restore the original
strength, as the earlier meaning-drift fixes on this branch did for the others.

The logical read operator is Read and the fusion rule is FuseOperators. No
ReadOp class exists, and OperatorFusionRule was renamed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
The docstring link-text updates need Ray Data code-owner review. They
move to their own PR at the top of this stack so the docs-only pages
can land on docs review alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman force-pushed the doc-1524-data-style-perf branch from fd865ea to efdf2c8 Compare September 30, 2026 15:18
@dstrodtman
dstrodtman requested review from a team as code owners September 30, 2026 15:18
The Ray Data style-pass stack renamed several headings to sentence
case and imperative form. Update the explicit :ref: titles in the
read_api.py and dataset.py docstrings to match. The labels don't
change, so every reference resolves before and after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman force-pushed the doc-1524-data-style-docstrings branch from a7943a2 to 9900e89 Compare September 30, 2026 15:19
Base automatically changed from doc-1524-data-style-perf to master September 30, 2026 15:32
dstrodtman added a commit that referenced this pull request Sep 30, 2026
## Description

Style and grammar pass on six Ray Data performance and internals pages
against Ray's [writing-style
guide](https://docs.ray.io/en/master/ray-contribute/writing-style.html):
`performance-tips.md`, `how-to-avoid-ooms.md`,
`execution-configurations.md`, `concurrent-dataset-execution.md`,
`monitoring-your-workload.md`, and `internals.md`. Prose only: no code,
testcode, literalinclude blocks, code comments, log samples, or URLs
changed.

Stacked on #66422. Review and merge that stack first. This branch
targets `doc-1524-data-style-modalities`. It's the last of five PRs that
apply the same pass to the top-level Ray Data pages.

### All six pages

- Rewords task headings as imperatives, such as "Optimize reads" and
"Configure the progress bar", and conceptual headings as questions, such
as "How does Ray Data schedule tasks?". Each reworded heading keeps its
old URL fragment through an explicit label named after the old slug,
unless the heading already had a matching label.
- Doesn't keep old fragments whose slug is a generic word, such as
`#configuration`, `#blocks`, `#datasets`, and `#best-practices`. Sphinx
labels are global, so a label with a generic name would claim it for the
whole site and break the build of any later page that defines it. One
more old fragment, `internals#datasets-and-blocks`, can't be kept
because `key-concepts.md` already defines that label name. Nothing in
the repo links to any of these fragments.
- Uses second person, active voice, present tense, and "such as" for
examples. Recasts "lets", "allows", and "enables", and firms up soft
recommendations while keeping factual hedges.
- Removes em dashes, parentheticals, semicolons, first-person plural,
and filler.
- Adds one-sentence lead-ins under headings that went straight into a
subheading, fixes list lead-ins and punctuation, and uses `1.` for
ordered lists.

### Page-specific changes

- `performance-tips.md`: Adds a page opening and lead-ins under five
H2s.
- `how-to-avoid-ooms.md`: Rewrites the three dashboard chart alt texts
from the charts themselves. The node-count chart's alt text had been
copied from another chart.
- `execution-configurations.md`: Labels the real old fragments for the
two headings that contain a role. MyST builds those headings' slugs
without the role text.
- `concurrent-dataset-execution.md`: Recasts eight em dashes and
replaces "Ray Data Datasets" with "Datasets".
- `monitoring-your-workload.md`: Makes each metric table's cell
punctuation consistent and replaces slashes in prose.
- `internals.md`: Lowercases "Ray tasks" and "Ray actors", and keeps the
signal that shuffle v2 doesn't yet replace the range-partitioning
shuffle. Names the operator classes as the source does: `Read`, not
`ReadOp`, and `FuseOperators`, which replaced `OperatorFusionRule`.

### Other files

- Updates link text that quotes the old headings in `loading-data.md`,
`joining-data.md`, `shuffling-data.md`, and `batch-inference.rst`. The
matching `dataset.py` docstring edit is in #66604.

## Questions for reviewers

These points need a Ray Data maintainer. Each one predates this PR
unless noted.

- **Column pruning (`performance-tips.md`):** the prose says passing
columns to `read_parquet` is more efficient than calling
`select_columns`, but the example under it uses `select_columns`, and
Ray Data has projection-pushdown optimizer rules.
- **Output blocks (`performance-tips.md`):** a lead-in says Ray Data
selects the number of output blocks "according to the following
procedure", but the bullets after it don't describe a procedure.
- **Read operator (`internals.md`):** this page says the planner
translates the `Read` operator into `InputDataBuffer` plus
`TaskPoolMapOperator`. `key-concepts.md` says the same in one place and
says it becomes only a `TaskPoolMapOperator` in another.
- **Resource isolation (`how-to-avoid-ooms.md`):** "Resource isolation
... eliminates kernel OOMs and node deaths" is absolute, while the
tuning section says "you shouldn't see OOMs or node deaths". The page
also refers to "older versions" of Ray without a version.
- **`block_transform_time_s` (`monitoring-your-workload.md`):** the Task
metrics table says only map operators report `block_transform_time_s`,
but the Operator stats item says read, write, and map operators all
report it. The Output block build item also cites
`data_block_serialization_time_s`, which none of the page's metric
tables list.
- **`write_file_retry_on_errors` (`execution-configurations.md`):** the
page lists it among the most important options, but `context.py`
deprecates it in favor of `retried_io_errors` and warns when you set it.
- **Object store limit (`performance-tips.md`):** the page says Ray Data
limits object store use to 1/4 of the object store by default.
`resource_manager.py` uses 0.25 only when `OpResourceAllocator` is off,
and `RAY_DATA_OBJECT_STORE_MEMORY_LIMIT_FRACTION`, which defaults to
0.5, when it's on.
- **Sort sampling (`internals.md`):** the range-partitioning shuffle
section says Ray Data samples 10 rows per block. `sort_task_spec.py`
computes `num_reducers * 10 / len(blocks)` samples per block.
- **`random_shuffle` backend (`internals.md`):** the page says
`Dataset.random_shuffle` uses the range-partitioning shuffle, but
`random_shuffle.py` builds on `ShuffleTaskSpec`, not the
range-partitioning `SortTaskSpec`.
- **`RAY_DATA_TRACE_SCHEDULING` (`monitoring-your-workload.md`):**
nothing under `python/` references this environment variable, so the
setting may be stale.

## Verification

- A follow-up commit applies source-verified fixes from automated
review:
- `verbose_progress` is on by default (`RAY_DATA_VERBOSE_PROGRESS`
defaults to `1`), so the sentence now describes the off state as the off
state.
  - `max_errored_blocks` tolerates no blocks with errors by default.
  - The Prometheus URL uses port 9090, as in the cluster metrics guide.
- Custom rules go through `get_logical_ruleset` and
`get_physical_ruleset`.
- Hash-shuffling is available starting in Ray 2.46, where `HASH_SHUFFLE`
first appears.
- "Configure resources" drops "locality", which the section doesn't
cover.
- Multitenancy is on a shared Ray cluster instead of an Anyscale
workspace.
- A meaning-diff review compared every before-and-after pair. A
conservative filter cleared 43 blocks as cosmetic, and reviewers checked
the remaining blocks against the pre-edit text and the Ray source. Eight
drifted and are fixed in a follow-up commit. Most were soft
recommendations, such as "consider" and "you might want to", that had
become instructions. The others were a host-dependent buffer size stated
as a fixed minimum, `DataConfig` described as the only place to set
selectors, a dropped "advanced users" audience, and a planning lead-in
that left out one subsection. The same commit lists the monitoring
page's execution states as examples, because `DatasetState` also has
`PENDING` and `UNKNOWN`.
- A second scan of the full diff found five more soft recommendations
that had become instructions: tuning block counts, the ranked spilling
strategy, limiting resource usage, trying `isolate_read_workers`, and
optimizing the iteration loop. A follow-up commit restores them.
- `vale` with Vale 3.12, run from the repo root: no warning- or
error-level alerts on any `doc/source/data/*.md` page in the stack.
- `codespell`: no hits.
- The pre-commit hooks passed.
- A structural check against each pre-edit file confirmed the code-fence
count, role targets, and URLs are unchanged. The only anchor changes are
the added old-slug labels. None were removed.
- Before adding each label, I grepped `doc/source` for the label name in
hyphen and underscore forms.

## AI assistance

I made these edits with AI assistance (Claude Code).

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

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation data Ray Data-related issues labels Sep 30, 2026
…e text

The comment on DataContext.max_hash_shuffle_aggregators said the default
was twice the cluster CPU count. The code in hash_shuffle.py uses the
CPU count (at least 1), capped at DEFAULT_MAX_HASH_SHUFFLE_AGGREGATORS.

The ExecutionOptions.verbose_progress docstring said "On by default" but
kept an older sentence describing the off state as the default. Reword
that sentence to describe the off state.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman dstrodtman changed the title [doc][data] Match Ray Data docstring link text to renamed headings [doc][data] Fix Ray Data docstring link text and stale default descriptions Sep 30, 2026
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Sep 30, 2026
@dstrodtman
dstrodtman merged commit 95dbb92 into master Oct 1, 2026
7 checks passed
@dstrodtman
dstrodtman deleted the doc-1524-data-style-docstrings branch October 1, 2026 18:11
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
## Description

Style and grammar pass on `doc/source/data/loading-data.md` against
Ray's [writing-style
guide](https://docs.ray.io/en/master/ray-contribute/writing-style.html).
Prose only, apart from one code fix: a missing comma in the Snowflake
example. No other code, testcode, code comments, or URLs changed.

Stacked on ray-project#66418. Review and merge that stack first. This branch
targets `doc-1524-data-style-core`. It's the second of several PRs that
apply the same pass to the top-level Ray Data pages.

### `loading-data.md`

- Rewords task headings as imperatives, such as "Read files" and "Load
data from ML libraries", and sentence-cases the H1 and tab titles. Each
reworded heading gets an explicit label named after its old slug, such
as `(reading-files-from-cloud-storage)=`, so existing URL fragments keep
resolving. Headings that already had a label, such as
`(loading_huggingface_datasets)=`, keep it with the new one stacked
beneath. The one exception is "Read from MongoDB": its existing
`(reading_mongodb)=` label already generates the `#reading-mongodb` id.
- Replaces the intro's bullet preview of the page's headings with one
sentence that keeps all three links, and adds a lead-in under "Load data
from other libraries".
- Uses "such as" for examples, second person, and active voice. Recasts
"lets" and "enables", and cuts filler such as "simply".
- Uses the vendor spellings "Hugging Face", "pandas", "Parquet", and
"Arrow".
- Puts quoted column names (`item`, `id`, `data`) in inline code.
- Changes "schema" to "scheme" for URI schemes, which matches the S3,
GCS, and Azure tabs.
- Fixes "underly" to "underlie" and adds lead-ins before code blocks.
- Describes the MongoDB `pipeline` as optional. The page said you need
one, but `read_mongo` declares it `Optional` with a `None` default and
reads the entire collection without one. It has been optional since at
least Ray 2.5. This is a factual correction.

### Other files

- Updates link text that quotes the old headings in
`batch-inference.rst`, `working-with-images.md`, and
`train/user-guides/data-loading-preprocessing.rst`. The matching
`read_api.py` docstring edits are in ray-project#66604.
- Fixes a link in `working-with-images.md` whose text says "Saving data"
but pointed at `loading_data`. It now points at `saving-data`.

## Questions for reviewers

Apart from the BigQuery and MongoDB corrections, this pass kept the
scope of every claim. These points need a Ray Data maintainer:

- **BigQuery:** "project ID, dataset, and query (if applicable)" now
reads "the project ID and either a dataset or a query". This is a
factual correction. The `read_bigquery` docstring says the two are
mutually exclusive, and `BigQueryDatasource` raises `ValueError` when
both are passed. Please confirm.
- **PostgreSQL:** "It's the most popular PostgreSQL database connector"
has no source.
- **Code the pass didn't touch:**
  - The GCS example uses `gcsfs.GCSFileSystem` without `import gcsfs`.
  - The MongoDB write example uses an undefined `MongoDatasource()`.
- The Azure example passes the filesystem to `read_parquet`
positionally.
  - The Zarr tab is a plain `python` block, not `testcode`.
- **Warnings and contractions:** Ray's guide says to avoid contractions
in warnings, but Vale's `Google.Contractions` rule errors on the
expanded forms, so the warnings keep their contractions. The guide and
the rule disagree.
- **Label placement:** `(reading_kafka)=` sits after the first paragraph
of the Kafka section rather than above the heading. I left it where it
is.

## Verification

- Follow-up commits apply fixes from automated review: the missing comma
in the Snowflake example, Hugging Face in the ML-libraries lead-in, and
`{func}` for `from_tf`.
- A meaning-diff review compared every before-and-after pair. It cleared
51 edits as cosmetic and found that 19 of the remaining 21 kept their
meaning. One drift, a permissive "you can" turned into an instruction,
is fixed in a follow-up commit. The BigQuery change is the intended
correction above.
- `vale` with Vale 3.12, run from the repo root: no warning- or
error-level alerts. Two suggestion-level alerts remain, both acronym
definitions ("HDFS" and "JVM") that the style guide requires.
- `codespell`: no hits.
- The pre-commit hooks passed.
- A structural check against the pre-edit file confirmed the code-fence
count, role targets, and URLs are unchanged. The only anchor changes are
the added old-slug labels. None were removed.
- Before adding each label, I grepped `doc/source` for the label name in
both hyphen and underscore forms. None collide.
- A grep for `{ref}` and Markdown links into this page found the link
text updated above and no other stale text.

## AI assistance

I made these edits with AI assistance (Claude Code).

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

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
## Description

Style and grammar pass on seven Ray Data operation guides against Ray's
[writing-style
guide](https://docs.ray.io/en/master/ray-contribute/writing-style.html):
`saving-data.md`, `inspecting-data.md`, `iterating-over-data.md`,
`aggregating-data.md`, `joining-data.md`, `mixing-data.md`, and
`shuffling-data.md`. Prose only, apart from one code fix: `import os` in
the partitioned-write example, which used `os` without importing it. No
other code, testcode, code comments, or URLs changed.

Stacked on ray-project#66419. Review and merge that stack first. This branch
targets `doc-1524-data-style-loading`. It's the third of several PRs
that apply the same pass to the top-level Ray Data pages.

### All seven pages

- Rewords task headings as imperatives, such as "Write data to files"
and "Configure joins", and conceptual headings as questions, such as
"How does per-block mixing work?". The gerund H1s stay, sentence-cased,
to match the nav titles and the loading page. Each reworded heading gets
an explicit label named after its old slug, such as
`(writing-data-to-files)=`, so existing URL fragments keep resolving.
Headings that already had a label keep it, with the new label stacked
beneath. None of the new labels collide with existing ones.
- Uses second person, active voice, present tense, and "such as" for
examples. Recasts "lets", "allows", and "enables".
- Removes dashes, parentheticals, semicolons, and filler such as
"essentially", "actually", and "note that".
- Fixes list structure and punctuation. Non-sequential numbered lists
become bullets or prose, and ordered lists use `1.`.
- Keeps contractions in warnings, because Vale's `Google.Contractions`
rule errors on the expanded forms.

### Page-specific changes

- `saving-data.md`: Folds the opening heading preview into prose and
adds a lead-in under the stacked H2. Fixes a Mars tab that said "convert
a Dataset from a Mars DataFrame" for `Dataset.to_mars()`.
- `inspecting-data.md`: Adds the missing `{meth}` role on
`Dataset.take_batch()`, which rendered its angle brackets literally.
Sentence-cases the `PyArrow` tab title.
- `iterating-over-data.md`: Adds the missing `{meth}` role on three
method list items (`iter_batches`, `iter_torch_batches`, and `to_tf`)
that had the same problem.
- `aggregating-data.md`: Replaces the marketing-style opening with a
statement of what the page covers.
- `joining-data.md`: Replaces three bold pseudo-headings over one-item
lists with one join-types list.
- `mixing-data.md`: Changes the optional repartitioning advice from a
`note` to a `tip`, and makes the Limitations labels parallel.
- `shuffling-data.md`: Fixes the "read function function" typo, adds alt
text to the push-based shuffle chart from the sentence that introduces
it, and changes "(New in 2.46)" into a sentence.

### Other files

- Updates link text that quotes the old headings in
`inspecting-data.md`, `iterating-over-data.md`, `shuffling-data.md`, and
`train/user-guides/data-loading-preprocessing.rst`. The matching
`dataset.py` docstring edits are in ray-project#66604.

## Questions for reviewers

These points need a Ray Data maintainer. Each one predates this PR
unless noted.

- **Push-based shuffle (`shuffling-data.md`):** the note says
`DataContext.use_push_based_shuffle` and `RAY_DATA_PUSH_BASED_SHUFFLE`
are deprecated in favor of `DataContext.shuffle_strategy`, but the same
section still tells you to set both, and its examples use them. Should
the section move to `ShuffleStrategy`?
- **Shuffle order (`shuffling-data.md`):** the intro says the methods
appear "in increasing order of resource consumption and runtime", but
the page's own benchmark shows `map_batches` shuffle, which comes
second, keeping more throughput than local buffer shuffle.
- **Hash shuffle naming (`shuffling-data.md`):** the key-based
repartitioning item says it triggers a "hash-shuffle" operation, while
the tip says it uses shuffle v2 by default and calls hash-shuffle the
previous implementation.
- **Aggregator count (`joining-data.md`):** "Setting
`max_hash_shuffle_aggregators >= num_partitions` allocates one partition
per aggregator." The page also says the count defaults to the smallest
of `num_partitions`, the CPU count, and the cap, so on a cluster with
fewer CPUs than partitions, raising the cap alone might not be enough.
- **Deprecated parameter (`joining-data.md`):** the lead-in "Tune join
performance ... with the following two parameters" includes
`partition_size_hint`, which the page says Ray Data ignores.
- **Random mixing (`mixing-data.md`):** the random-mixing section says
local batches are "each drawn from a single dataset", but an earlier
note says a local batch might contain data from more than one input
dataset.
- **Stats log (`inspecting-data.md`):** the page says Ray Data persists
execution statistics to `ray-data.log`. The streaming executor logs the
stats summary only when `DataContext.enable_auto_log_stats` is set, and
`DEFAULT_AUTO_LOG_STATS` is `False` in `context.py`. Should the sentence
name that condition?
- **Custom aggregators (`aggregating-data.md`):** the page says
`AggregateFnV2` has "three key methods that you implement", including
`finalize`. In `aggregate.py`, only `combine` and `aggregate_block` are
abstract. `finalize` has a default, and the class docstring calls
finalization optional.
- **Head node (`saving-data.md`):** "Your data must fit in memory on the
head node" for `to_pandas()` might mean the driver's node.
- **Removal date (`saving-data.md`):** "Support for this combination
ends after February 2027." Please confirm the date.
- **Code the pass didn't touch:**
- The GCS and Azure examples in `saving-data.md` call `gcsfs` and
`adlfs` without importing them.
- The NumPy example in `inspecting-data.md` prints `"Image shape"`
without the colon its output shows.
- `shuffling-data.md` has a `bash` block with `$` prompts and a plain
`python` block in the fallback tip.
- `aggregating-data.md` and `iterating-over-data.md` use `{class}` on
methods (`max`, `min`, `sum`, and `random_shuffle`).
- The benchmark link in the `aggregating-data.md` note ends its fragment
with a slash, `#performance-benchmarks/`.

## Verification

- A meaning-diff review compared every before-and-after pair. A
conservative filter cleared 22 blocks as cosmetic, and reviewers found
that 146 of the remaining 149 kept their meaning. The Mars tab change is
the intended correction noted above. Two drifts are fixed in a follow-up
commit: the mixing page's skewed-weights limitation had lost its signal
that the limitation is temporary, and the joins page had lost "previous"
for the hash-shuffle implementation.
- `vale` with Vale 3.12, run from the repo root: no warning- or
error-level alerts on the seven pages.
- `codespell`: no hits.
- The pre-commit hooks passed.
- A structural check against each pre-edit file confirmed the code-fence
count and URLs are unchanged. The only role-target changes are the four
added `{meth}` roles, and every target exists on `ray.data.Dataset`. The
only anchor changes are the added old-slug labels. None were removed.
- Before adding each label, I grepped `doc/source` for the label name in
hyphen and underscore forms. None collide.

## AI assistance

I made these edits with AI assistance (Claude Code).

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

---------

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

## Description

Style and grammar pass on six Ray Data performance and internals pages
against Ray's [writing-style
guide](https://docs.ray.io/en/master/ray-contribute/writing-style.html):
`performance-tips.md`, `how-to-avoid-ooms.md`,
`execution-configurations.md`, `concurrent-dataset-execution.md`,
`monitoring-your-workload.md`, and `internals.md`. Prose only: no code,
testcode, literalinclude blocks, code comments, log samples, or URLs
changed.

Stacked on ray-project#66422. Review and merge that stack first. This branch
targets `doc-1524-data-style-modalities`. It's the last of five PRs that
apply the same pass to the top-level Ray Data pages.

### All six pages

- Rewords task headings as imperatives, such as "Optimize reads" and
"Configure the progress bar", and conceptual headings as questions, such
as "How does Ray Data schedule tasks?". Each reworded heading keeps its
old URL fragment through an explicit label named after the old slug,
unless the heading already had a matching label.
- Doesn't keep old fragments whose slug is a generic word, such as
`#configuration`, `#blocks`, `#datasets`, and `#best-practices`. Sphinx
labels are global, so a label with a generic name would claim it for the
whole site and break the build of any later page that defines it. One
more old fragment, `internals#datasets-and-blocks`, can't be kept
because `key-concepts.md` already defines that label name. Nothing in
the repo links to any of these fragments.
- Uses second person, active voice, present tense, and "such as" for
examples. Recasts "lets", "allows", and "enables", and firms up soft
recommendations while keeping factual hedges.
- Removes em dashes, parentheticals, semicolons, first-person plural,
and filler.
- Adds one-sentence lead-ins under headings that went straight into a
subheading, fixes list lead-ins and punctuation, and uses `1.` for
ordered lists.

### Page-specific changes

- `performance-tips.md`: Adds a page opening and lead-ins under five
H2s.
- `how-to-avoid-ooms.md`: Rewrites the three dashboard chart alt texts
from the charts themselves. The node-count chart's alt text had been
copied from another chart.
- `execution-configurations.md`: Labels the real old fragments for the
two headings that contain a role. MyST builds those headings' slugs
without the role text.
- `concurrent-dataset-execution.md`: Recasts eight em dashes and
replaces "Ray Data Datasets" with "Datasets".
- `monitoring-your-workload.md`: Makes each metric table's cell
punctuation consistent and replaces slashes in prose.
- `internals.md`: Lowercases "Ray tasks" and "Ray actors", and keeps the
signal that shuffle v2 doesn't yet replace the range-partitioning
shuffle. Names the operator classes as the source does: `Read`, not
`ReadOp`, and `FuseOperators`, which replaced `OperatorFusionRule`.

### Other files

- Updates link text that quotes the old headings in `loading-data.md`,
`joining-data.md`, `shuffling-data.md`, and `batch-inference.rst`. The
matching `dataset.py` docstring edit is in ray-project#66604.

## Questions for reviewers

These points need a Ray Data maintainer. Each one predates this PR
unless noted.

- **Column pruning (`performance-tips.md`):** the prose says passing
columns to `read_parquet` is more efficient than calling
`select_columns`, but the example under it uses `select_columns`, and
Ray Data has projection-pushdown optimizer rules.
- **Output blocks (`performance-tips.md`):** a lead-in says Ray Data
selects the number of output blocks "according to the following
procedure", but the bullets after it don't describe a procedure.
- **Read operator (`internals.md`):** this page says the planner
translates the `Read` operator into `InputDataBuffer` plus
`TaskPoolMapOperator`. `key-concepts.md` says the same in one place and
says it becomes only a `TaskPoolMapOperator` in another.
- **Resource isolation (`how-to-avoid-ooms.md`):** "Resource isolation
... eliminates kernel OOMs and node deaths" is absolute, while the
tuning section says "you shouldn't see OOMs or node deaths". The page
also refers to "older versions" of Ray without a version.
- **`block_transform_time_s` (`monitoring-your-workload.md`):** the Task
metrics table says only map operators report `block_transform_time_s`,
but the Operator stats item says read, write, and map operators all
report it. The Output block build item also cites
`data_block_serialization_time_s`, which none of the page's metric
tables list.
- **`write_file_retry_on_errors` (`execution-configurations.md`):** the
page lists it among the most important options, but `context.py`
deprecates it in favor of `retried_io_errors` and warns when you set it.
- **Object store limit (`performance-tips.md`):** the page says Ray Data
limits object store use to 1/4 of the object store by default.
`resource_manager.py` uses 0.25 only when `OpResourceAllocator` is off,
and `RAY_DATA_OBJECT_STORE_MEMORY_LIMIT_FRACTION`, which defaults to
0.5, when it's on.
- **Sort sampling (`internals.md`):** the range-partitioning shuffle
section says Ray Data samples 10 rows per block. `sort_task_spec.py`
computes `num_reducers * 10 / len(blocks)` samples per block.
- **`random_shuffle` backend (`internals.md`):** the page says
`Dataset.random_shuffle` uses the range-partitioning shuffle, but
`random_shuffle.py` builds on `ShuffleTaskSpec`, not the
range-partitioning `SortTaskSpec`.
- **`RAY_DATA_TRACE_SCHEDULING` (`monitoring-your-workload.md`):**
nothing under `python/` references this environment variable, so the
setting may be stale.

## Verification

- A follow-up commit applies source-verified fixes from automated
review:
- `verbose_progress` is on by default (`RAY_DATA_VERBOSE_PROGRESS`
defaults to `1`), so the sentence now describes the off state as the off
state.
  - `max_errored_blocks` tolerates no blocks with errors by default.
  - The Prometheus URL uses port 9090, as in the cluster metrics guide.
- Custom rules go through `get_logical_ruleset` and
`get_physical_ruleset`.
- Hash-shuffling is available starting in Ray 2.46, where `HASH_SHUFFLE`
first appears.
- "Configure resources" drops "locality", which the section doesn't
cover.
- Multitenancy is on a shared Ray cluster instead of an Anyscale
workspace.
- A meaning-diff review compared every before-and-after pair. A
conservative filter cleared 43 blocks as cosmetic, and reviewers checked
the remaining blocks against the pre-edit text and the Ray source. Eight
drifted and are fixed in a follow-up commit. Most were soft
recommendations, such as "consider" and "you might want to", that had
become instructions. The others were a host-dependent buffer size stated
as a fixed minimum, `DataConfig` described as the only place to set
selectors, a dropped "advanced users" audience, and a planning lead-in
that left out one subsection. The same commit lists the monitoring
page's execution states as examples, because `DatasetState` also has
`PENDING` and `UNKNOWN`.
- A second scan of the full diff found five more soft recommendations
that had become instructions: tuning block counts, the ranked spilling
strategy, limiting resource usage, trying `isolate_read_workers`, and
optimizing the iteration loop. A follow-up commit restores them.
- `vale` with Vale 3.12, run from the repo root: no warning- or
error-level alerts on any `doc/source/data/*.md` page in the stack.
- `codespell`: no hits.
- The pre-commit hooks passed.
- A structural check against each pre-edit file confirmed the code-fence
count, role targets, and URLs are unchanged. The only anchor changes are
the added old-slug labels. None were removed.
- Before adding each label, I grepped `doc/source` for the label name in
hyphen and underscore forms.

## AI assistance

I made these edits with AI assistance (Claude Code).

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

---------

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

## Why are these changes needed?

This PR corrects Ray Data source text that disagrees with the renamed
docs headings or with the code it describes. It touches comments and
docstrings only.

### Link text that repeats renamed headings

The Ray Data style-pass stack renamed several headings to sentence case
and imperative form. Three docstrings in `python/ray/data/` carry
explicit `:ref:` titles that repeat the old heading text. This PR
updates them to match:

- `read_api.py`, `read_sql`: "Reading from SQL Databases" → "Read SQL
databases"
- `read_api.py`, `from_huggingface`: "Loading Hugging Face datasets" →
"Load Hugging Face datasets"
- `dataset.py`, `repartition`: "Advanced: Performance Tips and Tuning" →
"Advanced: Performance tips and tuning", and "Changing the number of
output files" → "Change the number of output files"
- `dataset.py`, `random_shuffle`: "Optimizing shuffles" → "Optimize
shuffles", and lowercases the start of an inline link that sits
mid-sentence

The labels don't change, so every reference resolves before and after
this PR. The only effect is that the rendered link text matches the
target heading.

### Source text that contradicts the code

- `context.py`, `max_hash_shuffle_aggregators`: the comment said the
default is twice the cluster CPU count. The code in `hash_shuffle.py`
uses `min(max(1, ceil(cluster CPUs)), max_hash_shuffle_aggregators or
DEFAULT_MAX_HASH_SHUFFLE_AGGREGATORS)`, and has never doubled since
ray-project#55510 added the comment and the code together. The comment now says the
CPU count, at least 1.
- `execution_options.py`, `ExecutionOptions.verbose_progress`: ray-project#43360
made the option on by default and added "On by default.", but left the
older sentence that described the off state as the default. That
sentence now describes the off state explicitly. This matches
`RAY_DATA_VERBOSE_PROGRESS` defaulting to `"1"`.

After this change the API reference agrees with the
`execution-configurations.md` and `joining-data.md` pages.

The link-text edits used to sit in ray-project#66419, ray-project#66420, and ray-project#66423. They
moved here so the docs-only PRs in the stack need only docs review.

## Related issue number

None. Follow-up to the stack starting at ray-project#66418.

## Checks

- Not a duplicate. No other open PR touches these docstrings or
comments.
- `pre-commit` passed on all four files, including ruff, black,
pydoclint, and the Ray docstyle check.
- The diff changes comment and docstring text only. No code, defaults,
or labels change.
- AI assistance (Claude Code) was used to prepare this PR. I reviewed
every changed line.

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

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
dstrodtman added a commit that referenced this pull request Oct 14, 2026
…ocstring examples, piloted on Ray Data (#66814)

> [!NOTE]
> **Draft proposal.** This PR is for agreeing on the direction before
the label extends past Ray Data. It's rebased on `master` now that
#66806 has merged.

## Why are these changes needed?

A docstring edit in `python/ray/<lib>/` routes like a code change, so it
runs every test suite that library's tag selects, and the `go` premerge
runs all of them before merge. Converting docstring examples from
Sphinx-only `.. testcode::` to stock `>>>` doctests produces a steady
stream of these PRs. On master, 398 `testcode` blocks in 147 files
remain.

Measured on seven recent docstring-only PRs, one premerge build each:

| PR | Library | Premerge runner-hours |
|---|---|---|
| #65901 | core | 39.6 |
| #66745 | core | 43.7 |
| #66749 | rllib | 15.3 |
| #66747 | train | 10.6 |
| #66746 | data | 10.3 |
| #66748 | tune | 8.6 |
| #66604 | data | 8.2 |

Runner-hours are summed job durations from the Buildkite API, so
queueing doesn't count.

None of those suites can fail on a docstring-only change, except through
a test that asserts on `__doc__` text. What a docstring edit can break
is the example code in the docstrings it touched.

## What this PR does

It adds a `docstring-only` PR label, piloted on Ray Data only. Under the
label, a Data PR runs the `>>>` examples in the docstrings of only the
modules it changed, plus the API checks and lint, instead of every Data
test suite.

- **The guard.** `lint: validate docstring-only scope` runs whenever the
label is present, is tagged `always`, and can't be turned off.
`ci/ray_ci/doc/check_docstring_only.py` parses each changed file at the
merge-base and at `HEAD` with Python's `ast`, removes the docstring from
the module and from every class and function, and compares `ast.dump` of
the two trees. It fails on any difference, on any file that isn't `.py`,
on any added, deleted, renamed, copied, or type-changed file, and on any
parse error. Comments aren't in the AST, so comment edits pass. A string
later in a body and a `__doc__` assignment both count as code.
- **What the label skips.** The 10 Data test steps in `data.rayci.yml`
that run on premerge get `if: '!(build.pull_request.labels includes
"docstring-only")'`, the same pattern `docs-go` used. `pyrefly type
check` isn't gated.
- **What it runs instead.** A new `data: docstring examples` step, gated
on the label, runs `ci/ray_ci/doc/run_docstring_examples.sh`:
1. It lists the `.py` files the PR modified under `python/ray/data/`,
excluding `tests/` and `examples/`, and exits if there are none.
1. It builds the Data CI image with the PR's Ray, using `test_in_docker
--build-only`, the same Ray install every Data test step uses.
1. In that image, it runs `ci/ray_ci/doc/run_docstring_examples.py` on
only those files.

The runner imports each module and extracts the `>>>` examples from
every docstring in the file. It runs each docstring's examples in order,
in a copy of the module's globals, as an interactive session would. An
example that shows output must print it, so those examples are unit
tests rather than smoke tests. Matching follows Ray's doctest targets:
`...` matches any text (pytest's default ELLIPSIS flag), and per-example
directives apply. An example that shows no output only has to run
without raising, and one that shows a traceback must raise a matching
exception. The standard library's doctest module supplies the parser and
the output comparison, with no doctest runner, pytest collection, or
Bazel doctest target. Examples still written as `.. testcode::` aren't
run.
- **Docs.** `doc/source/ray-contribute/ci.md` gets a "Docstring-only
changes" section.

### Design choices for review

- **Changed files only.** The unit is the changed module, not the
library. A PR that edits `aggregate.py` runs only `aggregate.py`'s
examples.
- **Output is checked where it's shown.** A stale result in an example
fails the step, the same as in Ray's doctest targets. Examples that show
nothing are smoke tests.
- **Data only.** Extending the label means an `if:` on most library test
steps in every per-library `*.rayci.yml`, which each library team owns.
This draft shows the shape on one library first. `ml: data integration
tests` also carries the `data` tag but lives in `ml.rayci.yml`, so it
still runs under the label.
- **Some image builds still run.** The label gates test steps, not the
`wanda` image builds they depend on. rayci selects steps by tag and
pulls in every image a selected step depends on, and it doesn't evaluate
`if:`. `wanda` steps can't take an `if:` either. Under the label, a Data
docstring PR still emits 5 image jobs that feed only the gated steps:
`datamongobuild-py3.10`, `datatfdsbuild-py3.12`, `docgpubuild-py3.10`,
`docgpubuild-py3.12`, and `oss-ci-base_gpu-py3.12`. On premerge builds
[74154](https://buildkite.com/ray-project/premerge/builds/74154) and
[74459](https://buildkite.com/ray-project/premerge/builds/74459), those
5 jobs took 4.1 and 10.1 minutes. Each takes about 50 seconds as a cache
hit, and `docgpubuild-py3.10` took 401 seconds on a miss. That's small
next to the 6.9 runner-hours the gated steps took. Dropping them needs a
rayci change that evaluates label gates before it marks dependencies.
The other 20 image jobs in the build feed a step the label keeps, or
rayci selects them on their own.
- **Known residual risk.** A test that asserts on `__doc__` text, or on
line numbers a docstring edit shifts, isn't visible to the guard. The
postmerge build is the backstop.

## Related issue number

None. Duplicate check: I searched open PRs for `docstring-only` and
`docstring only label`, and found no PR that adds a label or guard for
docstring-only changes.

## Tests run

- `pytest ci/ray_ci/doc/test_check_docstring_only.py
ci/ray_ci/doc/test_run_docstring_examples.py`: 29 passed. The runner's
tests cover examples that use module globals, a raising example that
fails with its file, line, and docstring name, wrong output that fails
with a diff, matching output with ELLIPSIS and a directive, expected and
mismatched exceptions, `+SKIP` and `+SKIP_EXAMPLE`, and no names leaking
between docstrings.
- The guard against real branches: it passes the three open docstring
PRs, #66745 (2 files), #66746 (1 file), and #66812 (5 files). It fails
#66806's branch and names the two `.py` files with code changes and the
three Markdown files.
- The runner against a Ray nightly (`43b706d`) on real branches. On
#66812's five files, 7 docstrings ran and passed in 24 seconds. On
#66746's `aggregate.py`, 18 docstrings ran and passed in 12 seconds.
With output checking, on six `master` Data modules that already use
`>>>` (`dataset.py`, `expressions.py`, `iterator.py`, `datatype.py`, and
two preprocessors), 113 of 118 docstrings passed in 36 seconds. The 5
failures are packages missing from the local environment (`torch`,
`tensorflow`, `crc32c`), not output mismatches.
- `--list-changed` in a scratch clone whose only change is a docstring
edit to `python/ray/data/aggregate.py` lists exactly that file.
- Pipeline generation with `rayci` built at `.rayciversion` (0.48.0),
for that simulated PR, on the premerge and microcheck pipeline IDs. Both
generate, with selected tags `always data lint`. Evaluating the
generated `if:` conditions shows the following:
- **Without the label:** the Data test steps match the real premerge
build of #66746
([74459](https://buildkite.com/ray-project/premerge/builds/74459)).
- **With `docstring-only`:** the 10 gated steps drop out, and `data:
docstring examples` and `lint: validate docstring-only scope` are added.
The API checks, `pyrefly`, `test-rules`, and `ml: data integration
tests` still run.
- The image jobs the label leaves running: I reran the same simulation
with the 10 gated steps removed from the YAML, which is what a rayci
change that evaluates label gates before marking dependencies would
emit. The build goes from 25 image jobs to 20. The 5 removed are listed
under "Some image builds still run." If the two `continuous-build` Data
steps are also dropped, `datalbuild-py3.12` goes too, for 6.
- Estimated saving on build 74459: the 10 gated steps took 6.9 of its
10.3 runner-hours. The new step adds one Data image build and a run of
seconds per changed file.
- `pre-commit` passes on the changed files.

Not yet run: the label on a real Buildkite build, including the
`--build-only` and `docker run` part of the new step. Nothing in the
repo evaluates Buildkite `if:` conditions, so the first labeled Data
docstring PR is the confirming check.

**AI assistance.** This change was drafted with Claude Code. I reviewed
every line and ran the tests above.

🤖 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]>
dstrodtman added a commit that referenced this pull request Oct 15, 2026
#67080)

## What

Convert the 10 `.. testcode::` blocks in `python/ray/data/read_api.py`
to stock `>>>` doctests:

- `read_parquet`: the projection and filter pushdown example joins the
docstring's existing `>>>` session, and its `testoutput` becomes the
expected output, so the `show(2)` result is still checked.
- `read_sql`: the SQLite example, which now creates its database in a
temporary directory and checks one read with `ds.count()`. See below.
- `read_bigquery`, `read_snowflake`, `read_databricks_tables` (2
blocks), `read_delta_sharing_tables`, and `read_kafka` (2 blocks):
`:skipif: True` examples that need an external service or credentials.
Each docstring carries the docstring-level `# doctest: +SKIP_EXAMPLE`
flag from #66753 once. None of these five docstrings has another `>>>`
example for the flag to skip by accident.

## Why

This continues the convergence in #66746, #66812, and #67070, with the
same conversion rules: same code, same order, same docstring, blank
lines inside a block dropped, bare expressions with an incidental repr
bound to `_`, and each example under a plural `Examples:` header with no
blank line after it. `read_snowflake`'s singular `Example:` header
becomes `Examples:`.

For the label from #66814, this is a larger case than #67070. The runner
runs every docstring in a changed file, so it runs all 35 runnable
docstrings in `read_api.py`, not only the 10 converted blocks. It also
checks output on `read_parquet` and runs five `+SKIP_EXAMPLE`
docstrings.

### Design choices for review

- **`read_sql` creates its database in a temporary directory.** The
original wrote `example.db` to the working directory and removed it in a
hidden `.. testcode:: :hide:` block, because a second run in the same
directory fails on `CREATE TABLE movie` ("table movie already exists").
Stock doctest has no run-but-hide form. The example now opens
`os.path.join(db_dir.name, "example.db")` under a
`tempfile.TemporaryDirectory()` and ends with `db_dir.cleanup()`, so it
can be rerun by readers as well as in CI, with no test-harness change.
An in-memory SQLite database wouldn't work: `read_sql` calls
`connection_factory` inside each read task, in a worker process, so each
worker would open a new empty database. The same `TemporaryDirectory`
pattern is in #66812's `list_stats_summaries`.
- **`read_sql` now checks a read.** The example never consumed the
datasets it built, so it didn't show that a read works. It now calls
`ds.count()` on the all-movies query and expects `4`. With no
`shard_keys`, `read_sql` falls back to a single read task whose metadata
has no row count, so `count()` runs that task in a worker and opens the
database through `create_connection`. On a warm local cluster the count
takes about 1 second.
- **Two `connection.execute(...)` calls are bound to `_`.** As a
statement in `testcode` they printed nothing, but as `>>>` they'd echo a
`sqlite3.Cursor` repr with a memory address.

## Duplicate check

I searched open PRs for `read_api`, `read_sql`, `read_kafka`, and
`testcode doctest data`. #66604 touched `read_api.py` but is merged and
changed different text. The only related open PRs are my own #66746,
#66812, and #67070, which touch other files.

## Tests run

Locally against a Ray nightly (`43b706d`) on Python 3.12, using pytest
7.4.4 and the same flags as the `doctest` Bazel macro,
`--doctest-modules -c NO_PYTEST_CONFIG -p <Ray Data doctest plugin>`,
with both collectors installed. `master`'s `read_api.py` imports
`ray.data.checkpoint.generated_id`, which that nightly predates, so I
applied this PR's diff to the nightly's own `read_api.py` rather than
overlaying `master`'s copy.

| Run | Before | After |
|---|---|---|
| pytest, both collectors | 31 passed, 5 failed | 30 passed, 5 skipped,
5 failed |
| pytest, `-p no:sphinx` | n/a | 30 passed, 5 skipped, 5 failed |
| `read_parquet` and `read_sql` alone, each collector setup | 1 passed
each | 1 passed each |
| `read_sql` run twice in the same directory, `-W
error::ResourceWarning` | n/a | passed both times, about 4 seconds each,
no `example.db` left in the working directory |
| `ci/ray_ci/doc/check_docstring_only.py --base upstream/master` | n/a |
passes: 1 file, docstrings only |

The pass count drops by one because `pytest-sphinx` collected the
`read_parquet` and `read_sql` `testcode` blocks as two extra items.
They're now part of the stock doctest items, one per docstring, and
`read_sql` gains a stock item it didn't have. The five `:skipif: True`
blocks were dropped before collection and never reported. They now
report as skipped.

The same five docstrings fail before and after, all in docstrings this
PR doesn't touch, because of my local environment: `from_tf`
(`tensorflow_datasets`), `read_audio` (`soundfile`), `read_avro`
(`fastavro`), `read_videos` (`decord`), and `read_json`, whose
`ds.schema()` prints `string` where the docstring expects `object`
because of a newer local pandas. The `run_docstring_examples.py` runner
on the file reports 35 docstrings run, with the same five failures and
five skips. `pre-commit` passes on the changed file.

**AI assistance.** This change was drafted with Claude Code. I reviewed
every line and ran the tests above.

🤖 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]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues 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