Skip to content

[doc] Test PR (not for merge): exercise docstring-only examples in the light image - #67084

Closed
dstrodtman wants to merge 7 commits into
masterfrom
doc-1838-docstring-only-test
Closed

dstrodtman wants to merge 7 commits into
masterfrom
doc-1838-docstring-only-test

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Description

Test PR, not for merge. It's stacked on #67083 to exercise the new doc: docstring examples step under the docstring-only label, which #67083 can't do itself, since it changes CI config and the label's scope guard would fail it.

It changes two docstrings, and nothing else:

  • ray.tune.grid_search, in a library outside Ray Data. Its examples should run and pass in the docstringbuild image.
  • Dataset.iter_torch_batches, in python/ray/data/dataset.py. Its examples need torch, which the image leaves out, so the step should report them as skipped with torch named. It should run and pass the rest of dataset.py's examples.

What to check on this PR's premerge:

  • lint: validate docstring-only scope passes.
  • doc: docstring examples runs both files in docstringbuild and passes, with the torch and TensorFlow examples in dataset.py skipped by name.
  • The docstringbuild image's real size and pull time, against about 6.4 minutes for datalbuild-py3.10 today.
  • Data's test suites are skipped under the label, and Tune's still run (expected until rayci can gate selection on labels).

The two wording edits are real fixes. If they're wanted, they can land in a regular docstring PR.

Related issues

Related to #67083.

Additional information

python ci/ray_ci/doc/check_docstring_only.py --base doc-1838-light-docstring-image: docstring-only guard: 2 file(s), docstrings only.

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

🤖 Generated with Claude Code

dstrodtman and others added 5 commits October 15, 2026 12:55
Add docstring_examples_depset_py3.10, the environment for the
"docstring-only" label's >>> examples steps: ray[all] plus dask and the
optional libraries Ray Data's readers, writers, and aggregations import
lazily (pillow, pyiceberg, fastavro, soundfile, decord, datasketches,
crc32c), without torch, TensorFlow, or cupy-cuda12x.

It expands ray_img_depset with the same requirements_compiled constraints
as doctest_depset and ci_data, so every package resolves to the version
Ray's tests use. It then relaxes cupy-cuda12x and fastrlock, which only
ray[cgraph] and cupy require. The Azure SDK is left out: the Azure node
provider needs azure-cli-core to import, and its one runnable example is
a single private import.

It installs to about 656 MB on Linux x86_64.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Add docstringbuild, built on oss-ci-base_test, which installs
docstring_examples_depset_py3.10. Pulling it should take on the order of
a minute, against the 6.4 minutes the docstring examples step spends
pulling datalbuild-py3.10, which carries the full ML stack. Nothing
consumes the image yet.

Route its lock and requirements input to deplock_check only, and its
Dockerfile and wanda spec to no tags, like doctestbuild: they feed only
this label-gated image, never a Ray wheel, another test image, or the
Sphinx docbuild image. Without these rules they fall to the general
python/requirements/ and ci/docker/ rules, which fan out across every
library and release tests.

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

The docstringbuild image leaves out torch, TensorFlow, and a few other
libraries. Teach run_docstring_examples.py to report a docstring that fails
only because one of them isn't installed as skipped, with the library
named, instead of failed. Every docstring in a module that can't be
imported without one is skipped the same way. Those examples still run in
their library's doctest() target.

It recognizes the three shapes these failures take: a ModuleNotFoundError,
an ImportError chained to one (Ray Data's install-advice errors), and a
bare ImportError that only names the library, such as RLlib's "PyTorch was
specified as the framework". A library that's installed never matches, so
nothing is skipped in a full image, and any other import failure still
fails the run. A module that fails to import no longer aborts the run; it's
reported and the remaining files still run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Replace "data: docstring examples" with "doc: docstring examples" in
others.rayci.yml. On a PR with the "docstring-only" label, it runs the >>>
examples in every changed module under python/ray, in any library, in the
docstringbuild image instead of datalbuild-py3.10.

It runs only modules that a CPU doctest() target covers, found with a
bazel query, so it never runs an example CI doesn't already run. Files no
target covers, such as util/iter.py, and files only a GPU target covers are
named and left out.

The step carries every library tag a python/ray/ change can emit, so a
labeled PR selects it whatever it touches, and `oss`, like the label's
scope guard. Until rayci can gate step selection on PR labels, an unlabeled
PR that selects it still builds docstringbuild (one image job, a cache hit
most of the time), though Buildkite drops the step itself. The Data test
steps keep their label gates; other libraries' suites still run under the
label for now.

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

Test change for the docstring-only label on the docstringbuild step: a
Tune and a Data docstring, present tense and a clearer subject. Not for
merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman dstrodtman added docstring-only Skip heavy library tests for Ray API docstring edits. go add ONLY when ready to merge, run all tests labels Oct 15, 2026
dstrodtman and others added 2 commits October 15, 2026 14:04
ray.init() starts the dashboard, which imports every module under
ray/dashboard/modules when it loads, including the test modules in
packaged tests/ directories. Nine of them import pytest. Without it the
dashboard fails to start and each ray.init() waits out a 30-second RPC
deadline, so every docstring that starts Ray took about 30 seconds in the
docstringbuild image. pytest resolves to 7.4.4, the version every other CI
image has.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
…' into doc-1838-docstring-only-test

Signed-off-by: Douglas Strodtman <[email protected]>
dstrodtman added a commit that referenced this pull request Oct 20, 2026
…ithout torch or TensorFlow (#67083)

## Review guide

**For ray-ci reviewers.** About 660 lines need review. The other ~7,250
are the two generated lock files under `python/deplocks/docs/`.

1. **New image.** `docstringbuild` (`ci/docker/docstring.build.*`) is
built on `oss-ci-base_test` with a 138-package depset that has no torch,
TensorFlow, or cupy. Its layer is about 244 MB, against the 11.8 GB
`datalbuild-py3.10`.
1. **Routing.** In `.buildkite/test.rules.txt`, the new lock files and
requirements file run only `deplock_check`. The Dockerfile and wanda
spec run no steps, the same as `doctestbuild`.
1. **Step.** `doc: docstring examples` in `others.rayci.yml` replaces
`data: docstring examples` in `data.rayci.yml`.
1. **Cost to unlabeled PRs.** `python/ray` PRs gain one `docstringbuild`
image job, because rayci doesn't evaluate `if:`. Nothing else changes in
the generated pipelines.

**Result:** on premerge
[#74946](https://buildkite.com/ray-project/premerge/builds/74946), the
step drops from 10.1 to 4.2 min, and the cold image pull from 384 to 38
s.

**Approval:** ray-ci owns every file in this PR. `ray-core` was
requested only through the `/ci/` catch-all, which also lists ray-ci.

## Description

#66814 added the `docstring-only` label for Ray Data: under the label, a
PR runs the `>>>` examples in the modules it changed instead of Data's
test suites. This PR makes that examples step faster and extends it to
every library.

**Why.** The `data: docstring examples` step runs about 30 seconds of
examples, but takes about 10 minutes, because it runs in
`datalbuild-py3.10`. That image is built on the ML base image and is
about 11.8 GB compressed. On premerge
[#74929](https://buildkite.com/ray-project/premerge/builds/74929) and
[#74882](https://buildkite.com/ray-project/premerge/builds/74882),
pulling and extracting it took 384 and 386 seconds. The image chain also
delays the step's start: when wanda's cache misses,
`oss-ci-base_ml-py3.10` alone takes about 19 minutes.

**What this PR does:**

1. **A light depset.** `docstring_examples_depset_py3.10`, in
`docs.depsets.yaml`, is `ray[all]` plus the libraries the examples need:
    - dask.
- pytest. `ray.init()` starts the dashboard, which imports every module
under `ray/dashboard/modules` when it loads, including test modules in
packaged `tests/` directories, and nine of those import pytest. Without
it, the dashboard fails to start, and each `ray.init()` waits out a
30-second RPC deadline.
- The optional libraries that Ray Data's readers, writers, and
aggregations import lazily: pillow, pyiceberg, fastavro, soundfile,
decord, datasketches, and crc32c.

It has no torch, TensorFlow, or `cupy-cuda12x`. It expands
`ray_img_depset` with the same `requirements_compiled` constraints as
`doctest_depset` and `ci_data`, so every package resolves to the version
Ray's tests pin. It then relaxes `cupy-cuda12x` and `fastrlock`, which
only `ray[cgraph]` and cupy require. That leaves 138 packages, about 656
MB installed on Linux x86_64.
2. **A `docstringbuild` image.** It's built on `oss-ci-base_test` and
installs that lock. Locally its layer is about 244 MB compressed,
against roughly 0.9 GB for `oss-ci-base_test`. New `test.rules.txt`
entries route the image's files narrowly:
    - The lock files and requirements file run only `deplock_check`.
- The Dockerfile and wanda spec run no steps, as `doctestbuild`'s
already do.

Without these entries, the files fall to the general
`python/requirements/` and `ci/docker/` rules, which fan out across
every library and the release tests.
3. **Skip examples that need a library the image omits.**
`run_docstring_examples.py` reports a docstring as skipped, with the
library named, when it fails only because a library in
`OMITTED_LIBRARIES` isn't installed. That list covers torch, TensorFlow,
and a few others. Every docstring in a module that can't import without
one is skipped the same way.
- **Error shapes it recognizes:** a `ModuleNotFoundError`; an
`ImportError` chained to one, as in Ray Data's install-advice errors;
and a bare `ImportError` naming the library, such as RLlib's "PyTorch
was specified as the framework".
- **Safeguards:** the chain stops at `raise ... from None`, and an
installed library never matches, so nothing is skipped in a full image.
Any other import failure still fails the run.
- **No more aborted runs:** a module that fails to import is reported,
and the remaining modules still run.
- **Where skipped examples run instead:** their library's `doctest()`
target. That's in premerge for libraries whose suites the label doesn't
skip, and postmerge for Ray Data, because the label also turns off
`data: docs example tests`.
- **Where they're shown:** the step repeats them at the end of its log.
On a pass, they're in a `+++` section, which Buildkite opens expanded.
The step's container can't reach `buildkite-agent`, so it can't annotate
the build.
4. **One step for every library.** `doc: docstring examples` in
`others.rayci.yml` replaces `data: docstring examples`. It runs the
examples in every changed module under `python/ray` that a CPU
`doctest()` target covers, found with a `bazel query`, so it never runs
an example CI doesn't already run. Six files with runnable examples,
such as `util/iter.py` and `util/dask/scheduler.py`, have no `doctest()`
target and fail in any environment. The step names them and leaves them
out.

**Scope.** The examples step now covers every library. The label still
skips only Ray Data's test suites, through the existing per-step `if:`
gates. Skipping other libraries' suites the same way would mean a
negated `if:` on nearly every premerge test step. A better way is to let
rayci adjust tag selection from PR labels, a separate change to
`ray-project/rayci`. Until then, a labeled docstring-only PR outside
Data still runs its library's suites, so the new step adds coverage
there without saving time yet.

**Cost.** The step carries every library tag a `python/ray/` change can
emit, so a labeled PR selects it whatever it touches. rayci doesn't
evaluate `if:`, so an unlabeled Python PR that selects it still builds
`docstringbuild`, though Buildkite drops the step. I generated premerge
pipelines with rayci v0.48.0 against unmodified master. Unlabeled and
labeled Serve PRs and a labeled Data PR each gain exactly one image job,
`docstringbuild`, and nothing else changes. A doc-prose-only PR gains
nothing. The step also carries `oss`, like the label's scope guard.

## Related issues

Related to #66814.

## Additional information

**Not a duplicate.** #66814, which this extends, is merged. I searched
open PRs for the label, the step, and the image, and found nothing
overlapping.

**Tests run**

- `bazel test //ci/ray_ci/doc:test_run_docstring_examples`: 29 passed, 1
skipped (the existing Python 3.11+ `add_note` case). The new tests cover
each import-error shape, `raise ... from None`, both safeguards, the
coverage filter, and `main()` end to end.
- `bazel run //ci/raydepsets:raydepsets -- build
ci/raydepsets/configs/docs.depsets.yaml --check`: lock files are up to
date.
- `rayci test-rules` at v0.48.0: all 185 cases pass, including the new
ones. A deliberately wrong expectation fails, so the check is live.
- Pipeline generation with rayci v0.48.0 for the four PR shapes above,
compared against master.
- The image, built for linux/amd64 and linux/arm64 on a stand-in base,
because `oss-ci-base_test` is in CI's registry.
- `run_docstring_examples.py` over all 87 files with runnable examples
(323 docstrings) in the arm64 build, with the nightly wheel at the same
commit. Every file a CPU `doctest()` target covers either passes or
skips with the library named. The exception is `read_videos`, which
needs decord, and decord publishes no aarch64 wheel; the x86_64 image
installs it.
- `shellcheck` on `run_docstring_examples.sh`. The end of the script,
which preserves the exit status and repeats the skips, ran against a
stub `docker` for a passing run and a failing one.
- Locally, `ray.init()` with the dashboard's packaged test modules
present takes 31 s without pytest and 6 s with it, with the dashboard
up.

**Verified in CI.** This PR changes CI config, so the label's scope
guard would fail it. #67084, a test PR stacked on this one and not for
merge, edits a Data docstring and a Tune docstring under the label. Its
premerge,
[#74946](https://buildkite.com/ray-project/premerge/builds/74946),
passed:

- `docstringbuild` built on the real `oss-ci-base_test` in 138 s.
- The `docstring examples` step took 4.2 min, against 10.1 min on
`datalbuild-py3.10`.
- Pulling and extracting the image took 37.6 s on a cold agent, against
384 s.
- The step ran 53 docstrings across Data and Tune in 85 s: 0 failed, and
the 3 expected TensorFlow and torch examples skipped by name.

Details are in [this
comment](#67083 (comment)).
The first test run is what exposed the pytest gap above.

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]>
Base automatically changed from doc-1838-light-docstring-image to master October 20, 2026 16:43
@dstrodtman

Copy link
Copy Markdown
Contributor Author

This was a test PR. Tested code has since merged, so closing.

@dstrodtman dstrodtman closed this Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docstring-only Skip heavy library tests for Ray API docstring edits. go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant