From 6b8ec1730ee592079bbcda77aad8398b61a08621 Mon Sep 17 00:00:00 2001 From: Balaji Veeramani Date: Mon, 11 Nov 2024 12:35:10 -0800 Subject: [PATCH 1/2] Initial commit Signed-off-by: Balaji Veeramani --- python/ray/data/dataset.py | 7 ++++++- python/ray/data/tests/test_consumption.py | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/python/ray/data/dataset.py b/python/ray/data/dataset.py index d4c8d887da34..5e5a124a1c61 100644 --- a/python/ray/data/dataset.py +++ b/python/ray/data/dataset.py @@ -4018,7 +4018,7 @@ def iter_torch_batches( ) @ConsumptionAPI - @PublicAPI(api_group=CD_API_GROUP) + @Deprecated def iter_tf_batches( self, *, @@ -4091,6 +4091,11 @@ def iter_tf_batches( :meth:`Dataset.iter_batches` Call this method to manually convert your data to TensorFlow tensors. """ # noqa: E501 + warnings.warn( + "`iter_tf_batches` is deprecated and will be removed after May 2025. Use " + "`to_tf` instead.", + DeprecationWarning, + ) return self.iterator().iter_tf_batches( prefetch_batches=prefetch_batches, batch_size=batch_size, diff --git a/python/ray/data/tests/test_consumption.py b/python/ray/data/tests/test_consumption.py index b4e63d20a7cf..4e638cb09667 100644 --- a/python/ray/data/tests/test_consumption.py +++ b/python/ray/data/tests/test_consumption.py @@ -1259,6 +1259,11 @@ def test_union(ray_start_regular_shared): assert ds2.count() == 210 +def test_iter_tf_batches_emits_deprecation_warning(ray_start_regular_shared): + with pytest.warns(DeprecationWarning): + ray.data.range(1).iter_tf_batches() + + @pytest.mark.skipif( sys.version_info >= (3, 12), reason="No tensorflow for Python 3.12+" ) From e22db577bb3642b123159fe89caef3769deadd73 Mon Sep 17 00:00:00 2001 From: Balaji Veeramani Date: Tue, 12 Nov 2024 12:22:27 -0800 Subject: [PATCH 2/2] Fix docs Signed-off-by: Balaji Veeramani --- doc/source/data/api/dataset.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/source/data/api/dataset.rst b/doc/source/data/api/dataset.rst index 01275066dd26..d803d313f674 100644 --- a/doc/source/data/api/dataset.rst +++ b/doc/source/data/api/dataset.rst @@ -23,3 +23,14 @@ Developer API block.BlockExecStats block.BlockMetadata block.BlockAccessor + +Deprecated API +-------------- + +.. currentmodule:: ray.data + +.. autosummary:: + :nosignatures: + :toctree: doc/ + + Dataset.iter_tf_batches \ No newline at end of file