Skip to content

[data] Convert never-run sink and reader docstring examples to +SKIP_EXAMPLE doctests - #67209

Merged
dstrodtman merged 1 commit into
masterfrom
doc-1854-data-sink-skip-example
Oct 21, 2026
Merged

dstrodtman merged 1 commit into
masterfrom
doc-1854-data-sink-skip-example

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Description

Converts the never-run .. testcode:: / :skipif: True examples for Ray Data's external-service sinks and the Hive reader to >>> doctests. Each docstring is flagged once with the docstring-level # doctest: +SKIP_EXAMPLE from #66753. The change touches only docstrings:

  • python/ray/data/dataset.py: 10 blocks in write_iceberg, write_delta, write_webdataset, write_snowflake, write_mongo, write_bigquery, write_clickhouse, write_turbopuffer (2 blocks), and write_kafka.
  • python/ray/data/read_api.py: the read_hive example.
  • python/ray/data/_internal/datasource/turbopuffer_datasink.py: the 3 TurbopufferDatasink examples.

Each example needs a service, credentials, or a bucket that CI doesn't have, so they stay render-only, as before. The flag is stripped at render time by both Sphinx (trim_doctest_flags) and griffe. The conversion follows the rules from #67080: same code in the same order, blank lines inside a block dropped, and top-level comments as >>> # lines.

Two docstrings needed something other than the flag:

  • The Dataset class docstring runs its example now. That docstring also holds 10 runnable >>> examples, and +SKIP_EXAMPLE skips a whole docstring, so it would have stopped them from running. Instead, only the two lines that use placeholder paths, read_parquet("s3://bucket/path") and write_csv("s3://bucket/output"), carry # doctest: +SKIP. The range and from_items lines run.
  • write_csv's example had an unterminated string, "s3://bucket/folder/). It was already +SKIP, so nothing ever parsed it. The closing quote is now in place, so the docstring parses with the stock doctest parser.

The :skipif: True blocks left in dataset.py after this PR are in #67202 (join) and #67207 (streaming_split).

Related issues

Related to #66753, #67080, #67202, and #67207.

Additional information

Not a duplicate. I searched open PRs for each method name, turbopuffer, SKIP_EXAMPLE, and testcode skipif data. #67202 and #67207 are my own and convert other methods in dataset.py. Two open PRs edit text these examples sit next to, so whichever PR lands second needs a small rebase:

#67114 and #67168 change read_api.py but not the read_hive docstring example.

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 with the Ray nightly at 093faf5583e and the changed files mounted over the installed ones. None of the three files changed between that commit and this PR's base. Result: 85 docstrings run and 1 failed, with 16 skipped for +SKIP_EXAMPLE and 5 for an omitted library (torch, torchvision, TensorFlow, tensorflow_datasets). All 13 converted docstrings report SKIP (+SKIP_EXAMPLE), and Dataset and Dataset.write_csv pass. The one failure is read_videos, which this PR doesn't touch. It needs decord, which has no aarch64 wheel. The run installed datasketches, Pillow, crc32c, soundfile, and fastavro, which the base image lacks. Without them, six more untouched docstrings fail on the missing import.
  • Every >>> example in the three files compiles with the stock doctest parser once SKIP_EXAMPLE is registered.
  • 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

…EXAMPLE doctests

Convert the :skipif: True testcode blocks in the Dataset write methods
that need an external service (write_iceberg, write_delta,
write_webdataset, write_snowflake, write_mongo, write_bigquery,
write_clickhouse, write_turbopuffer, write_kafka), read_hive, and
TurbopufferDatasink to >>> doctests, each docstring flagged once with
+SKIP_EXAMPLE.

The Dataset class docstring also holds runnable examples, so its block
runs, with +SKIP only on the two lines that use placeholder S3 paths.
Also close the unterminated string in the write_csv example.

@rtd-build

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman requested a review from a team as a code owner October 20, 2026 20:32
@dstrodtman dstrodtman added data Ray Data-related issues go add ONLY when ready to merge, run all tests docstring-only Skip heavy library tests for Ray API docstring edits. labels Oct 20, 2026

@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 refactors documentation examples across several files, converting Sphinx testcode blocks into standard Python doctests using the >>> syntax with appropriate skip directives. Additionally, it fixes a syntax error in a doctest string literal within dataset.py. There are no review comments to address, and I have no further feedback to provide.

@dstrodtman
dstrodtman merged commit 3374174 into master Oct 21, 2026
5 checks passed
@dstrodtman
dstrodtman deleted the doc-1854-data-sink-skip-example branch October 21, 2026 10:40
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

2 participants