From 54d5c754c9ae1df1a5511ea377cd6e6a76716022 Mon Sep 17 00:00:00 2001 From: Balaji Veeramani Date: Mon, 21 Nov 2022 21:34:18 -0800 Subject: [PATCH 1/2] Update dataset.py --- python/ray/data/dataset.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/ray/data/dataset.py b/python/ray/data/dataset.py index 96f031cf2c61..1c41823b65ed 100644 --- a/python/ray/data/dataset.py +++ b/python/ray/data/dataset.py @@ -4203,6 +4203,12 @@ def __len__(self) -> int: "This may be an expensive operation." ) + def __iter__(self): + raise TypeError( + "`Dataset` objects aren't iterable. If you want to inspect records, call " + "`ds.take()`. If you want to transform records, call `ds.map_batches()`." + ) + def _block_num_rows(self) -> List[int]: get_num_rows = cached_remote_fn(_get_num_rows) return ray.get([get_num_rows.remote(b) for b in self.get_internal_block_refs()]) From ad44905b09828b4bcff8cb04c0aefa8bee919e2b Mon Sep 17 00:00:00 2001 From: Balaji Veeramani Date: Wed, 7 Dec 2022 12:45:15 -0800 Subject: [PATCH 2/2] Update dataset.py Signed-off-by: Balaji Veeramani --- python/ray/data/dataset.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/ray/data/dataset.py b/python/ray/data/dataset.py index 1c41823b65ed..8788bd5d2deb 100644 --- a/python/ray/data/dataset.py +++ b/python/ray/data/dataset.py @@ -4205,8 +4205,9 @@ def __len__(self) -> int: def __iter__(self): raise TypeError( - "`Dataset` objects aren't iterable. If you want to inspect records, call " - "`ds.take()`. If you want to transform records, call `ds.map_batches()`." + "`Dataset` objects aren't iterable. To iterate records, call " + "`ds.iter_rows()` or `ds.iter_batches()`. For more information, read " + "https://docs.ray.io/en/latest/data/consuming-datasets.html." ) def _block_num_rows(self) -> List[int]: