-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[Datasets] Add metadata override and inference in Dataset.to_dask()
.
#28625
Conversation
There was a problem hiding this 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.
python/ray/data/dataset.py
Outdated
else: | ||
# Simple dataset or schema not available. | ||
meta = None |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 .
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.