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] Add override_num_blocks to from_pandas and perform auto-partition #44937

Merged
merged 13 commits into from
May 25, 2024

Conversation

bveeramani
Copy link
Member

@bveeramani bveeramani commented Apr 23, 2024

Why are these changes needed?

A common pattern is to load a DataFrame containing file URIs with from_pandas and then loading those URIs with map_batches. If you have a single large DataFrame, the subsequent operator (e.g., for reading) won't be parallelized because from_pandas produces one input block.

To fix this issue, this PR automatically splits DataFrames into a good number of blocks, and allows the user to override the number of blocks.

Related issue number

Fixes #44893

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 <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
@bveeramani bveeramani changed the title [Data] Add override_num_blocks to from_pandas [Data] Add override_num_blocks to from_pandas and perform auto-partition May 3, 2024
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Balaji Veeramani <[email protected]>
@bveeramani bveeramani enabled auto-merge (squash) May 24, 2024 18:46
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label May 24, 2024
Signed-off-by: Balaji Veeramani <[email protected]>
@github-actions github-actions bot disabled auto-merge May 24, 2024 21:36
Signed-off-by: Balaji Veeramani <[email protected]>
@bveeramani bveeramani merged commit f13d144 into ray-project:master May 25, 2024
6 checks passed
@bveeramani bveeramani deleted the pandas-split branch May 25, 2024 07:43
ryanaoleary pushed a commit to ryanaoleary/ray that referenced this pull request Jun 6, 2024
…rtition (ray-project#44937)

A common pattern is to load a DataFrame containing file URIs with from_pandas and then loading those URIs with map_batches. If you have a single large DataFrame, the subsequent operator (e.g., for reading) won't be parallelized because from_pandas produces one input block.

To fix this issue, this PR automatically splits DataFrames into a good number of blocks, and allows the user to override the number of blocks.

Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Ryan O'Leary <[email protected]>
ryanaoleary pushed a commit to ryanaoleary/ray that referenced this pull request Jun 6, 2024
…rtition (ray-project#44937)

A common pattern is to load a DataFrame containing file URIs with from_pandas and then loading those URIs with map_batches. If you have a single large DataFrame, the subsequent operator (e.g., for reading) won't be parallelized because from_pandas produces one input block.

To fix this issue, this PR automatically splits DataFrames into a good number of blocks, and allows the user to override the number of blocks.

Signed-off-by: Balaji Veeramani <[email protected]>
Signed-off-by: Ryan O'Leary <[email protected]>
ryanaoleary pushed a commit to ryanaoleary/ray that referenced this pull request Jun 7, 2024
…rtition (ray-project#44937)

A common pattern is to load a DataFrame containing file URIs with from_pandas and then loading those URIs with map_batches. If you have a single large DataFrame, the subsequent operator (e.g., for reading) won't be parallelized because from_pandas produces one input block.

To fix this issue, this PR automatically splits DataFrames into a good number of blocks, and allows the user to override the number of blocks.

Signed-off-by: Balaji Veeramani <[email protected]>
bveeramani added a commit that referenced this pull request Jul 9, 2024
Originally, the number of blocks outputted by from_pandas equaled the number of input DataFrames (i.e., each input DataFrame became a block). For consistency with how we treat other inputs, #44937 changed the behavior so that each output block is the target block size. This meant that you could pass in many DataFrames as input but from_pandas would only output one block.

The change is problematic because many users do something like from_pandas(np.array_split(metadata, num_blocks)) to get better performance, and after #44937, the array_split is pointless. So, this PR reverts the change

Signed-off-by: Balaji Veeramani <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Data] Add override_num_blocks parameter to from_pandas
2 participants