Repository navigation
[ci] Run docstring-only examples for every library in a light image without torch or TensorFlow - #67083
Conversation
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]>
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]>
dstrodtman
left a comment
There was a problem hiding this comment.
🤖 This review was generated by Claude Code, run by the PR author, acting as a Ray CI (REEf) reviewer. It's posted from the author's account, which is why it reads like a self-review.
Reviewed from the Ray CI side. The tradeoff here is deliberate: examples that need torch or TensorFlow skip in the light image, and that only affects PRs under the docstring-only label, which the scope guard limits to docstring and comment changes. That's acceptable for the speedup. Below are one small change and a docs fix, plus a few optional nits. The step itself is wired correctly: every test.rules.txt rule matching python/ emits one of its tags, and the bazel query lines up with the cpu tag and the data files that doctest() sets.
Non-blocking, for the record: outside Data, the label doesn't skip any suites yet, so this step adds coverage there but no time savings. The savings depend on a rayci change that lets PR labels adjust tag selection. Until that lands, unlabeled python/ray PRs also pick up a docstringbuild image job, which is cheap when the wanda cache hits.
Test run under the labelThe not-for-merge test PR #67084 is stacked on this branch and edits one Data docstring (
What the run showed:
The first test run, #74936, exposed a missing dependency, fixed in aa48b48. Of the 4.2 minutes, about 1.5 are agent setup and the forge pull, and 46 seconds are Bazel startup for |
There was a problem hiding this comment.
Code Review
This pull request consolidates and optimizes the "docstring-only" CI pipeline by replacing per-library docstring testing steps with a single, unified "doc: docstring examples" step. It introduces a lightweight, CPU-only docstringbuild Docker image and updates the run_docstring_examples.py script to gracefully skip examples requiring omitted heavy libraries (such as PyTorch or TensorFlow) while filtering changed files using Bazel query labels. Feedback on the changes includes a recommendation to make the missing_library exception helper more robust by merging the message-based ImportError check directly into the exception chain traversal loop.
- Say where skipped examples run instead: their library's doctest() target, in premerge where the label doesn't skip the suites and postmerge for Ray Data, whose docs example tests the label turns off. - Repeat the skipped examples at the end of the step's log, in a "+++" section Buildkite opens expanded when the run passes. The step's container can't reach buildkite-agent, so it can't annotate the build. On a failure the list stays in the examples section, which Buildkite expands, so the failures stay in view. - Stop following an exception chain at `raise ... from None`, and note that an implicit context can't be told apart from Ray Data's re-raise. - Note that "azure" is a namespace package, so an azure-* distribution in the image makes the provider module fail rather than skip. - Cover the intermediate lock in test.rules.test.txt. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
…#67202) ## Description Converts the `.. testcode::` examples in six `Dataset` transform methods to stock `>>>` doctests: `map`, `map_batches`, `flat_map`, `groupby`, `aggregate`, and `join`. Stock doctests render without Sphinx-only directives, and the `docstring-only` label's examples step runs them. The change touches only docstrings in `python/ray/data/dataset.py`. **`join` stays render-only.** Its three examples were `:skipif: True`, and their expected output couldn't have matched: a list prints on one line, and `NORMALIZE_WHITESPACE` can't insert the whitespace a multi-line expected block has between `[` and `{`. The examples now print one row per line. They're marked `+SKIP_EXAMPLE` because `Dataset.join` needs `polars`, and neither the docstring examples image nor the Data CI locks install it. With polars installed and the skip removed, all three pass. Running them in CI needs `polars` added to `docstring_examples_depset`, a dependency change that's out of scope here. **`map_batches` runs only in postmerge under the label.** Its third example imports torch, which the docstring examples image omits, so the step skips the whole docstring by name. It still runs in `//python/ray/data:doctest`. ## Related issues Related to #66814 and #67083. ## Additional information **Not a duplicate.** I searched open PRs that touch `python/ray/data/dataset.py` or mention converting its docstring examples. None converts these examples. #66746 and #66812 converted other Data modules and have merged. **Tests run** - `ci/ray_ci/doc/check_docstring_only.py --base upstream/master`: "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`. The run excludes `decord`, which has no aarch64 wheel, and `ray-haproxy`. Result: 56 docstrings run and 0 failed. `map`, `flat_map`, `groupby`, and `aggregate` pass. `map_batches` is skipped for torch, and `join` for `+SKIP_EXAMPLE`. - The same run with `polars` installed and `+SKIP_EXAMPLE` removed: 57 docstrings run, 0 failed, `join` included. - `pre-commit run --files python/ray/data/dataset.py`: all hooks pass, including ruff, black, pydoclint, and the Ray docstyle check. 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]>
…examples to stock doctests (#67207) ## Description Converts the remaining runnable `.. testcode::` examples in nine `Dataset` methods to stock `>>>` doctests: `streaming_split`, `split`, `iter_batches`, `iter_jax_batches`, `iter_tf_batches`, `stats`, `explain`, `serialize_lineage`, and `deserialize_lineage`. It also converts the one example each in `SerializablePreprocessorBase._set_serializable_fields` (`preprocessor.py`) and `MemoryProfiler` (`_internal/util.py`). Stock doctests render without Sphinx-only directives, and the `docstring-only` label's examples step runs them. The change touches only docstrings. Three examples used `:options: +MOCK`, which hid their output from comparison. Comparing it surfaced the following fixes: - **`iter_batches`** read `example://image-datasets/simple`, which resolves inside the installed package, and wheels don't ship `ray/data/examples/data/`. It now reads the same images from `s3://anonymous@ray-example-data/image-datasets/simple`, as `Dataset.map` does. The three images make exactly two batches, so the expected output drops the `...` line between them, which wouldn't have matched. - **`stats`** shows the current output format, with ellipses for counts, timings, and the read operator's name, which becomes `ReadRange->SplitBlocks(N)` depending on the CPU count. The `assert ds.stats() == ""` is now `>>> ds.stats()` with `''` as the output. - **`MemoryProfiler`** replaces the `...` placeholder statement with `pass`. In a doctest, a bare `...` expression echoes `Ellipsis` on every loop iteration. The USS values use an ellipsis. **`iter_tf_batches`** called `Dataset.to_tf`, which has its own examples. It now calls `iter_tf_batches` and prints the first batch, matching the `iter_jax_batches` example. The fourth `streaming_split` example deliberately blocks, so it stays render-only, now with `# doctest: +SKIP` on that one line in place of `:skipif: True`. The rest of the docstring runs. `explain`, `split`, and the lineage examples matched as written. **`iter_jax_batches` and `iter_tf_batches` run only in postmerge under the label.** The docstring examples image omits JAX and TensorFlow, so the step skips both docstrings by name. They still run in `//python/ray/data:doctest`. ## Related issues Related to #66814, #67083, and #67202. ## Additional information **Not a duplicate.** I searched open PRs that touch `python/ray/data/dataset.py`, `streaming_split`, `serialize_lineage`, or `MemoryProfiler`. #67202 converts the `Dataset` transform methods (`map`, `map_batches`, `flat_map`, `groupby`, `aggregate`, `join`) in the same file, and the two PRs edit different methods. #64869 and #66340 don't touch these examples. #66746, #66812, #67070, and #67080 converted other Data modules and have merged. **Tests run** - `ci/ray_ci/doc/check_docstring_only.py --base upstream/master`: "3 file(s), docstrings only." - `ci/ray_ci/doc/run_docstring_examples.py` on the three files in an aarch64 image built from `python/deplocks/docs/docstring_examples_depset_py3.10.lock`, with the Ray nightly at `093faf5583e` and the changed files mounted over the installed ones. The three files are unchanged between that commit and this PR's base. Result: 61 docstrings run and 0 failed. `iter_jax_batches`, `iter_tf_batches`, `to_tf`, `write_tfrecords`, and `iter_torch_batches` are skipped for libraries the image omits. - The two JAX and TensorFlow docstrings, run with `doctest` in the same image after installing `jax` 0.6.2 and `tensorflow` 2.21.0: 0 failures each. Those aren't CI's pinned versions, so I'll check the postmerge `data: docs example tests` result after merge. - `pre-commit run --files` on the three files: all hooks pass, including ruff, black, pydoclint, and the Ray docstyle check. 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]>
…per-page doctest targets - ci.md: the docstring-only examples step is now `doc: docstring examples`, covering every library's changed modules in the light docstringbuild image (#67083). The label still skips only Ray Data's suites. - writing-code-snippets.md: replace the GPU guidance that showed a nonexistent glob catch-all in doc/BUILD with the per-page doctest_each lists (#66809, #67003), and say how a page with a new runnable example joins CI. - docs.md, writing-style.md: the Vale CI check is temporarily off. - ci/ray_ci/doc/README.md: describe the label-driven test selection scripts and the linkcheck report. - doc/README.md: linkcheck does run in CI, after merge, as a soft-fail step. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
…per-page doctest targets (#67204) ## Why are these changes needed? Several contributor-facing CI docs fell behind the docs CI changes that merged this month. - **`ci.md`, "Docstring-only changes."** The section still described `data: docstring examples` and said the examples step covers Ray Data only. Since #67083, `doc: docstring examples` in `others.rayci.yml` runs the changed modules' `>>>` examples for every library that a CPU `doctest()` target covers. It runs in the light `docstringbuild` image, which has no torch or TensorFlow, and reports examples that need those libraries as skipped, by name. Since #67341, the label also skips every library's test suites through `.buildkite/docs.labels.yaml`, so the section now says that, and recommends an `@rtd-build` commit line alongside the label so Read the Docs builds the API reference the docstrings render into. - **`ci.md`, broken steps and post-merge builds.** A new "Why some steps show as broken" section says that on a PR the label rules remove the steps a label skips, so they don't appear at all, that the scope guard is the one label-gated step still shown as `broken` on an unlabeled PR, and that scheduled post-merge builds don't apply label rules, so all three label-gated steps show as `broken` there. The page also distinguishes the two kinds of post-merge build on `master`. The build each merge starts doesn't run the docs example tests, and the scheduled builds that the release automation triggers run the full suite, so the page now says "scheduled post-merge builds" wherever it means those. - **`writing-code-snippets.md`, "How to test examples with GPUs."** It told readers to open `doc/BUILD` and exclude their page from a `glob(["source/**/*.rst"])` catch-all target. Neither exists: #66809 and #67003 replaced library-wide prose targets with per-page `doctest_each()` lists. The steps now show both cases: a doc page moves from its library's `doctest_each` list to the GPU `doctest` rule, and a docstring module moves from the CPU glob's `exclude` to the GPU rule. A new short section says how a page with its first runnable example joins CI, which the `doc_prose_doctest_targets` lint enforces. - **`docs.md` and `writing-style.md`.** Both said CI enforces Vale. The `documentation_style` check is out of the `lint.rayci.yml` matrix for now, so they say the check is temporarily off. - **`ci/ray_ci/doc/README.md`.** It described only the doc build and the API guard. It now covers the scripts behind the `docs-example-test` and `docstring-only` labels and `linkcheck_report.py`. - **`doc/README.md`.** It said CI doesn't run linkcheck. The postmerge `doc: linkcheck` step does, as a soft-fail step that never blocks. Docs-only. No CI or behavior changes. ## Related issue number None. Follows #66806, #66809, #66814, #67003, and #67083. ## Duplicate check Not a duplicate. `gh pr list --repo ray-project/ray --state open` searches for `"ci.md docstring"`, `"writing-code-snippets"`, and `"ci/ray_ci/doc README"` return two other open PRs that touch these files, both mine, neither covering these sections: - #65868 adds a "How to test a Ray Serve deployment" section to `writing-code-snippets.md` at the same insertion point as this PR's new section, so whichever merges second needs a trivial rebase. - #66884 updates the LLM doc paths in `ci.md`, not the docstring-only section. ## Testing - Every changed claim was checked against `master` at 3ae1b8b: `.buildkite/others.rayci.yml`, `.buildkite/data.rayci.yml`, `.buildkite/lint.rayci.yml`, `.buildkite/doc.rayci.yml`, `doc/BUILD.bazel`, `python/ray/train/BUILD.bazel` (the GPU rule examples are copied from the real `doctest[train-gpu]` and `py_doctest[train-gpu]` rules), `doc/test_prose_doctest_targets.py`, and the scripts under `ci/ray_ci/doc/`. - `pre-commit run` on the changed files passes, including the master-link check. - Not run: a Sphinx build. The Read the Docs preview on this PR is the check. AI assistance (Claude Code) was used to find the stale text and draft the changes. 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]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…ttings in the examples runner (#67237) ## 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 #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)`. #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`. #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. #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 #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 #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 #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](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
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/.docstringbuild(ci/docker/docstring.build.*) is built onoss-ci-base_testwith a 138-package depset that has no torch, TensorFlow, or cupy. Its layer is about 244 MB, against the 11.8 GBdatalbuild-py3.10..buildkite/test.rules.txt, the new lock files and requirements file run onlydeplock_check. The Dockerfile and wanda spec run no steps, the same asdoctestbuild.doc: docstring examplesinothers.rayci.ymlreplacesdata: docstring examplesindata.rayci.yml.python/rayPRs gain onedocstringbuildimage job, because rayci doesn't evaluateif:. Nothing else changes in the generated pipelines.Result: on premerge #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-corewas requested only through the/ci/catch-all, which also lists ray-ci.Description
#66814 added the
docstring-onlylabel 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 examplesstep runs about 30 seconds of examples, but takes about 10 minutes, because it runs indatalbuild-py3.10. That image is built on the ML base image and is about 11.8 GB compressed. On premerge #74929 and #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.10alone takes about 19 minutes.What this PR does:
A light depset.
docstring_examples_depset_py3.10, indocs.depsets.yaml, isray[all]plus the libraries the examples need:ray.init()starts the dashboard, which imports every module underray/dashboard/moduleswhen it loads, including test modules in packagedtests/directories, and nine of those import pytest. Without it, the dashboard fails to start, and eachray.init()waits out a 30-second RPC deadline.It has no torch, TensorFlow, or
cupy-cuda12x. It expandsray_img_depsetwith the samerequirements_compiledconstraints asdoctest_depsetandci_data, so every package resolves to the version Ray's tests pin. It then relaxescupy-cuda12xandfastrlock, which onlyray[cgraph]and cupy require. That leaves 138 packages, about 656 MB installed on Linux x86_64.A
docstringbuildimage. It's built onoss-ci-base_testand installs that lock. Locally its layer is about 244 MB compressed, against roughly 0.9 GB foross-ci-base_test. Newtest.rules.txtentries route the image's files narrowly:deplock_check.doctestbuild's already do.Without these entries, the files fall to the general
python/requirements/andci/docker/rules, which fan out across every library and the release tests.Skip examples that need a library the image omits.
run_docstring_examples.pyreports a docstring as skipped, with the library named, when it fails only because a library inOMITTED_LIBRARIESisn'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.ModuleNotFoundError; anImportErrorchained to one, as in Ray Data's install-advice errors; and a bareImportErrornaming the library, such as RLlib's "PyTorch was specified as the framework".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.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 offdata: docs example tests.+++section, which Buildkite opens expanded. The step's container can't reachbuildkite-agent, so it can't annotate the build.One step for every library.
doc: docstring examplesinothers.rayci.ymlreplacesdata: docstring examples. It runs the examples in every changed module underpython/raythat a CPUdoctest()target covers, found with abazel query, so it never runs an example CI doesn't already run. Six files with runnable examples, such asutil/iter.pyandutil/dask/scheduler.py, have nodoctest()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 negatedif:on nearly every premerge test step. A better way is to let rayci adjust tag selection from PR labels, a separate change toray-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 evaluateif:, so an unlabeled Python PR that selects it still buildsdocstringbuild, 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 carriesoss, 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_notecase). The new tests cover each import-error shape,raise ... from None, both safeguards, the coverage filter, andmain()end to end.bazel run //ci/raydepsets:raydepsets -- build ci/raydepsets/configs/docs.depsets.yaml --check: lock files are up to date.rayci test-rulesat v0.48.0: all 185 cases pass, including the new ones. A deliberately wrong expectation fails, so the check is live.oss-ci-base_testis in CI's registry.run_docstring_examples.pyover all 87 files with runnable examples (323 docstrings) in the arm64 build, with the nightly wheel at the same commit. Every file a CPUdoctest()target covers either passes or skips with the library named. The exception isread_videos, which needs decord, and decord publishes no aarch64 wheel; the x86_64 image installs it.shellcheckonrun_docstring_examples.sh. The end of the script, which preserves the exit status and repeats the skips, ran against a stubdockerfor a passing run and a failing one.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, passed:
docstringbuildbuilt on the realoss-ci-base_testin 138 s.docstring examplesstep took 4.2 min, against 10.1 min ondatalbuild-py3.10.Details are in this 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