Repository navigation
[Data] Fix WebDataset docs and encoder typing - #65278
Conversation
There was a problem hiding this comment.
Code Review
This pull request refines the type annotations and documentation for the WebDataset writer, introducing type aliases for encoder configurations and updating the docstrings to correctly reference WebDataset tar archives instead of TFRecord files. It also adds tests to verify default, callable, and chained encoders. The review feedback suggests refining the WebDatasetEncoderConfig type alias to use List[WebDatasetEncoderSpec] instead of List[Any], and using this alias consistently in Dataset.write_webdataset instead of an inlined type union.
Signed-off-by: viiccwen <[email protected]>
ba5bd45 to
0f7fc04
Compare
|
@400Ping any updates? |
|
cc @bveeramani to take a look |
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
| assert_archive(default_path, lambda i: str(i)) | ||
|
|
||
| def encode_a(sample): | ||
| sample = dict(sample) | ||
| sample["a"] = f"encoded-{sample['a']}".encode("utf-8") | ||
| return sample | ||
|
|
||
| callable_path = tmp_path / "callable" | ||
| ds.write_webdataset(path=callable_path, encoder=encode_a) | ||
| assert_archive(callable_path, lambda i: f"encoded-{i}") | ||
|
|
||
| def prefix_a(sample): | ||
| sample = dict(sample) | ||
| sample["a"] = f"prefixed-{sample['a']}" | ||
| return sample | ||
|
|
||
| chained_path = tmp_path / "chained" | ||
| ds.write_webdataset(path=chained_path, encoder=[prefix_a, encode_a]) | ||
| assert_archive(chained_path, lambda i: f"encoded-prefixed-{i}") |
There was a problem hiding this comment.
Nit: This test is verifying three different cases: basic string encoding, UDF-8 encoding, and multiple chained encoders.
For future PRs, I think it'd be good if we can split these up into focused and isolated tests, even if there's some duplication.
## Description Correct the public `Dataset.write_webdataset()` contract so it matches the tar-based WebDataset implementation. - Replace copied TFRecord descriptions with WebDataset sample and tar archive semantics. - Correct output path and default extension documentation. - Define reusable encoder aliases for a default format specifier, a sample-transform callable, or a list of those values. - Use the aliases in both `Dataset.write_webdataset()` and `WebDatasetDatasink`. - Add focused tests proving callable and chained-list encoders are accepted and produce the expected archive entries. This changes documentation and static typing only; existing supported runtime inputs remain valid. ## Related issues Closes ray-project#65277. ## Additional information API documentation changes (no real behavior change). --------- Signed-off-by: viiccwen <[email protected]> Co-authored-by: Jie-Kai Chang <[email protected]>
Add a nomination under `fellowship/ray/` Suggested level: 20k Highlights from 2026-09-01 to 2026-10-11: - [Contribution](https://github.com/opensource4you/readme/blob/main/fellowship/ray/fellow-contribution/400Ping/September/report.md) - Landed the Ray Data roadmap feature task-based shuffle v2 for `sort()`: ~35% faster, ~24% lower object-store peak and no spilling compared with v1 on an 11.92 GiB sort ([#64875](ray-project/ray#64875)) - As a senior contributor who can already approve Ray Data PRs, helps the community a lot by reviewing and guiding other contributors, for example, reviewing other fellows' PRs ([#66878](ray-project/ray#66878), [#65278](ray-project/ray#65278)) - Spent over a month with Ray Data maintainer Balaji researching how to cut Ray Data release test launch time([#66284](ray-project/ray#66284)) - Migrating the CSV datasource to DataSourceV2, with a design doc and a 5-PR stack for the Ray Data maintainers ([#65743](ray-project/ray#65743))
Description
Correct the public
Dataset.write_webdataset()contract so it matches the tar-based WebDataset implementation.Dataset.write_webdataset()andWebDatasetDatasink.This changes documentation and static typing only; existing supported runtime inputs remain valid.
Related issues
Closes #65277.
Additional information
API documentation changes (no real behavior change).