From 5984f1ec6f49d8a2e5ae3a362f9c71efe1c8c36e Mon Sep 17 00:00:00 2001 From: Balaji Veeramani Date: Mon, 21 Nov 2022 21:00:42 -0800 Subject: [PATCH 1/8] Rename `"model_state_dict"` to `"model"` --- .../train/examples/pytorch/tune_cifar_torch_pbt_example.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/ray/train/examples/pytorch/tune_cifar_torch_pbt_example.py b/python/ray/train/examples/pytorch/tune_cifar_torch_pbt_example.py index 71472227a249..46ea6ab3947a 100644 --- a/python/ray/train/examples/pytorch/tune_cifar_torch_pbt_example.py +++ b/python/ray/train/examples/pytorch/tune_cifar_torch_pbt_example.py @@ -83,7 +83,7 @@ def train_func(config): checkpoint_dict = session.get_checkpoint().to_dict() # Load in model - model_state = checkpoint_dict["model_state_dict"] + model_state = checkpoint_dict["model"] model.load_state_dict(model_state) # Load in optimizer @@ -146,7 +146,7 @@ def train_func(config): checkpoint = Checkpoint.from_dict( { "epoch": epoch, - "model_state_dict": model.state_dict(), + "model": model.state_dict(), "optimizer_state_dict": optimizer.state_dict(), } ) From 8f58490187070bc8122629f97f9c9ff07b716f85 Mon Sep 17 00:00:00 2001 From: Balaji Veeramani Date: Mon, 21 Nov 2022 21:00:49 -0800 Subject: [PATCH 2/8] Revert "Rename `"model_state_dict"` to `"model"`" This reverts commit 5984f1ec6f49d8a2e5ae3a362f9c71efe1c8c36e. --- .../train/examples/pytorch/tune_cifar_torch_pbt_example.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/ray/train/examples/pytorch/tune_cifar_torch_pbt_example.py b/python/ray/train/examples/pytorch/tune_cifar_torch_pbt_example.py index 46ea6ab3947a..71472227a249 100644 --- a/python/ray/train/examples/pytorch/tune_cifar_torch_pbt_example.py +++ b/python/ray/train/examples/pytorch/tune_cifar_torch_pbt_example.py @@ -83,7 +83,7 @@ def train_func(config): checkpoint_dict = session.get_checkpoint().to_dict() # Load in model - model_state = checkpoint_dict["model"] + model_state = checkpoint_dict["model_state_dict"] model.load_state_dict(model_state) # Load in optimizer @@ -146,7 +146,7 @@ def train_func(config): checkpoint = Checkpoint.from_dict( { "epoch": epoch, - "model": model.state_dict(), + "model_state_dict": model.state_dict(), "optimizer_state_dict": optimizer.state_dict(), } ) From de05655b003c96b3cb9194e6cf21155e04ee22f5 Mon Sep 17 00:00:00 2001 From: Balaji Veeramani Date: Thu, 26 Jan 2023 11:56:49 -0800 Subject: [PATCH 3/8] Update annotations.py Signed-off-by: Balaji Veeramani --- python/ray/util/annotations.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/ray/util/annotations.py b/python/ray/util/annotations.py index 9996b092fcab..f7b93746f910 100644 --- a/python/ray/util/annotations.py +++ b/python/ray/util/annotations.py @@ -49,7 +49,7 @@ def PublicAPI(*args, **kwargs): def wrap(obj): if stability in ["alpha", "beta"]: message = ( - f"PublicAPI ({stability}): This API is in {stability} " + f"**PublicAPI ({stability}):** This API is in {stability} " "and may change before becoming stable." ) else: @@ -80,7 +80,8 @@ def DeveloperAPI(*args, **kwargs): def wrap(obj): _append_doc( - obj, message="DeveloperAPI: This API may change across minor Ray releases." + obj, + message="**DeveloperAPI:** This API may change across minor Ray releases.", ) _mark_annotated(obj) return obj From fd2ff917e1cc3258554c56b283db8e8e155cff9a Mon Sep 17 00:00:00 2001 From: Balaji Veeramani Date: Thu, 26 Jan 2023 12:02:30 -0800 Subject: [PATCH 4/8] Revert "Update annotations.py" This reverts commit de05655b003c96b3cb9194e6cf21155e04ee22f5. Signed-off-by: Balaji Veeramani --- python/ray/util/annotations.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python/ray/util/annotations.py b/python/ray/util/annotations.py index f7b93746f910..9996b092fcab 100644 --- a/python/ray/util/annotations.py +++ b/python/ray/util/annotations.py @@ -49,7 +49,7 @@ def PublicAPI(*args, **kwargs): def wrap(obj): if stability in ["alpha", "beta"]: message = ( - f"**PublicAPI ({stability}):** This API is in {stability} " + f"PublicAPI ({stability}): This API is in {stability} " "and may change before becoming stable." ) else: @@ -80,8 +80,7 @@ def DeveloperAPI(*args, **kwargs): def wrap(obj): _append_doc( - obj, - message="**DeveloperAPI:** This API may change across minor Ray releases.", + obj, message="DeveloperAPI: This API may change across minor Ray releases." ) _mark_annotated(obj) return obj From 2952150954056f709cf592cf4094825bd50c4a1c Mon Sep 17 00:00:00 2001 From: Balaji Veeramani Date: Mon, 24 Jul 2023 17:04:14 -0700 Subject: [PATCH 5/8] Initial commit Signed-off-by: Balaji Veeramani --- python/ray/data/read_api.py | 9 +++++++++ .../train/tensorflow/tensorflow_checkpoint.py | 16 +++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) 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..1c99c7c8bfbd 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) + + .. testcode:: + :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( From cb9c0c02bdaa5693dab4e8f10b439ad93387fd8c Mon Sep 17 00:00:00 2001 From: Balaji Veeramani Date: Mon, 24 Jul 2023 17:11:04 -0700 Subject: [PATCH 6/8] Update key-concepts.rst Signed-off-by: Balaji Veeramani --- doc/source/data/key-concepts.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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'] From e0dea08577f58998b0d591c827ed2b93a8fa249b Mon Sep 17 00:00:00 2001 From: Balaji Veeramani Date: Mon, 24 Jul 2023 17:15:09 -0700 Subject: [PATCH 7/8] Update python.bzl Signed-off-by: Balaji Veeramani --- bazel/python.bzl | 1 + 1 file changed, 1 insertion(+) 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, From 3d41f31a56d8e5bb9434773b61ac8f4868a69aea Mon Sep 17 00:00:00 2001 From: Balaji Veeramani Date: Mon, 24 Jul 2023 18:14:07 -0700 Subject: [PATCH 8/8] Update tensorflow_checkpoint.py Signed-off-by: Balaji Veeramani --- python/ray/train/tensorflow/tensorflow_checkpoint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ray/train/tensorflow/tensorflow_checkpoint.py b/python/ray/train/tensorflow/tensorflow_checkpoint.py index 1c99c7c8bfbd..ecdeed18148c 100644 --- a/python/ray/train/tensorflow/tensorflow_checkpoint.py +++ b/python/ray/train/tensorflow/tensorflow_checkpoint.py @@ -75,7 +75,7 @@ def from_model( model = tf.keras.applications.resnet.ResNet101() checkpoint = TensorflowCheckpoint.from_model(model) - .. testcode:: + .. testoutput:: :options: +MOCK :hide: