From 431d2808db717e69ab3cf798e7d4716c5725573a Mon Sep 17 00:00:00 2001 From: Balaji Veeramani Date: Tue, 25 Jul 2023 19:57:28 -0500 Subject: [PATCH] [Docs] De-flake doctests (#37743) Signed-off-by: Balaji Veeramani --- bazel/python.bzl | 1 + doc/source/data/key-concepts.rst | 5 +++-- python/ray/data/read_api.py | 9 +++++++++ .../train/tensorflow/tensorflow_checkpoint.py | 16 +++++++++++----- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/bazel/python.bzl b/bazel/python.bzl index 9f60dddd47bd..b341512610db 100644 --- a/bazel/python.bzl +++ b/bazel/python.bzl @@ -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, diff --git a/doc/source/data/key-concepts.rst b/doc/source/data/key-concepts.rst index 66b915777504..5f8e7dd69db5 100644 --- a/doc/source/data/key-concepts.rst +++ b/doc/source/data/key-concepts.rst @@ -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'] diff --git a/python/ray/data/read_api.py b/python/ray/data/read_api.py index dc2d79ae8cf5..3b6c8a81bb4e 100644 --- a/python/ray/data/read_api.py +++ b/python/ray/data/read_api.py @@ -1635,6 +1635,15 @@ def read_sql( For examples of reading from larger databases like MySQL and PostgreSQL, see :ref:`Reading from SQL Databases `. + .. testcode:: + :hide: + + import os + try: + os.remove("example.db") + except OSError: + pass + .. testcode:: import sqlite3 diff --git a/python/ray/train/tensorflow/tensorflow_checkpoint.py b/python/ray/train/tensorflow/tensorflow_checkpoint.py index d561c80b7b94..ecdeed18148c 100644 --- a/python/ray/train/tensorflow/tensorflow_checkpoint.py +++ b/python/ray/train/tensorflow/tensorflow_checkpoint.py @@ -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(