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

Normalize tf record io #34411

Draft
wants to merge 30 commits into
base: master
Choose a base branch
from
Draft

Conversation

derrickaw
Copy link
Collaborator

@derrickaw derrickaw commented Mar 24, 2025

Add TFRecordIO normalization for java and python.
This fixes #28692.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@derrickaw derrickaw force-pushed the normalizeTFRecordIO branch from 75d2682 to e9d6428 Compare March 27, 2025 16:15
@derrickaw
Copy link
Collaborator Author

derrickaw commented Mar 27, 2025

When running the yaml integration tests, I get this error that I haven't figured out yet how to solve -
FAILED apache_beam/yaml/integration_tests.py::TfrecordTest::test_WriteToTFRecord_InlineProvider_0 - RuntimeError: AssertionError: (BeamSchema_c8a75360_f2fc_4d80_9173_2d839bf21107(record2=b'foo'), <class 'apache_beam.typehints.schemas.BeamSchema_c8a75360_f2fc_4d80_9173_2d839bf21107'>) [while running 'WriteToTFRecord/Write/WriteImpl/WriteBundles']

Returns:
A WriteToTFRecord transform object.
"""
return WriteToTFRecord(
Copy link
Contributor

Choose a reason for hiding this comment

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

Because WriteToTFRecord takes in a PCollection of bytes, but yaml returns a PCollection of rows, we need a small conversion layer here - similar to

def write_to_text(pcoll, path: str):

We will probably need a similar construct for reading to map it to rows

@@ -0,0 +1,111 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

Once this is ready for full review (IMO, this is probably now if we can add a few integration tests). I'd recommend doing a separate PR for read/write since they're not really tied together at all. That will make it easier to review/iterate. It also will hopefully unblock the read review while dealing with the issues you're seeing on write

@damccorm
Copy link
Contributor

When running the yaml integration tests, I get this error that I haven't figured out yet how to solve - FAILED apache_beam/yaml/integration_tests.py::TfrecordTest::test_WriteToTFRecord_InlineProvider_0 - RuntimeError: AssertionError: (BeamSchema_c8a75360_f2fc_4d80_9173_2d839bf21107(record2=b'foo'), <class 'apache_beam.typehints.schemas.BeamSchema_c8a75360_f2fc_4d80_9173_2d839bf21107'>) [while running 'WriteToTFRecord/Write/WriteImpl/WriteBundles']

If you have integration test code, could you include that in the draft PR (or whatever follow up PR you have here)? I think it will help to see the full thing.

Noting the InlineProvider piece means that this is an issue with the python provider, which shouldn't be too bad to figure out since its less code.

@derrickaw
Copy link
Collaborator Author

When running the yaml integration tests, I get this error that I haven't figured out yet how to solve - FAILED apache_beam/yaml/integration_tests.py::TfrecordTest::test_WriteToTFRecord_InlineProvider_0 - RuntimeError: AssertionError: (BeamSchema_c8a75360_f2fc_4d80_9173_2d839bf21107(record2=b'foo'), <class 'apache_beam.typehints.schemas.BeamSchema_c8a75360_f2fc_4d80_9173_2d839bf21107'>) [while running 'WriteToTFRecord/Write/WriteImpl/WriteBundles']

This error is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[yaml] Normalize TFRecordIO
2 participants