python/ray/data/dataset.py
def repeat(self, times: Optional[int] = None) -> "DatasetPipeline[T]":
        """Convert this into a DatasetPipeline by looping over this dataset.

        Transformations prior to the call to ``repeat()`` are evaluated once.
        Transformations done on the returned pipeline are evaluated on each
        loop of the pipeline over the base dataset.

        Note that every repeat of the dataset is considered an "epoch" for
        the purposes of ``DatasetPipeline.iter_epochs()``.

        Examples:
            >>> import ray
            >>> # Infinite pipeline of numbers [0, 5)
            >>> ray.data.range(5).repeat().take() # doctest: +SKIP
            [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, ...]
            >>> # Can apply transformations to the pipeline.
            >>> ray.data.range(5).repeat().map(lambda x: -x).take() # doctest: +SKIP
            [0, -1, -2, -3, -4, 0, -1, -2, -3, -4, ...]
            >>> # Can shuffle each epoch (dataset) in the pipeline.
            >>> ray.data.range(5).repeat().random_shuffle().take() # doctest: +SKIP
            [2, 3, 0, 4, 1, 4, 0, 2, 1, 3, ...]

        Args:
            times: The number of times to loop over this dataset, or None
                to repeat indefinitely.
        """
        from ray.data.dataset_pipeline import DatasetPipeline
        from ray.data.impl.plan import _rewrite_read_stage

        ctx = DatasetContext.get_current()
        if self._plan.is_read_stage() and ctx.optimize_fuse_read_stages:
            blocks, _ = self._plan._get_source_blocks()
            blocks.clear()
            blocks, outer_stats, read_stage = _rewrite_read_stage(blocks)
        else:
            blocks = self._plan.execute()
            outer_stats = self._plan.stats()
            read_stage = None
        uuid = self._get_uuid()
        outer_stats.dataset_uuid = uuid

        if times is not None and times < 1:
            raise ValueError("`times` must be >= 1, got {}".format(times))

        class Iterator:
            def __init__(self, blocks):
                self._blocks = blocks
                self._i = 0

            def __next__(self) -> "Dataset[T]":
                if times and self._i >= times:
                    raise StopIteration
                epoch = self._i
                blocks = self._blocks
                self._i += 1

                def gen():
                    ds = Dataset(
                        ExecutionPlan(blocks, outer_stats, dataset_uuid=uuid),
                        epoch,
                        lazy=False,
                    )
                    ds._set_uuid(uuid)
                    return ds

                return gen

        class Iterable:
            def __init__(self, blocks):
                self._blocks = blocks

            def __iter__(self):
                return Iterator(self._blocks)

        pipe = DatasetPipeline(Iterable(blocks), length=times or float("inf"))
        if read_stage:
            pipe = pipe.foreach_window(
                lambda ds, read_stage=read_stage: Dataset(
                    ds._plan.with_stage(read_stage), ds._epoch, True
                )
            )
        return pipe
Convert this into a DatasetPipeline by looping over this dataset.

        Transformations prior to the call to ``repeat()`` are evaluated once.
        Transformations done on the returned pipeline are evaluated on each
        loop of the pipeline over the base dataset.

        Note that every repeat of the dataset is considered an "epoch" for
        the purposes of ``DatasetPipeline.iter_epochs()``.

        Examples:
            >>> import ray
            >>> # Infinite pipeline of numbers [0, 5)
            >>> ray.data.range(5).repeat().take() # doctest: +SKIP
            [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, ...]
            >>> # Can apply transformations to the pipeline.
            >>> ray.data.range(5).repeat().map(lambda x: -x).take() # doctest: +SKIP
            [0, -1, -2, -3, -4, 0, -1, -2, -3, -4, ...]
            >>> # Can shuffle each epoch (dataset) in the pipeline.
            >>> ray.data.range(5).repeat().random_shuffle().take() # doctest: +SKIP
            [2, 3, 0, 4, 1, 4, 0, 2, 1, 3, ...]

        Args:
            times: The number of times to loop over this dataset, or None
                to repeat indefinitely.
        
Convert this into a DatasetPipeline by looping over this dataset.
Transformations prior to the call to ``repeat()`` are evaluated once.
Transformations done on the returned pipeline are evaluated on each
loop of the pipeline over the base dataset.

Note that every repeat of the dataset is considered an "epoch" for
the purposes of ``DatasetPipeline.iter_epochs()``.
Convert this into a DatasetPipeline by looping over this dataset . Transformations prior to the call to ` ` repeat () ` ` are evaluated once . Transformations done on the returned pipeline are evaluated on each loop of the pipeline over the base dataset . Note that every repeat of the dataset is considered an " epoch " for the purposes of ` ` DatasetPipeline . iter_epochs () ` ` .
def repeat(self, times: Optional[int] = None) -> "DatasetPipeline[T]":
        from ray.data.dataset_pipeline import DatasetPipeline
        from ray.data.impl.plan import _rewrite_read_stage
        ctx = DatasetContext.get_current()
        if self._plan.is_read_stage() and ctx.optimize_fuse_read_stages:
            blocks, _ = self._plan._get_source_blocks()
            blocks.clear()
            blocks, outer_stats, read_stage = _rewrite_read_stage(blocks)
        else:
            blocks = self._plan.execute()
            outer_stats = self._plan.stats()
            read_stage = None
        uuid = self._get_uuid()
        outer_stats.dataset_uuid = uuid
        if times is not None and times < 1:
            raise ValueError("`times` must be >= 1, got {}".format(times))
        class Iterator:
            def __init__(self, blocks):
                self._blocks = blocks
                self._i = 0
            def __next__(self) -> "Dataset[T]":
                if times and self._i >= times:
                    raise StopIteration
                epoch = self._i
                blocks = self._blocks
                self._i += 1
                def gen():
                    ds = Dataset(
                        ExecutionPlan(blocks, outer_stats, dataset_uuid=uuid),
                        epoch,
                        lazy=False,
                    )
                    ds._set_uuid(uuid)
                    return ds
                return gen
        class Iterable:
            def __init__(self, blocks):
                self._blocks = blocks
            def __iter__(self):
                return Iterator(self._blocks)
        pipe = DatasetPipeline(Iterable(blocks), length=times or float("inf"))
        if read_stage:
            pipe = pipe.foreach_window(
                lambda ds, read_stage=read_stage: Dataset(
                    ds._plan.with_stage(read_stage), ds._epoch, True
                )
            )
        return pipe
def repeat ( self , times : Optional [ int ] = None ) -> "DatasetPipeline[T]" : from ray . data . dataset_pipeline import DatasetPipeline from ray . data . impl . plan import _rewrite_read_stage ctx = DatasetContext . get_current ( ) if self . _plan . is_read_stage ( ) and ctx . optimize_fuse_read_stages : blocks , _ = self . _plan . _get_source_blocks ( ) blocks . clear ( ) blocks , outer_stats , read_stage = _rewrite_read_stage ( blocks ) else : blocks = self . _plan . execute ( ) outer_stats = self . _plan . stats ( ) read_stage = None uuid = self . _get_uuid ( ) outer_stats . dataset_uuid = uuid if times is not None and times < 1 : raise ValueError ( "`times` must be >= 1, got {}" . format ( times ) ) class Iterator : def __init__ ( self , blocks ) : self . _blocks = blocks self . _i = 0 def __next__ ( self ) -> "Dataset[T]" : if times and self . _i >= times : raise StopIteration epoch = self . _i blocks = self . _blocks self . _i += 1 def gen ( ) : ds = Dataset ( ExecutionPlan ( blocks , outer_stats , dataset_uuid = uuid ) , epoch , lazy = False , ) ds . _set_uuid ( uuid ) return ds return gen class Iterable : def __init__ ( self , blocks ) : self . _blocks = blocks def __iter__ ( self ) : return Iterator ( self . _blocks ) pipe = DatasetPipeline ( Iterable ( blocks ) , length = times or float ( "inf" ) ) if read_stage : pipe = pipe . foreach_window ( lambda ds , read_stage = read_stage : Dataset ( ds . _plan . with_stage ( read_stage ) , ds . _epoch , True ) ) return pipe
Convert this into a DatasetPipeline by looping over this dataset.
Convert this into a DatasetPipeline by looping over this dataset .
"""Convert this into a DatasetPipeline by looping over this dataset.

        Transformations prior to the call to ``repeat()`` are evaluated once.
        Transformations done on the returned pipeline are evaluated on each
        loop of the pipeline over the base dataset.

        Note that every repeat of the dataset is considered an "epoch" for
        the purposes of ``DatasetPipeline.iter_epochs()``.

        Examples:
            >>> import ray
            >>> # Infinite pipeline of numbers [0, 5)
            >>> ray.data.range(5).repeat().take() # doctest: +SKIP
            [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, ...]
            >>> # Can apply transformations to the pipeline.
            >>> ray.data.range(5).repeat().map(lambda x: -x).take() # doctest: +SKIP
            [0, -1, -2, -3, -4, 0, -1, -2, -3, -4, ...]
            >>> # Can shuffle each epoch (dataset) in the pipeline.
            >>> ray.data.range(5).repeat().random_shuffle().take() # doctest: +SKIP
            [2, 3, 0, 4, 1, 4, 0, 2, 1, 3, ...]

        Args:
            times: The number of times to loop over this dataset, or None
                to repeat indefinitely.
        """
self
times
Optional[int]
The number of times to loop over this dataset, or None
to repeat indefinitely.
The number of times to loop over this dataset or None to repeat indefinitely .
examples
None