Skip to content

Commit

Permalink
[Docs] De-flake doctests (#37743)
Browse files Browse the repository at this point in the history
Signed-off-by: Balaji Veeramani <[email protected]>
  • Loading branch information
bveeramani authored Jul 26, 2023
1 parent 6048b6b commit 431d280
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions bazel/python.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def doctest(files, gpu = False, name="doctest", deps=[], srcs=[], data=[], args=
"--doctest-modules",
"--doctest-glob='*.md'",
"-c=$(location //bazel:conftest.py)",
"--disable-warnings",
"-v"
] + args + ["$(location :%s)" % file for file in files],
data = ["//bazel:conftest.py"] + files + data,
Expand Down
5 changes: 3 additions & 2 deletions doc/source/data/key-concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,11 @@ or remote filesystems.

transformed_ds.write_parquet("/tmp/iris")

print(sorted(os.listdir("/tmp/iris")))
print(os.listdir("/tmp/iris"))

.. testoutput::

:options: +MOCK

['..._000000.parquet', '..._000001.parquet']


Expand Down
9 changes: 9 additions & 0 deletions python/ray/data/read_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,15 @@ def read_sql(
For examples of reading from larger databases like MySQL and PostgreSQL, see
:ref:`Reading from SQL Databases <reading_sql>`.
.. testcode::
:hide:
import os
try:
os.remove("example.db")
except OSError:
pass
.. testcode::
import sqlite3
Expand Down
16 changes: 11 additions & 5 deletions python/ray/train/tensorflow/tensorflow_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,20 @@ def from_model(
A :py:class:`TensorflowCheckpoint` containing the specified model.
Examples:
.. testcode::
.. testcode::
from ray.train.tensorflow import TensorflowCheckpoint
import tensorflow as tf
from ray.train.tensorflow import TensorflowCheckpoint
import tensorflow as tf
model = tf.keras.applications.resnet.ResNet101()
checkpoint = TensorflowCheckpoint.from_model(model)
.. testoutput::
:options: +MOCK
:hide:
model = tf.keras.applications.resnet.ResNet101()
checkpoint = TensorflowCheckpoint.from_model(model)
... # Model may or may not be downloaded
"""
checkpoint = cls.from_dict(
Expand Down

0 comments on commit 431d280

Please sign in to comment.