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

[Datasets] Refactor map-like functions into planner package #32021

Merged
merged 1 commit into from
Jan 28, 2023

Conversation

c21
Copy link
Contributor

@c21 c21 commented Jan 28, 2023

Signed-off-by: Cheng Su scnju13@gmail.com

Why are these changes needed?

This PR is followup of #31977 (comment), to remove block_fn from logical operator, and make planner to generate functions for map_batches/map/flat_map/filter. The change includes

  • Remove block_fn from AbstactMap, and all subclasses.
  • Refactor the transform functions defined in Dataset.map_batches/map/flat_map/filter into Planner.generate_xxx_fn (e.g. generate_map_batches_fn)

Decide to doing refactoring from Dataset here, because we update those code paths very frequently (e.g. Dataset.map_batches()), so don't want to maintain two diverged code paths. Also different from plan.py and stage_impl.py, we won't delete dataset.py.

Related issue number

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 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: Cheng Su <scnju13@gmail.com>
fn_args: Optional[Iterable[Any]] = None,
fn_kwargs: Optional[Dict[str, Any]] = None,
fn_constructor_args: Optional[Iterable[Any]] = None,
fn_constructor_kwargs: Optional[Dict[str, Any]] = None,
target_block_size: Optional[int] = None,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just reordering arguments, to make all fn-related arguments to be put together, and look more coherent.

from ray.data.context import DatasetContext


def generate_filter_fn() -> Callable[[Iterator[Block]], Iterator[Block]]:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied from Dataset.filter()

from ray.data.context import DatasetContext


def generate_flat_map_fn() -> Callable[[Iterator[Block]], Iterator[Block]]:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied from Dataset.flat_map()

from typing_extensions import Literal


def generate_map_batches_fn(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied from Dataset.map_batches()

from ray.data.context import DatasetContext


def generate_map_rows_fn() -> Callable[[Iterator[Block]], Iterator[Block]]:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied from Dataset.map()

@ericl ericl merged commit 8e188db into ray-project:master Jan 28, 2023
@c21 c21 deleted the refactor-map branch January 29, 2023 05:02
edoakes pushed a commit to edoakes/ray that referenced this pull request Mar 22, 2023
Signed-off-by: Cheng Su <scnju13@gmail.com>
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants