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] Add metadata override and inference in Dataset.to_dask(). #28625

Merged

Conversation

clarkzinzow
Copy link
Contributor

Adds an option to override the metadata when converting a Ray Dataset to a Dask DataFrame. If no override is provided, Datasets will infer the Dask DataFrame metadata using the Dataset schema (this should be cheaper than Dask's metadata inference, which involves launching a task).

Related issue number

Closes #27502

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 :(

Copy link
Contributor

@c21 c21 left a comment

Choose a reason for hiding this comment

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

LGTM with one minor comment.

Comment on lines 2965 to 2967
else:
# Simple dataset or schema not available.
meta = None
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this branch seems unnecessary, and it could be pyarrow not installed.

@@ -2905,12 +2915,25 @@ def to_dask(self) -> "dask.DataFrame":

Time complexity: O(dataset size / parallelism)

Args:
meta: An empty pandas DataFrame or Series that matches the dtypes and column
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the last 4 types from Union be dropped then?

Also if it's a Series, how does it correspond to multiple columns of the Dataset? Is it performing a column projection when meta is a subset columns?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think Clark was following Dask type here - meta: pd.DataFrame, pd.Series, dict, iterable, tuple, optional in https://docs.dask.org/en/stable/generated/dask.dataframe.from_delayed.html .

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not quite match the type annotation so we should fix either.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah agree, the comment should be updated.

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.

[Datasets] -> Adding meta during to_dask() call
3 participants