Repository navigation
[data] Convert never-run sink and reader docstring examples to +SKIP_EXAMPLE doctests - #67209
Merged
Merged
Conversation
…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]>
Contributor
There was a problem hiding this comment.
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.
matthewdeng
approved these changes
Oct 20, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Converts the never-run
.. testcode::/:skipif: Trueexamples for Ray Data's external-service sinks and the Hive reader to>>>doctests. Each docstring is flagged once with the docstring-level# doctest: +SKIP_EXAMPLEfrom #66753. The change touches only docstrings:python/ray/data/dataset.py: 10 blocks inwrite_iceberg,write_delta,write_webdataset,write_snowflake,write_mongo,write_bigquery,write_clickhouse,write_turbopuffer(2 blocks), andwrite_kafka.python/ray/data/read_api.py: theread_hiveexample.python/ray/data/_internal/datasource/turbopuffer_datasink.py: the 3TurbopufferDatasinkexamples.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:
Datasetclass docstring runs its example now. That docstring also holds 10 runnable>>>examples, and+SKIP_EXAMPLEskips 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")andwrite_csv("s3://bucket/output"), carry# doctest: +SKIP. Therangeandfrom_itemslines 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: Trueblocks left indataset.pyafter 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, andtestcode skipif data. #67202 and #67207 are my own and convert other methods indataset.py. Two open PRs edit text these examples sit next to, so whichever PR lands second needs a small rebase:write_icebergexample's content, adding a REST catalog write. This PR changes only the example's form.write_clickhouse, next to its example.#67114 and #67168 change
read_api.pybut not theread_hivedocstring 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.pyon the three files, in an aarch64 image with the Ray nightly at093faf5583eand 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_EXAMPLEand 5 for an omitted library (torch, torchvision, TensorFlow,tensorflow_datasets). All 13 converted docstrings reportSKIP (+SKIP_EXAMPLE), andDatasetandDataset.write_csvpass. The one failure isread_videos, which this PR doesn't touch. It needsdecord, which has no aarch64 wheel. The run installeddatasketches,Pillow,crc32c,soundfile, andfastavro, which the base image lacks. Without them, six more untouched docstrings fail on the missing import.>>>example in the three files compiles with the stockdoctestparser onceSKIP_EXAMPLEis registered.pre-commit run --fileson the three files: all hooks pass, including ruff, black, pydoclint, and the Ray docstyle check.The PR carries the
docstring-onlylabel, and its commit carries an@rtd-buildline for the Read the Docs preview.AI assistance (Claude Code) was used for this PR.
🤖 Generated with Claude Code