Skip to content

[Data] Fix WebDataset docs and encoder typing - #65278

Merged
bveeramani merged 3 commits into
ray-project:masterfrom
viiccwen:data-webdataset-contract
Sep 17, 2026
Merged

bveeramani merged 3 commits into
ray-project:masterfrom
viiccwen:data-webdataset-contract

Conversation

@viiccwen

@viiccwen viiccwen commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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 #65277.

Additional information

API documentation changes (no real behavior change).

@viiccwen
viiccwen requested a review from a team as a code owner August 7, 2026 02:38

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread python/ray/data/dataset.py Resolved
@400Ping 400Ping self-assigned this Aug 7, 2026
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation data Ray Data-related issues community-contribution Contributed by the community labels Aug 7, 2026
@viiccwen
viiccwen force-pushed the data-webdataset-contract branch from ba5bd45 to 0f7fc04 Compare August 7, 2026 13:57
@richardliaw richardliaw added the go add ONLY when ready to merge, run all tests label Aug 8, 2026
Comment thread python/ray/data/dataset.py Resolved
Comment thread python/ray/data/dataset.py Resolved

@400Ping 400Ping left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall LGTM

@viiccwen

Copy link
Copy Markdown
Contributor Author

@400Ping any updates?

@400Ping

400Ping commented Aug 27, 2026

Copy link
Copy Markdown
Member

cc @bveeramani to take a look

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

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.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Sep 10, 2026
@bveeramani bveeramani self-assigned this Sep 16, 2026
@github-actions github-actions Bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Sep 17, 2026
Comment thread python/ray/data/dataset.py Resolved
Comment on lines +228 to +246
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}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@bveeramani
bveeramani merged commit 97f42ed into ray-project:master Sep 17, 2026
6 checks passed
@viiccwen
viiccwen deleted the data-webdataset-contract branch September 17, 2026 01:58
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
## 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]>
chia7712 pushed a commit to opensource4you/readme that referenced this pull request Oct 21, 2026
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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community data Ray Data-related issues docs An issue or change related to documentation go add ONLY when ready to merge, run all tests unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Data] Correct write_webdataset documentation and encoder type contract

4 participants