Skip to content

Commit

Permalink
[Data] Deprecate iter_tf_batches (ray-project#48693)
Browse files Browse the repository at this point in the history
<!-- Thank you for your contribution! Please review
https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before
opening a pull request. -->

<!-- Please add a reviewer to the assignee section when you create a PR.
If you don't have the access to it, we will shortly find a reviewer and
assign them to your PR. -->

## Why are these changes needed?

<!-- Please give a short summary of the change and the problem this
solves. -->

We recommend `to_tf` over `iter_tf_batches`. To avoid confusion, we
shouldn’t have two similar APIs, especially if we always prefer one.

## Related issue number

<!-- For example: "Closes ray-project#1234" -->

## Checks

- [ ] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [ ] I've run `scripts/format.sh` to lint the changes in this PR.
- [ ] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [ ] I've added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [ ] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [ ] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

---------

Signed-off-by: Balaji Veeramani <bveeramani@berkeley.edu>
  • Loading branch information
bveeramani authored and JP-sDEV committed Nov 14, 2024
1 parent 48e6c65 commit 42dcd6a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
11 changes: 11 additions & 0 deletions doc/source/data/api/dataset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion python/ray/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4008,7 +4008,7 @@ def iter_torch_batches(
)

@ConsumptionAPI
@PublicAPI(api_group=CD_API_GROUP)
@Deprecated
def iter_tf_batches(
self,
*,
Expand Down Expand Up @@ -4081,6 +4081,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,
Expand Down
5 changes: 5 additions & 0 deletions python/ray/data/tests/test_consumption.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,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+"
)
Expand Down

0 comments on commit 42dcd6a

Please sign in to comment.