Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data][Doc] Add tip about how to understand map_batches format #47394

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions python/ray/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ def map_batches(
stateful Ray actors. For more information, see
:ref:`Stateful Transforms <stateful_transforms>`.

.. tip::
For interactive development, to understand the format of the input to ``fn``,
you can call :meth:`~Dataset.take_batch` on the dataset to get a batch in the
same format as will be passed to ``fn``.

pcmoritz marked this conversation as resolved.
Show resolved Hide resolved
.. tip::
If ``fn`` doesn't mutate its input, set ``zero_copy_batch=True`` to improve
performance and decrease memory utilization.
Expand Down Expand Up @@ -562,6 +567,11 @@ def __call__(self, batch: Dict[str, np.ndarray]) -> Dict[str, np.ndarray]:
:meth:`~Dataset.iter_batches`
Call this function to iterate over batches of data.

:meth:`~Dataset.take_batch`
Call this function to get a batch of data from the dataset
in the same format as will be passed to the `fn` function of
:meth:`~Dataset.map_batches`.

:meth:`~Dataset.flat_map`
Call this method to create new records from existing ones. Unlike
:meth:`~Dataset.map`, a function passed to :meth:`~Dataset.flat_map`
Expand Down