Repository navigation
[ci] Split library prose doctests into per-file targets so the docs-example-test opt-in can run them - #66809
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new lint check, doc_prose_doctest_targets, to ensure that all documentation prose pages with runnable examples have corresponding per-file doctest targets and are correctly routed in Buildkite. The changes also update the Buildkite configurations, test rules, and contributor documentation to integrate this check. Reviewer feedback focuses on enhancing the robustness of the new validation script, doc/test_prose_doctest_targets.py. Key recommendations include making regex patterns more flexible, handling uppercase file extensions to prevent potential crashes, specifying UTF-8 encoding for cross-platform file reading, and resolving paths to absolute paths to avoid errors with relative path inputs.
…t enforced) (#66885) ## Why are these changes needed? This PR adds Vale terminology rules for Ray Train docs ahead of a style pass over those pages. It follows the pattern from #65239 (KubeRay), #66236 (RLlib), and #66640 (Ray Core). Every rule is warn-level and **doesn't run in CI yet**. Registering the config lets contributors run `vale doc/source/train/` by hand during the style pass. **Stacked on #66883**, which renames the Train landing page and hyphenates page slugs. The path-scoped section targets the final paths, so this PR targets that branch. Retarget it to `master` once #66883 merges. ## What's here - **`.vale/styles/Train/Terms.yml`:** case-sensitive `substitution` swaps at `level: warning`, each safe to apply without judgment, so the file sets `action: replace`. The forms follow the four concepts `train/overview.md` defines: - `train function` becomes `training function`. - `scaling config`, `run config`, and `checkpoint config` are spelled out in prose. The classes keep code style. - `finetune` and its forms become `fine-tune`. - `Train v2` becomes `Train V2`. - **`.vale/styles/Train/Capitalization.yml`:** title-cased generic nouns, such as `Fault Tolerance`, `Local Mode`, and `Worker Group`, plus `Trainer` written as the Ray Train concept. Applying any of these takes judgment, so this rule has no replace action: - Lowercasing would also drop the capital at the start of a heading or sentence, which has to stay. - A bare "Trainer" in prose is often a third-party class, such as the Lightning or Hugging Face Transformers `Trainer`. Those need code style, not lowercase. The rule's keys carry a preceding word, such as `the Trainer` and `your Trainer`, and leave the decision to a person. - **Trainer casing:** prose uses "trainer" lowercase for the concept, with class names in code style. That matches the guide's rule to lowercase generic nouns even when they name a Ray concept, the way Ray Core treats "placement group." `overview.md` capitalizes it today, so the style pass changes that page. - **Accept lists:** - `Train` gains `JAX`, `Flax`, `Optax`, `Orbax`, `TensorBoard`, `torchrun`, `allreduce`, and `resharding`. - `General` gains cross-library words and vendor names: `Trainium`, `Backblaze`, `Filestore`, `preemption(s)`, `bottleneck(ed|ing)`, `iterable(s)`, `serializable`, and `colocated`. - Casing-only fixes such as `Jax` and `Tensorboard` come from the accept list driving `Vale.Terms` rather than from a swap, so no token alerts twice. - **RLlib accept list fix:** `[Pp]y[Tt]orch` and `[Tt]ensor[Ff]low` become `PyTorch` and `TensorFlow`. Vocabularies register globally, so those bracket classes accepted `Pytorch` and `Tensorflow` in every library and silently overrode the Train vocabulary's casing. The change adds no alerts under `doc/source/rllib`. It surfaces 15 miscased brand names in prose elsewhere, across Serve, Tune, KubeRay, cluster, getting-started, and Train pages. It also flags the "Not" column of the new guide table, as intended, and one `:link:` false positive, described under Testing. - **`Ray/Brands.yml`:** adds `WandB` → `W&B`. It's case-sensitive, so the lowercase package name `wandb` doesn't match. - **`.vale.ini`:** a `[doc/source/train/**/*.{md,rst}]` section with `Vale, Google, Ray, Train`, which mirrors the Core block. - **`writing-style.md`:** a "Writing Ray Train docs" section with a terms table. Both Train rules link to it through the `ray-train-docs-style` label. The section also places a Train worker relative to a Ray Core worker process. No prose under `doc/source/train/` changes here. The style pass that fixes the alerts follows in separate PRs stacked on this one. ## Duplicate check No open PR adds Ray Train Vale rules. I searched open `ray-project/ray` PRs for `vale train` and for `writing-style.md`. The only hits are #66809, my own CI change with no Vale or style-guide edits, and #65707, a KubeRay docs change. ## Testing Commands, run from the repo root: ```bash vale --output=JSON doc/source/train/ vale --output=line doc/source/ # before and after, diffed pre-commit run --files <changed files> ``` Results with Vale 3.12.0: - **`doc/source/train/`:** total alerts go from 839 to 802. `Train.Terms` raises 5 alerts, all true positives. `Train.Capitalization` raises 29: `Trainer` concept uses, title-cased `Fault Tolerance` and `Local Mode`, and the Lightning and Transformers `Trainer` mentions that the style pass should put in code style. `Vale.Spelling` drops from 77 to 43. The rest is mostly unbackticked code and identifiers for the prose pass. No position alerts twice across `Vale.Terms`, `Vale.Spelling`, `Train.*`, `Ray.Terms`, and `Ray.Brands`. - **Rule check against the new guide table:** linting the table rows under the Train scope fires on every "Not" form except a bare `Trainer`, which the rule deliberately doesn't match. - **Other scopes:** compared alert by alert over `doc/source/rllib`, `doc/source/core`, and `doc/source/kuberay`, the accept-list entries remove 4 false positives (`serializable`, `colocated`, `JAX`, and one `Google.Parens`). The only new alerts are 5 true-positive `WandB` hits in RLlib, from the shared `Ray/Brands.yml`. Across all of `doc/source`, the RLlib accept-list fix is the only other source of new alerts. - **Known false positive:** Vale reads a sphinx-design `:link:` option as prose. `train/more-frameworks.md:43` (`:link: distributed-tensorflow-keras`) alerted on `keras` before this PR and now also alerts on `tensorflow`. A section-scoped `TokenIgnores = (:link: \S+)` didn't suppress it, so it's left as a follow-up. Five `:link:` lines exist across `doc/source`. - **pre-commit:** passed on the changed files. - **Not run locally:** the Sphinx build. The only `doc/source` change is one new section and label in `writing-style.md`. The RtD preview covers it. Prepared with AI assistance (Claude Code). Draft until the submitter has 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]>
fce20bc to
cb1fdb9
Compare
Move the Core, RLlib, Serve, and Train prose doctest targets from one library-wide doctest() to doctest_each() over an explicit list of the pages that collect a test, as Data already does. The docs-example-test opt-in only runs per-file targets, so this lets it test a changed prose page outside Data. Pages that collect nothing (no >>> or testcode block, or only `:skipif: True` blocks) drop out of doctest targets rather than becoming per-file targets that pass vacuously. doctest[tune] collected nothing and is removed. Route the split pages to doc_example page by page, and add test.rules.test.txt cases for them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
The docs-example-test label now runs Core, RLlib, Serve, and Train pages with a runnable example, not only Ray Data pages. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
The per-file prose doctest targets name their pages explicitly, so a runnable block added to an unlisted page would run nowhere. Add a stdlib-only check, run in the prose lint matrix, that fails when a Core, RLlib, Serve, Train, or Tune page with a runnable example has no target, when a listed page has nothing runnable, or when the doc_example rule and the CPU doctest lists disagree. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
The contributor CI page named three prose lint steps, two of which no longer run on prose. List the four that do, including the new doc_prose_doctest_targets check. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
A relative --doc-dir such as '.' made the repo root resolve to '.', so the check failed to find .buildkite/test.rules.txt. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
Master renamed doc/source/rllib/package_ref/ to doc/source/rllib/api/, so update the RLlib doctest_each list, the doc_api/doc_example file rule, and its test expectation to the new paths. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
cb1fdb9 to
5cbddc2
Compare
Replace the per-page doc_example list with a broad doc/source/*.md and *.rst match, after the API reference rules. The opt-in step already picks targets by changed file when it runs, so the rule no longer needs to know which pages have a per-file doctest target. A page rename, a move, or a page gaining a runnable example now edits only doc/BUILD.bazel. Prose that Sphinx never renders as a page, under doc/source/_* and doc/source/templates/, stays skipped. The prose doctest lint drops its rules-sync check and keeps the check that every runnable page has a target or a reason in UNTESTED. The cost: every prose PR under doc/source/ builds the opt-in step's images from cache, even without the label, because rayci marks dependencies before Buildkite evaluates the step's if: guard. Signed-off-by: Douglas Strodtman <[email protected]>
Drop the file-level rule that sent doc/source/rllib/api/callback.rst and utils.rst to both doc_api and doc_example. The existing api/ directory rule already gives them doc_api, and naming individual pages in a ray-ci-owned rules file means renaming or removing either page needs ray-ci review. API reference pages trigger the API consistency checks, not the docs example opt-in; the post-merge build still runs their doctests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
…les to stock doctests (#67070) ## What Convert the remaining `.. testcode::` examples in two `ray.data` torch docstrings to stock `>>>` doctests: - `TorchVisionPreprocessor`: two runnable blocks. - `TorchInference`: one `:skipif: True` block. It needs a GPU (`.cuda()`, `num_gpus=1`), so it carries the docstring-level `# doctest: +SKIP_EXAMPLE` flag from #66753 instead. ## Why This continues the convergence in #66746 and #66812, with the same conversion rules: same code, same order, same docstring, blank lines inside a block dropped, and each example under a plural `Examples:` header with no blank line after it. Lead-in sentences stay inside the section. It's also the first Data PR opened after #66814 merged, and it carries the `docstring-only` label, so its premerge build exercises the new `data: docstring examples` step and the `lint: validate docstring-only scope` guard on a real build. #66812 deferred `preprocessors/torch.py` because it needs `torchvision`. That's true locally only: `torchvision` is in `python/requirements/ml/data-test-requirements.txt`, which the `datalbuild` image the new step uses installs. `TorchInference` changes test reporting as well as markup. Ray's `pytest-sphinx` fork drops `:skipif: True` blocks before collection, so the example wasn't reported at all. Under `+SKIP_EXAMPLE`, the Data doctest plugin and the new runner both report it as skipped. ## Not in this PR `SerializablePreprocessorBase._set_serializable_fields` stays as is, for the reason in #66812: it shows a method pattern in prose, not under an `Examples:` section. `dataset.py`, `read_api.py`, and `llm.py` go in their own PRs. ## Duplicate check I searched open PRs for `TorchVisionPreprocessor`, `torch_inference`, and `testcode doctest data`. The only related open PRs are my own #66746, #66812, and #66809, which touch other files. ## Tests run Locally, against a Ray nightly (`43b706d`) on Python 3.12 with the edited modules overlaid and `torchvision` 0.29.1 installed. The pytest runs use 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. | Run | Before | After | |---|---|---| | pytest, both collectors | 1 passed | 1 passed, 1 skipped (`+SKIP_EXAMPLE`) | | pytest, `-p no:sphinx` | n/a | 1 passed, 1 skipped | | `ci/ray_ci/doc/run_docstring_examples.py` on both files | n/a | 1 docstring run, 0 failed, 1 skipped | | `ci/ray_ci/doc/check_docstring_only.py --base upstream/master` | n/a | passes: 2 files, docstrings only | The `TorchVisionPreprocessor` example reads `s3://anonymous@air-example-data-2/imagenet-sample-images`, as it did before, so it needs network access. `pre-commit` passes on the changed files. **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]>
…ules (#67089) ## Why are these changes needed? `test-rules` fails on master, so every premerge build that includes master since 18:32Z today goes red. For example, [74953](https://buildkite.com/ray-project/premerge/builds/74953) and [74954](https://buildkite.com/ray-project/premerge/builds/74954) both fail on the same line: ``` FAIL: doc/source/cluster/doc_code/README.md (line 180) +doc_example (unexpected) 1/192 test(s) failed ``` Two PRs that merged a minute apart conflict, though each passed `test-rules` on its own base: - #67008 (merged 18:31Z) removed `doc/source/templates/`. It added the expected result `doc/source/cluster/doc_code/README.md:` (no tags), because prose inside a `doc`-routed `doc_code/` directory is skipped. - #66809 (merged 18:32Z) routes `doc/source/*.md` to `doc_example`. Its skip rule for prose that Sphinx never renders exempted only `doc/source/templates/*.md`, which #67008 had just removed. This PR points that skip rule at the two `doc`-routed `doc_code/` directories (`cluster/` and `ray-contribute/`) instead of the removed templates directory. It also drops the stale `doc/source/templates/README.md:` expected result, which would now fail the same way, and adds the matching `ray-contribute/doc_code/README.md:` expected result. ## Duplicate check I searched open PRs for `test-rules` and `test.rules README` and found no fix in flight. I'm the author of both PRs that conflict. ## Testing I built rayci at the repo's pinned version (`.rayciversion` = 0.48.0) and ran `rayci test-rules` from the repo root: - On master without this change, it fails with the same `doc/source/cluster/doc_code/README.md (line 180)` error as CI and exits 1. - With this change, it passes and exits 0. AI assistance (Claude Code) was used to diagnose the failure and draft the change. 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]>
## Why are these changes needed? A `testcode` block reads as code that CI runs. On doc pages, 217 of them never run. Most carry `:skipif: True`, which Ray's pytest-sphinx fork drops before it builds an example, so the block never even shows up as skipped. The rest sit on pages that no doctest target collects. Most of these date from the semgrep `code-block-python` rule that required `testcode`, which #65903 removed. ### Changes - 45 doc pages: each never-run `testcode` block becomes a plain fenced `python` block, or `.. code-block:: python` in rST. Its paired `testoutput` becomes a `text` block. pytest-sphinx attaches a `testoutput` to the nearest preceding `testcode`, so leaving one behind would pin its output onto an earlier block that does run. - The 8 never-run blocks marked `:hide:` are deleted. Readers never saw them and CI never ran them. - The `hasattr` self-check asserts in the collective backend example are dropped. The asserts in `testing-tips.md` and the local-mode unit test stay, because they're what those examples teach. - `writing-code-snippets.md` no longer teaches `:skipif: True`. Code CI can't run goes in a plain code block, with a `text` block for sample output. - `doc/test_prose_doctest_targets.py` and `doc/BUILD.bazel`: `core/handling-dependencies.md` and `train/horovod.md` no longer hold a runnable example, so they leave `UNTESTED`, and the BUILD comments that explained their missing targets are trimmed. Docstring `testcode` under `python/ray/` is out of scope. It's moving to `>>>` examples in separate PRs, because `code-block` doesn't suit docstrings. ## Duplicate check No open PR covers this. Searches for `skipif`, `testcode`, and `writing-code-snippets` return only my own docstring-convergence PRs (#66745, #66746, #66812) and #66809, which this PR builds on and which has merged. ## Testing - For every changed page, I extracted examples with the pinned pytest-sphinx fork (`ray-project/pytest-sphinx@c1ab2b33`, `docstring2examples`, `pytest==7.4.4`) before and after the change. On the 36 pages a doctest target collects, the examples are identical: same source, expected output, and options. The 9 pages whose examples changed are exactly the pages no target collects, so no test result changes. - `python doc/test_prose_doctest_targets.py` passes: "45 listed pages; every runnable page is accounted for." Without the two `UNTESTED` removals, it fails on both as stale. - `pre-commit run` on all changed files passes. - No `:skipif:` remains under `doc/` except the guide's instruction not to use it. - Not run: a Sphinx build. The edits are directive-to-fence swaps, and the Read the Docs preview is the check. AI assistance (Claude Code) was used to write this change. 🤖 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]>
## Why are these changes needed? Builds on #66974. This PR changes only files under `doc/`, so it needs no `@ray-project/ray-ci` review. #66809 routes all prose under `doc/source/` to the `docs-example-test` opt-in, so giving a page a target here doesn't touch `.buildkite/`. The per-page routing this PR used to add, 27 page paths in `test.rules.txt`, is the kind of edit #66809 removes. #66809 gives Core, RLlib, Serve, and Train pages one doctest target each, listing only pages with something to run. Two doc doctest targets still glob directories, so they report passes with nothing behind them: - The catch-all `//doc:doctest` globs 214 pages that no library owns. 8 of them have a runnable example. - Ray Data's `doctest_each` globs `source/data/`. 12 of its 31 per-page targets, such as `user-guide`, `benchmark`, and `api/api`, run nothing. ### Changes - `doc/BUILD.bazel`: the catch-all becomes `doctest_each()` over its 8 runnable pages, still tagged `team:none` with the Ray Data pytest plugin, so the postmerge `doc: doctest` step selects them unchanged. Its 17 exclude lines go away, including the three for pages that #66974 left with nothing to run. Data lists its 19 runnable CPU pages. The GPU targets are unchanged. - `doc/test_prose_doctest_targets.py`: the lint now covers every page under `doc/source`, not five library directories. A runnable page anywhere needs a target, or an `UNTESTED` entry with a reason. Two pages join `UNTESTED`: the contributor pages whose `>>>` samples teach doctest syntax. Both were excluded from the catch-all before. The lint also ignores comments when it reads targets from `doc/BUILD.bazel`. - `doc/source/ray-contribute/ci.md`: the `docs-example-test` label now runs any changed page with a runnable example. The "feeds only a shared doctest target" case is gone, because no multi-page CPU prose target remains. The comment above the postmerge `doc: doctest` step in `.buildkite/others.rayci.yml` still calls `//doc:doctest` a single catch-all target. It's left for a later CI change so this PR stays docs-only. ### Target renames `//doc:doctest` becomes 8 per-page targets such as `//doc:source/ray-references/glossary`. The catch-all step runs with the test DB disabled, so no flaky-test history is lost. Data's 12 empty targets disappear. ## Duplicate check No open PR covers this. The adjacent work is #66809, which split the other libraries' targets, and #66974, which this PR builds on. #66809 changes only the Core, RLlib, Serve, Train, and Tune targets. ## Testing - `./ci/lint/lint.sh doc_prose_doctest_targets` passes: "74 listed pages; every runnable page is accounted for." On scratch copies of the tree, each new failure mode fires: a runnable unlisted page outside the library directories, a catch-all page dropped from BUILD, and an empty Data page listed. - `rayci test-rules` (rayci v0.48.0, built from source) passes on this branch. This PR doesn't change the rules files. - `bazel query 'attr(tags, "doctest", tests(//doc:all))'` lists 72 targets. The `team:none` query lists the 8 catch-all pages. - `bazel run //ci/ray_ci/doc:cmd_doc_example_targets -- doc/source/ray-references/glossary.md doc/source/data/benchmark.md doc/source/data/loading-data.md` selects `//doc:source/ray-references/glossary` under team `none` and `//doc:source/data/loading-data` under `data`, and reports "No test names this file" for `benchmark.md`. - `buildifier` and `pre-commit run` on all changed files pass. - Not run locally: the doctests themselves. Each page runs the same files with the same plugin as before, now one page per target. The postmerge build and a `docs-example-test` labeled run are the checks. AI assistance (Claude Code) was used to write this change. 🤖 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]>
…enforced) (#67017) ## Why are these changes needed? This PR adds Vale terminology rules for Ray Tune docs ahead of a style pass over those pages. It follows the pattern from #65239 (KubeRay), #66236 (RLlib), #66640 (Ray Core), and #66885 (Ray Train). Every rule is warn-level and **doesn't run in CI yet**. Registering the config lets contributors run `vale doc/source/tune/` by hand during the style pass. Builds on #67015 (merged), which renamed the Tune tutorials landing and hyphenated page slugs. The style pass PRs stacked on this one edit pages under those final names. ## What's here - **`.vale/styles/Tune/Terms.yml`:** case-sensitive `substitution` swaps at `level: warning`, each safe to apply without judgment, so the file sets `action: replace`. It spells out abbreviations in prose: `search alg`, `config dict`, `trial dir`, and `experiment dir`. The arguments and attributes keep code style. - **`.vale/styles/Tune/Capitalization.yml`:** title-cased generic nouns, such as `Search Algorithm`, `Trial Scheduler`, `Function API`, and `Bayesian Optimization`, plus `Trainable` written as the concept. Applying any of these takes judgment, so this rule has no replace action: - Lowercasing would also drop the capital at the start of a heading or sentence, which has to stay. - A bare "Trainable" in prose is often the class, which needs code style rather than lowercase. The rule's keys carry a preceding word, such as `the Trainable` and `your Trainable`, and leave the decision to a person. - "Bayesian Optimization" sometimes names the `bayesian-optimization` package rather than the technique. - **"Scheduler" is deliberately not a rule.** Ray Core and Kubernetes both have schedulers. The guide asks for "trial scheduler" where a page discusses more than one kind, and the rule flags only the title-cased `Trial Scheduler`. - **Accept lists:** - New `Tune` vocabulary: `trainable(s)`, `syncer(s)`, the search libraries `Hyperopt`, `Optuna`, `Nevergrad`, `BayesOpt`, `ZOOpt`, `HEBO`, and `Ax`, and the algorithm names `Hyperband`, `ASHA`, `BOHB`, `PBT`, `PB2`, and `TPE`. - `General` gains cross-library words: `docstring(s)`, `traceback(s)`, `runtimes`, `errored`, and `underperforming`. - Casing-only fixes such as `HyperOpt` and `HyperBand` come from the accept list driving `Vale.Terms` rather than from a swap, so no token alerts twice. - **`.vale.ini`:** registers `Tune` on the `Vocab` line and adds a `[doc/source/tune/**/*.{md,rst}]` section with `Vale, Google, Ray, Tune`, which mirrors the Train block. - **`writing-style.md`:** a "Writing Ray Tune docs" section with a terms table. Both Tune rules link to it through the `ray-tune-docs-style` label. The section also separates "trial" from "experiment," which the current prose uses loosely. An experiment is one `Tuner.fit()` call, and a trial is one run of the trainable with one hyperparameter configuration. No prose under `doc/source/tune/` changes here. The style pass that fixes the alerts follows in separate PRs stacked on this one. ## Duplicate check No open PR adds Ray Tune Vale rules. I searched open `ray-project/ray` PRs for `vale tune`, `writing-style.md`, and Tune docs titles. The hits are #66809, my own CI change with no Vale or style-guide edits, #65707, a KubeRay docs change, #64137, a Ray Core NIXL guide, and #67015, the rename this work builds on (now merged). ## Testing Commands, run from the repo root: ```bash vale --output=JSON doc/source/tune/ vale --output=line doc/source/ # on the base branch and on this branch, diffed pre-commit run --files <changed files> ``` Results with Vale 3.12.0: - **`doc/source/tune/`:** total alerts go from 1,239 to 1,437. Most of the increase is the shared `Ray` style now applying to Tune. `Tune.Capitalization` raises 118 alerts and `Tune.Terms` raises 1, all in title-cased concept nouns or spelled-out abbreviations. `Vale.Spelling` drops from 88 to 50. No position alerts twice across `Vale.Terms`, `Vale.Spelling`, and `Tune.*`. - **Two alert sources the style pass should handle rather than suppress:** - Library names in `api/suggestion.rst` headings, such as `Optuna (tune.search.optuna.OptunaSearch)`, now alert under `Vale.Terms` on the lowercase module segment. The module path belongs in code style. - `tutorials/tune-lifecycle.md` alerts on `ERRORED`, which it lists as a trial status. The source defines the status as `ERROR` (`Trial.ERROR` in `python/ray/tune/experiment/trial.py`), so that's a doc correction. - **Rule check against the new guide table:** linting the table rows fires `Vale.Terms` on `HyperBand`, `HyperOpt`, `hyperopt`, and `AX` in the "Not" column, as intended, the same as the Train table. - **Other scopes:** compared alert by alert across all of `doc/source` outside `tune/`, the only change is 17 removed alerts. They're false positives on `runtimes`, `errored`, `docstring`, `traceback`, and `Hyperopt` in Core, KubeRay, Serve, Train, observability, and contributor pages, plus one `Google.Parens` alert in `kuberay/user-guides/configuring-ippr.md:281` that the accept list now shadows. No new alerts. - **pre-commit:** passed on the changed files. - **Not run locally:** the Sphinx build. The only `doc/source` change is one new section and label in `writing-style.md`. The RtD preview covers it. Prepared with AI assistance (Claude Code). Draft until the submitter has 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]>
…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>
Why are these changes needed?
With #66806, the
docs-example-testlabel runs only per-file doc test targets. Prose outside Ray Data sits in onedoctest()target per library, so the label can't run a changed Core, RLlib, Serve, or Train page. This PR splits those targets into per-file targets. Pages with nothing runnable drop out instead of becoming targets that pass without testing anything, becausebazel/pytest_wrapper.pyturns an empty collection into a pass.Decision for CI reviewers: what the routing costs
Splitting the targets also means deciding how prose reaches the opt-in step. This PR routes all prose under
doc/source/todoc_example. The alternative is a rule that names each page with a per-file target. That costs no compute, but it moves every page rename, move, or page gaining or losing a runnable block intotest.rules.txt, which only@ray-project/ray-cican approve. With #67003 that list grows to about 70 pages, during a docs rename campaign. Routing all prose keeps those edits indoc/BUILD.bazel, under the/doc/CODEOWNERS rule.The cost. rayci marks a selected step's
depends_onchain before Buildkite evaluates the step'sif:label guard, and wanda image steps can't takeif:. So every build of a PR that touches prose underdoc/source/schedules the opt-in step's 5 Python 3.10 image jobs,oss-ci-base_test,oss-ci-base_build,doctestbuild,ray-core-build, andray-dashboard-build, even though the step itself is dropped. They're expected to be cache hits. The count comes from simulating PR builds with rayci v0.48.0. Master already pays this today for Ray Data prose, which this rule replaces.How often. Of the 403 PRs merged from 2026-09-16 to 2026-10-13, 111 touched prose under
doc/source/, about 28 a week. For most of them the images already build for other reasons. 34, about 8 a week, changed nothing butdoc/prose and images, so the 5 jobs are pure added cost on every build of those PRs.Any of these answers leaves something worth merging:
alwaystag and thedoc_exampleprose rule is deleted.doc-1708-per-file-doctests-literalbranchtest.rules.txt.The
doc-1708-per-file-doctests-literalbranch is this PR's previous head, so switching back is a reset, not a rewrite.Which pages get a target
I ran real pytest collection for every prose page under the five library directories, with the pinned
pytest==7.4.4and theray-project/pytest-sphinxfork, as thedoctestmacro does:A page whose only blocks are
:skipif: Truecollects nothing. That's why Train has 10 pages withtestcodeblocks that never run. An rST.. testcode::directive inside a MyST.mdpage isn't collected either;core/internals/streaming-generator.mdand one block intrain/user-guides/experiment-tracking.mdhit this.Changes
doc/BUILD.bazel:doctest[core],[rllib],[serve], and[train]becomedoctest_each()over an explicit page list. Existing excludes,envsettings, RLlib'scartpole-v1_largedata dependency, and the GPU targets are unchanged.doctest[tune]collected nothing and is removed..buildkite/test.rules.txt: the Ray Data prose rule,doc/source/data/*.mdand*.rst, becomesdoc/source/*.mdand*.rst, still after the API reference rules and ahead of the prose skip rule. Prose that Sphinx never renders as a page, underdoc/source/_*anddoc/source/templates/, gets a skip rule ahead of it. API reference pages match thedoc_apidirectory rule first and emit onlydoc_api, so the label doesn't run doctests on RLlib's twoapi/pages. The post-merge build still does. The rules file names no individual page, so renaming or removing a page never needs a.buildkite/edit.doc_prose_doctest_targets(doc/test_prose_doctest_targets.py), in thelint-small-prosematrix so prose-only PRs run it. With explicit lists, a runnable block added to an unlisted page would otherwise run nowhere, not even post-merge. The check fails when a library page has a runnable example but no target, or when a listed page has nothing runnable. It's stdlib-only because the forge image has no pytest. On the current tree its rule matches real pytest-sphinx collection exactly, 49 of 49 pages.doc/source/ray-contribute/ci.mdanddoc/AGENTS.md: the label now runs Core, RLlib, Serve, and Train pages, not only Ray Data, andci.mdstates the image-job cost of a prose change.doc/source/ray-contribute/ci.mdalso lists the lint steps that run on a prose-only change. The page named three, and two of them, the README check and the Vale style check, no longer run on prose. It now lists the four that do, including the new check.Target renames
The four library-wide targets become per-file targets named after their pages, for example
//doc:source/core/actors/named-actors. The postmerge//doc/...doctest pass picks them up automatically. Flaky-test history and release-blocker auto-open are keyed by target name, so the old names' history doesn't carry over. Nothing in this repo refers to the old names except synthetic fixtures inci/ray_ci/doc/test_doc_example_targets.py.Duplicate check
No open PR covers this. Searches for
doctest_each, "per-file doctest", "doctest targets doc/BUILD.bazel", anddoctest[tune]return only #66806, which this PR builds on.Testing
rayci test-rules(rayci v0.48.0, the version in.rayciversion, built from source): all 198 cases intest.rules.test.txtandalways.rules.test.txtpass. A deliberately wrong expectation fails, so the check is real. New cases cover a library page without a per-file target, the root index, a non-library page, a KubeRay page, and the three skipped internal prose paths.ci/pipeline/determine_tests_to_run.py) gives the expected tags for a sample of library and KubeRay prose, API pages, internal prose, package and repo-root READMEs, images, adoc_codescript, andconf.py. Only the prose emitsdoc_example. API pages emit onlydoc_api.pytest ci/pipeline/test_doc_api_rules_sync.pyandpytest ci/ray_ci/doc/test_doc_example_targets.pypass.bazel query 'attr(tags, "doctest", tests(//doc:all))'lists all 43 new per-file targets.bazel run //ci/ray_ci/doc:cmd_doc_example_targets -- <pages>selects the matching per-file target for a Core, Train, RLlibapi/, and Serve page, and reports "No test names this file" for an excluded page../ci/lint/lint.sh doc_prose_doctest_targetspasses. Each failure mode fires when the tree is edited to trigger it: an unlisted runnable page, a page dropped from BUILD, and a listed page with nothing runnable.torch, missingCUDA_VISIBLE_DEVICESon macOS, and the nightly wheel's usage-stats banner showing up intestoutput. The banner pages fail the same way when run in one shared session, so the split doesn't cause them.doctestbuildimage. Adocs-example-testlabeled run on this PR is the check for those.AI assistance (Claude Code) was used to write this change.
🤖 Generated with Claude Code