Skip to content

[ci] Skip polars docstring examples by name and apply Data doctest settings in the examples runner - #67237

Merged
dstrodtman merged 7 commits into
masterfrom
doc-1863-docstring-runner-bundle
Nov 3, 2026
Merged

dstrodtman merged 7 commits into
masterfrom
doc-1863-docstring-runner-bundle

Conversation

@dstrodtman

@dstrodtman dstrodtman commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follow-ups to the docstring-only label (#66814, #67083) after its first real campaign PRs on Ray Data. They're bundled into one PR because they share files and all need ray-ci review. Stacked on #67204, which updates the contributor docs this PR edits.

  1. Skip polars examples by name instead of marking them render-only. Dataset.join needs polars, which the light docstringbuild image doesn't install, so [data] Convert Dataset transform docstring examples to stock doctests #67202 marked the docstring +SKIP_EXAMPLE. That also stopped it from running in //python/ray/data:doctest, whose image installs polars through test-requirements.txt. This PR adds polars to OMITTED_LIBRARIES and removes the flag. The examples step now reports SKIP Dataset.join (needs polars), and Data's target runs the three join examples.
    • Polars isn't added to the image. polars==1.40.0 plus polars-runtime-32==1.40.0 is a 57 MB x86_64 wheel and about 195 MB installed, larger than pyarrow at 136 MB, for one docstring. Every current extra is 21 MB or less.
    • lance, the same way. Dataset.write_lance needs lance, from the pylance distribution. It's about 138 MB installed on Linux aarch64, for one docstring, and Data's doctest image installs it through data-test-requirements.txt. This PR adds lance to OMITTED_LIBRARIES, so the examples step reports SKIP Dataset.write_lance (needs lance). [data] Convert the write_sql and write_lance docstring examples to stock doctests #67238, stacked on this PR, converts that docstring and write_sql's from testcode to >>>.
    • LightGBM and XGBoost, the same way. ray.tune.integration.lightgbm and .xgboost, and Ray Train's LightGBM and XGBoost modules, import these at module level. The image installs neither, so a docstring-only change to one of those modules failed the examples step at import, even though Tune's examples there are render-only (+SKIP_EXAMPLE) and Train's are still testcode. The ML images install both through python/requirements/ml/core-requirements.txt, which meets the omit rule in item 2. The step now reports SKIP python/ray/tune/integration/lightgbm.py (module needs lightgbm), and likewise for xgboost. [tune] Convert the LightGBM and XGBoost callback examples to stock doctests #67619, stacked on this PR, converts those two Tune examples.
  2. Write the inclusion rule into docstring-examples-requirements.txt. The header now states when to add a library to the image and when to omit it by name. Each entry names the APIs whose examples need it, so it can go once those stop needing it. Comment-only. raydepsets --check reports the locks unchanged.
  3. Apply Ray Data's doctest settings in the runner. doctest_pytest_plugin.py sets preserve_order and turns off print_on_execution_start for every Data docstring. The runner applied neither, so an order-dependent example could pass in its target and flake in the step. It now applies both to ray.data modules and restores them after each docstring.
  4. ml: data integration tests under the label. This PR originally added a negated if: gate to it. [ci] Gate the docstring-only and docs-example-test labels with rayci label rules #67341 merged the docstring-only keep-only rule in .buildkite/docs.labels.yaml, which drops this step with every other library test step, so the gate is removed and ml.rayci.yml is unchanged.
  5. Count the output a render-only docstring hides. +SKIP_EXAMPLE skips a whole docstring, so expected output inside it is never checked. The skip line now names how many such examples there are. Across python/ray at this commit, 26 docstrings carry the flag, and only Dataset.join had expected output, which item 1 makes runnable. So the count is a signal rather than a failure: a render-only example can legitimately show sample output, such as for an external service.
  6. check_docstring_only.py --base diffs from the merge base. It diffed against the ref literally. After master moved past the branch point, --base upstream/master flagged files the PR never touched. The CI path, which already used the merge base, is unchanged. This matches run_docstring_examples.py, and the ci.md instructions drop the manual git merge-base wrapper.
  7. Stale comments. The doc_example prose rule's comment in test.rules.txt said an unlabeled prose PR still builds the opt-in step's images. Since [ci] Gate the docstring-only and docs-example-test labels with rayci label rules #67341, the docs-example-test label rule drops the step before dependency marking, so the comment now says that. The doc: doctest comment in others.rayci.yml still called //doc:doctest the catch-all target, but [ci] Give every runnable doc page its own doctest target #67003 split it into per-page team:none targets. The docstring examples comment now names the omitted libraries. It also said Buildkite drops the step on an unlabeled PR that selects it, but Buildkite shows it as broken, and that the skipped Ray Data examples run in "postmerge", which now says the scheduled postmerge builds, since the build each merge starts doesn't run them.

Related issues

Related to #66814, #67083, #67202, and #67204. #67238 and #67619 are stacked on this PR.

Additional information

Not a duplicate. I searched open PRs for run_docstring_examples, check_docstring_only, docstring-only, OMITTED_LIBRARIES, and data integration tests. Only #67204, which this stacks on, touches these files, and it changes docs only.

Tests run

  • bazel test //ci/ray_ci/doc:test_run_docstring_examples //ci/ray_ci/doc:test_check_docstring_only: both pass. New cases cover:
    • The Dataset.join polars message.
    • The hidden-output count.
    • The Data settings, applied and restored, and left alone for other modules.
    • --base against a base that moved past the branch point.
    • missing_library for lightgbm and xgboost module-level imports. For that commit I ran the suite with pytest directly rather than through Bazel: 33 passed.
  • run_docstring_examples.py on dataset.py, aggregate.py, and read_api.py. I ran it in an aarch64 image built from docstring_examples_depset_py3.10.lock, without decord (no aarch64 wheel) and ray-haproxy, with the Ray nightly at 093faf5583e.
    • 114 docstrings ran, and Dataset.join skipped for polars.
    • The one failure is read_videos, which needs decord. The x86_64 CI image installs it.
    • With polars installed, Dataset.join passes, and 115 docstrings run.
    • With the Data settings, Starting execution of Dataset lines drop to zero, and all 18 aggregate.py docstrings pass.
  • run_docstring_examples.py on ray.tune.integration.lightgbm and .xgboost from [tune] Convert the LightGBM and XGBoost callback examples to stock doctests #67619, in a Python 3.12 virtualenv with ray[tune]==2.59.0 and neither library installed: both modules skipped by name, 0 failed. Before this change, both failed at import.
  • bazel run //ci/raydepsets:raydepsets -- build ci/raydepsets/configs/docs.depsets.yaml --check: lock files are up to date.
  • pre-commit run on the changed files: passes.
  • rayci v0.50.0 pipeline generation for a labeled Data docstring PR on this branch, as above.

This PR's own premerge runs the Data and ML suites, because it changes dataset.py. That run is also the check that Data's doctest image has polars.

AI assistance (Claude Code) was used for this PR.

🤖 Generated with Claude Code

@dstrodtman
dstrodtman requested a review from a team as a code owner October 21, 2026 12:59
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Oct 21, 2026
@dstrodtman
dstrodtman requested review from a team as code owners October 21, 2026 12:59

@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 enhances the docstring testing infrastructure and documentation. Key updates include modifying check_docstring_only.py to diff against the merge base of the specified base branch, adding polars to the omitted heavy libraries list, and introducing a library_settings context manager to apply Ray Data-specific doctest settings during execution. Additionally, skipped docstrings now report the number of unchecked expected outputs, and corresponding tests and documentation have been updated. There are no review comments, so I have no feedback to provide.

@ray-gardener ray-gardener Bot added docs An issue or change related to documentation data Ray Data-related issues devprod labels Oct 21, 2026
@dstrodtman
dstrodtman added this pull request to stack #67289 October 22, 2026 16:38
elliot-barn pushed a commit that referenced this pull request Oct 28, 2026
…label rules (#67341)

> [!IMPORTANT]
> Draft until rayci ships label rules
([rayci#510](ray-project/rayci#510),
[rayci#511](ray-project/rayci#511)) and this PR
bumps `.rayciversion` to that release. Don't merge it before then:
today's rayci ignores `*.labels.yaml`, so removing the per-step gates
would stop the `docstring-only` label from skipping Ray Data's suites.

## Why are these changes needed?

The `docstring-only` and `docs-example-test` labels gate steps with
Buildkite `if:` conditions, which Buildkite evaluates after rayci has
selected the steps and marked their dependencies. That causes two
problems:

- **Images build for steps that don't run.** An unlabeled prose PR
builds the 5 images only the opt-in step needs. An unlabeled Python PR
builds `docstringbuild` for `doc: docstring examples`.
- **`docstring-only` covers only Ray Data.** Each skipped step needs its
own negated `if:`. Extending the label means a gate on nearly every
premerge test step, and a new step that forgets one silently runs under
the label.

rayci#510 and #511 let PR labels adjust step selection before dependency
marking, through rules in `.buildkite/*.labels.yaml`. This PR adopts
them.

## What changes

- **Adds `.buildkite/docs.labels.yaml`** with the following rules:
- `docstring-only` keeps only steps tagged `always`, `lint`, `doc_api`,
or `docstring_examples`. That's the same set a labeled Data PR runs
today (`doc/source/ray-contribute/ci.md`): the docstring examples step,
the two API surface checks, lint, and the scope guard, which is tagged
`always`. It now applies to every library, not just Ray Data. Without
the label, it skips `doc: docstring examples`.
  - `docs-example-test` skips the opt-in step without the label.
- **Tags the two steps** in `others.rayci.yml`: `docstring_examples` on
`doc: docstring examples`, and `doc_example_optin` on `doc: docs example
tests (opt-in)`.
- **Removes the 10 negated `docstring-only` gates** from
`data.rayci.yml`.
- **Keeps the positive `if:` gates** on the examples step, the opt-in
step, and the scope guard. They're redundant now, but they show a reader
of the step why it's label-gated.

## Behavior change to review

Under `docstring-only`, examples that need torch or TensorFlow are
reported as skipped by the light examples image, and their library's
`doctest()` target is skipped with the rest of the suites. Today that's
true only for Ray Data. With this PR it's true for every library, so
those examples get no premerge coverage on a labeled PR. `ml: data
integration tests`, which #67237 gates with its own `if:`, is also
covered by the keep-only rule, so that gate becomes redundant.

## Duplicate check

No open PR adopts rayci label rules, which don't exist yet in a release.
Related open PRs: #67237 adds a `docstring-only` gate to `ml: data
integration tests`, and #67204 rewrites the `docstring-only` section of
`ci.md`. The `ci.md` update for this change (the label covering every
library) waits until #67204 lands, to avoid conflicting with it.

## Testing

I generated the premerge pipeline locally with a Linux build of rayci
#510 and #511 against this branch. Each row simulates a PR that changes
one file:

| Simulated PR | rayci v0.50.0 on master | This branch, unlabeled | This
branch, labeled |
|---|---|---|---|
| Doc prose (`doc/source/data/aggregating-data.md`) | 11 steps | 5
steps: the opt-in step and the 5 images only it needs drop | 11 steps
with `docs-example-test` |
| Ray Data docstring (`python/ray/data/dataset.py`) | 51 steps | 49
steps: `doc: docstring examples` and `docstringbuild` drop | 19 steps
with `docstring-only` |
| Core docstring (`python/ray/actor.py`) | 165 steps | 163 steps: the
same 2 drop | 19 steps with `docstring-only` |

The 19 labeled steps are test-rules, the lint steps, the scope guard,
both API surface checks, `doc: docstring examples`, and their images.
Apart from the two dropped steps, unlabeled pipelines are identical to
v0.50.0 on master. `pre-commit run` on the changed files passes. Once a
rayci release exists, the `.rayciversion` bump goes here and premerge
runs with and without each label.

This PR was prepared with AI assistance (Claude Code). It stays in draft
until a human review of every changed line and a premerge run on the
release.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
@dstrodtman dstrodtman changed the title [ci] Skip polars docstring examples by name, apply Data doctest settings in the examples runner, and gate ml: data integration tests [ci] Skip polars docstring examples by name and apply Data doctest settings in the examples runner Oct 28, 2026
@cursor

cursor Bot commented Oct 28, 2026

Copy link
Copy Markdown

This PR is too large for Bugbot to review. It changes 39,387 lines and 4,058,458 characters. Split the change into smaller pull requests to get a review.

@dstrodtman
dstrodtman force-pushed the doc-1863-docstring-runner-bundle branch from b28fb61 to 79554aa Compare October 28, 2026 20:52
Base automatically changed from djs-261020-ci-docs-refresh to master October 29, 2026 16:47
@dstrodtman
dstrodtman force-pushed the doc-1863-docstring-runner-bundle branch from 79554aa to cf820b1 Compare October 29, 2026 16:47
dstrodtman added a commit that referenced this pull request Oct 29, 2026
…blocks (#67432)

## Description

Converts the last `>>>` doctest examples on documentation pages, so
`>>>` examples remain only in docstrings and on the two pages that teach
the docstring format. #67429 changes the contributor guidance to match.
This PR is independent of that stack and targets `master`.

Before this PR, seven pages under `doc/source/` had `>>>` prompts. Two
of them teach the docstring format and stay as they are:
`ray-contribute/writing-code-snippets.md` and
`ray-contribute/getting-involved.md`. This PR converts the other five:

| Page | Before | After | Test coverage |
|---|---|---|---|
| `data/working-with-tensors.md` | Three `{doctest}` blocks |
`{testcode}` and `{testoutput}` blocks | Unchanged. The `dtype` and
shape checks still run. The two per-image shapes the doctest skipped are
now a `+MOCK` sample. |
| `ray-references/glossary.md` | One `{doctest}` block with `+SKIP` on
every line | `{testcode}` and `{testoutput}` | Gained. The block used to
run nothing and now runs. The expected output is unchanged, because Ray
produces it exactly. |
| `serve/advanced-guides/multi-app-container.md` | `>>>` prompts in a
`python` fence, with every request skipped | Plain `python` and `text`
blocks | None before or after. The requests need the containerized Serve
apps running. The doctest only ran `import requests` and two string
assignments. |
| `core/tasks/nested-tasks.md` | REPL transcript in a `bash` block |
Plain `python` and `text` blocks | None before or after. The page's
`doc_code/` script is tested. |
| `serve/production-guide/fault-tolerance.md` | Interactive `$ python` /
`>>>` transcripts | Plain `python` blocks, with `text` blocks for output
| None before or after. These steps kill actors on a live cluster. |

### Test wiring

- `doc/BUILD.bazel`:
- Removes the Serve `doctest_each` call. Its only file was
`multi-app-container.md`, which no longer has a runnable example, so the
target would pass without testing anything.
- Drops the comment explaining why `nested-tasks.md` isn't listed, since
the page no longer has anything runnable to explain.
- The glossary and tensors entries stay, because both pages still have
runnable examples.
- `doc/test_prose_doctest_targets.py`: removes `nested-tasks.md` and
`fault-tolerance.md` from `UNTESTED`. Neither page has a runnable
example now. The two docstring-teaching pages stay exempt.

No `.buildkite/test.rules.txt` change. All prose routes to `doc_example`
whether or not a doctest target names the page, and the existing routing
cases for these pages still hold.

This PR edits `doc/BUILD.bazel`, so premerge runs every library's docs
example step. The glossary target is tagged `team:none`, which runs only
post-merge or with `docs-example-test`, so this PR carries that label
too.

## Related issues

Companion to #67429, which reserves `>>>` doctest-style examples for
docstrings in the contributor guide.

## Additional information

### Duplicate check

I searched open PRs for each converted page and for `doctest` in titles.
#66705 edits `fault-tolerance.md` around line 53, far from these hunks.
Draft #66851 appends a line to `nested-tasks.md` after these hunks.
Neither converts these examples. The docstring conversion PRs (#67238,
#66745, #67237) touch `python/`, not pages.

### Testing

I reproduced the CI doctest runner locally: Ray 2.59.0, Python 3.11,
`pytest==7.4.4`, `ray-project/pytest-sphinx@c1ab2b33`, the Ray Data
`doctest_pytest_plugin.py`, and the macro's `--doctest-modules
--doctest-glob='*.md' -c NO_PYTEST_CONFIG` arguments.

- `working-with-tensors.md`: passes before (2 items: the doctest blocks
and the testcode blocks) and after (1 item). A copy with a wrong
expected shape fails with `Expected (32, 28, 99) / Got (32, 28, 28)`, so
the new assertions are live.
- `glossary.md`: before, 1 skipped. After, 1 passed. A copy with a wrong
expected value fails.
- `python doc/test_prose_doctest_targets.py`: "73 listed pages; every
runnable page is accounted for."
- `pre-commit run --files` on the changed files passes, including
buildifier and buildifier-lint.
- `vale` on each changed page: no new alerts compared with `master`.
- After this PR, `git grep -l '^\s*>>> '` over `doc/source/*.md` and
`*.rst` returns only the two pages that teach the docstring format.
- The Read the Docs preview covers rendering.

This PR was prepared with AI assistance (Claude Code). 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 <[email protected]>
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]>
dstrodtman and others added 7 commits November 2, 2026 15:59
… docstring examples runner

- Add polars to OMITTED_LIBRARIES, so the docstring examples step skips
  Dataset.join by name, and drop +SKIP_EXAMPLE from that docstring so
  its examples run in Ray Data's doctest target, whose image installs
  polars through test-requirements.txt.
- Apply the Ray Data doctest plugin's DataContext settings to ray.data
  modules in the runner, so an order-dependent example behaves as it
  does in its target.
- Count the examples with expected output that a +SKIP_EXAMPLE docstring
  leaves unchecked in its skip line.
- check_docstring_only.py --base now diffs from the merge base, matching
  the CI path and run_docstring_examples.py.
- Skip ml: data integration tests under the docstring-only label, as the
  Data steps sharing its data tag already are.
- Write the inclusion rule for the examples image's libraries into
  docstring-examples-requirements.txt, and name each library's consumers.
- Refresh the stale comments in others.rayci.yml and the guard preview
  in ci.md.

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

Dataset.write_lance needs lance, from the pylance distribution. It's
about 138 MB installed, for one docstring, and Ray Data's own doctest
image installs it through data-test-requirements.txt. Adding it to
OMITTED_LIBRARIES makes the examples step report the docstring as
skipped by name, the way it does for polars, while Data's doctest
target runs it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
A leave-one-out run of the docstring examples, one library uninstalled
at a time over every module a CPU doctest() target covers, found the
consumers the comments missed. pillow serves eight docstrings, not two;
datasketches also serves Dataset.summary; and pyiceberg's only consumer
is the internal expression visitor, since read_iceberg and write_iceberg
skip their Iceberg calls. No example that runs in the image needs
crc32c, because write_tfrecords also needs TensorFlow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
The previous commit said no example that runs in the image needs crc32c.
It does: the TFRecord datasink checks for crc32c before
Dataset.write_tfrecords's example reaches TensorFlow, so without crc32c
the example fails with ModuleNotFoundError instead of skipping for
TensorFlow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
The docstring-only keep-only rule in .buildkite/docs.labels.yaml (#67341) already drops this step, so the per-step if: is redundant.

Signed-off-by: Douglas Strodtman <[email protected]>
Since #67341, the docs-example-test label rule drops the opt-in step before dependency marking, so unlabeled prose PRs no longer build its images.

Signed-off-by: Douglas Strodtman <[email protected]>
…tring examples runner

ray.tune.integration.lightgbm and .xgboost, and the Train LightGBM and XGBoost modules, import these libraries at module level. The docstring examples image installs neither, so a docstring-only change to one of those modules failed the step at import, even though Tune's examples are render-only. Omitting them reports the modules as skipped by name instead. The ML images install both through core-requirements.txt, so the omit policy in docstring-examples-requirements.txt allows it.

Signed-off-by: Douglas Strodtman <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dstrodtman
dstrodtman force-pushed the doc-1863-docstring-runner-bundle branch from 13290c4 to c98bcaf Compare November 2, 2026 21:00
@dstrodtman
dstrodtman merged commit baae422 into master Nov 3, 2026
6 checks passed
@dstrodtman
dstrodtman deleted the doc-1863-docstring-runner-bundle branch November 3, 2026 11:49
dstrodtman added a commit that referenced this pull request Nov 3, 2026
…ock doctests (#67238)

## Description

Converts the last three `.. testcode::` blocks in
`python/ray/data/dataset.py` to stock `>>>` doctests, in
`Dataset.write_sql` and `Dataset.write_lance`. After this, `dataset.py`
has no `testcode` left. The change touches only docstrings.

**`write_sql` follows `read_sql`'s pattern.** The example created
`example.db` in the working directory, and a hidden `:hide:` testcode
block deleted it afterward. Stock doctests have no hidden-cleanup
equivalent, so the example now creates the database in a
`tempfile.TemporaryDirectory()` and calls `cleanup()` at the end, the
way `ray.data.read_sql`'s example does.

**`write_lance` was malformed.** Its `.. testcode::` directive had no
blank line before its body. The example also wrote to a fixed
`/tmp/lance_data/` path. It now writes to a temporary directory too. It
needs `lance`, which the docstring examples image doesn't install, so
the examples step reports it as skipped by name, and
`//python/ray/data:doctest`, whose image installs `pylance`, runs it.

Stacked on #67237, which adds `lance` to the runner's
`OMITTED_LIBRARIES`. Without that change, the examples step would fail
on `write_lance` rather than skip it.

## Related issues

Related to #67202, #67207, #67209, and #67237.

## Additional information

**Not a duplicate.** I searched open PRs for `write_sql` and
`write_lance`. None converts these examples. #67202, #67207, and #67209
converted the rest of `dataset.py` and have merged.

**Tests run**

- `ci/ray_ci/doc/check_docstring_only.py --base
upstream/doc-1863-docstring-runner-bundle`: "1 file(s), docstrings
only."
- `ci/ray_ci/doc/run_docstring_examples.py python/ray/data/dataset.py`
in an aarch64 image built from
`python/deplocks/docs/docstring_examples_depset_py3.10.lock`, with the
Ray nightly at `093faf5583e` and this branch's `dataset.py` mounted over
the installed one. Result: 64 docstrings run and 0 failed. `write_sql`
passes, and `write_lance` is skipped for `lance`.
- The same run with `pylance==4.0.0` installed, the version Ray Data's
CI pins: 65 docstrings run, 0 failed, and `write_lance` passes. Neither
example leaves files in `/tmp`.
- `pre-commit run --files python/ray/data/dataset.py`: all hooks pass.

The PR carries the `docstring-only` label, and its commit carries an
`@rtd-build` line for the Read the Docs preview.

AI assistance (Claude Code) was used for 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]>
dstrodtman added a commit that referenced this pull request Nov 3, 2026
…ctests (#67619)

## Description

Converts the never-run `.. testcode::` examples in the
`TuneReportCheckpointCallback` docstrings of
`python/ray/tune/integration/lightgbm.py` and
`python/ray/tune/integration/xgboost.py` to `>>>` examples. Sphinx
renders `.. testcode::`, but griffe and MkDocs don't, and stock `>>>`
examples render in both.

Both blocks were `:skipif: True`, so they never ran. They now carry the
docstring-level `# doctest: +SKIP_EXAMPLE` flag (#66753), which skips
the whole docstring in the doctest targets and in the docstring examples
step, so they still never run. The example code is unchanged. The
LightGBM docstring's NumPy-style `Examples` header with a dashed
underline becomes the Google-style `Examples:` header that the rest of
Tune uses.

This is a syntax-only change. The three other remaining Tune `testcode`
blocks, in `tune/callback.py` and `tune/result_grid.py`, pair with a
hidden `testoutput` that matches any output. Converting them changes
what each example checks, so they're in #67623 for Tune review rather
than in this one.

Stacked on #67237, which adds `lightgbm` and `xgboost` to the docstring
examples runner's `OMITTED_LIBRARIES`. Both modules import their library
at module level, and the `docstringbuild` image installs neither.
Without that change, the examples step would fail both modules at
import, rather than skip them.

## Related issues

Related to #66748, #66753, and #67237.

## Additional information

**Not a duplicate.** I searched open PRs for Tune doctest and `testcode`
conversions. None touches these docstrings. #66748, which has merged,
converted the `Trainable` and `Callback` method examples.

**Tests run**

- `ci/ray_ci/doc/check_docstring_only.py --base
upstream/doc-1863-docstring-runner-bundle`: "2 file(s), docstrings
only."
- `ci/ray_ci/doc/run_docstring_examples.py` on both files, in a Python
3.12 virtualenv with `ray[tune]==2.59.0` and neither library installed.
With #67237's runner, both modules are skipped by name: "module needs
lightgbm" and "module needs xgboost," 0 failed. With `master`'s runner,
both fail at import.
- Parsed both docstrings with `doctest.DocTestParser` and compiled every
example: 4 examples in `lightgbm.py` and 6 in `xgboost.py`. Both
docstrings carry `SKIP_EXAMPLE`, so
`bazel/default_doctest_pytest_plugin.py` skips each one whole.
- `pre-commit run --files` on both files: all hooks pass.

The PR carries the `docstring-only` label, and its commit carries an
`@rtd-build` line for the Read the Docs preview.

AI assistance (Claude Code) was used for 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 devprod docs An issue or change related to documentation go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants