-
Notifications
You must be signed in to change notification settings - Fork 373
feat: Wire override_num_blocks through full call chain for Ray Data read operations #984
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
95c77e0
caa8fce
96aca23
df51e5d
b2531ae
f5623ff
aa3dd4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -347,11 +347,11 @@ def count(self) -> int: | |||||||||||||||||||
| return self.data.count() | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @classmethod | ||||||||||||||||||||
| def read(cls, data_format: str, paths: Union[str, List[str]]) -> RayDataset: | ||||||||||||||||||||
| def read(cls, data_format: str, paths: Union[str, List[str]], **kwargs) -> RayDataset: | ||||||||||||||||||||
| if data_format in {"json", "jsonl", "json.gz", "jsonl.gz", "json.zst", "jsonl.zst"}: | ||||||||||||||||||||
| return RayDataset.read_json(paths) | ||||||||||||||||||||
| return RayDataset.read_json(paths, **kwargs) | ||||||||||||||||||||
| elif data_format == "webdataset": | ||||||||||||||||||||
| return RayDataset.read_webdataset(paths) | ||||||||||||||||||||
| return RayDataset.read_webdataset(paths, **kwargs) | ||||||||||||||||||||
| elif data_format in { | ||||||||||||||||||||
| "parquet", | ||||||||||||||||||||
| "images", | ||||||||||||||||||||
|
|
@@ -369,23 +369,23 @@ def read(cls, data_format: str, paths: Union[str, List[str]]) -> RayDataset: | |||||||||||||||||||
| from data_juicer.utils.lazy_loader import LazyLoader | ||||||||||||||||||||
|
|
||||||||||||||||||||
| LazyLoader.check_packages(["pylance"]) | ||||||||||||||||||||
| return getattr(ray.data, f"read_{data_format}")(paths) | ||||||||||||||||||||
| return getattr(ray.data, f"read_{data_format}")(paths, **kwargs) | ||||||||||||||||||||
|
fengrui-z marked this conversation as resolved.
Outdated
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| @classmethod | ||||||||||||||||||||
| def read_json(cls, paths: Union[str, List[str]]) -> RayDataset: | ||||||||||||||||||||
| def read_json(cls, paths: Union[str, List[str]], override_num_blocks: Optional[int] = None) -> RayDataset: | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||||
| # Note: a temp solution for reading json stream | ||||||||||||||||||||
| # TODO: replace with ray.data.read_json_stream once it is available | ||||||||||||||||||||
| import pyarrow.json as js | ||||||||||||||||||||
|
|
||||||||||||||||||||
| try: | ||||||||||||||||||||
| js.open_json | ||||||||||||||||||||
| return read_json_stream(paths) | ||||||||||||||||||||
| return read_json_stream(paths, override_num_blocks=override_num_blocks) | ||||||||||||||||||||
| except AttributeError: | ||||||||||||||||||||
| return ray.data.read_json(paths) | ||||||||||||||||||||
| return ray.data.read_json(paths, override_num_blocks=override_num_blocks) | ||||||||||||||||||||
|
fengrui-z marked this conversation as resolved.
Outdated
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| @classmethod | ||||||||||||||||||||
| def read_webdataset(cls, paths: Union[str, List[str]]) -> RayDataset: | ||||||||||||||||||||
| return ray.data.read_webdataset(paths, decoder=partial(_custom_default_decoder, format="PIL")) | ||||||||||||||||||||
| def read_webdataset(cls, paths: Union[str, List[str]], **kwargs) -> RayDataset: | ||||||||||||||||||||
| return ray.data.read_webdataset(paths, decoder=partial(_custom_default_decoder, format="PIL"), **kwargs) | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| def to_list(self) -> list: | ||||||||||||||||||||
| return self.data.to_pandas().to_dict(orient="records") | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed these files only changed executable mode ( |
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.
The return type hint
RayDatasetis incorrect. This method returns aray.data.Datasetobject, which is then wrapped by the caller (e.g., inload_strategy.py). This inconsistency exists in several methods in this class.