Fixes metadata propagation from doFn output to next parDo by introducing new interface and plumbing propagation#37851
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue where metadata associated with Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
|
||
| public abstract <T> void outputWindowedValue(TupleTag<T> tag, WindowedValue<T> windowedValue); | ||
|
|
||
| public abstract void outputWindowedValue(WindowedValue<OutputT> windowedValue); |
There was a problem hiding this comment.
@kennknowles I'm really curious if we are able to avoid that. You've spent quite a lot of time on outputbuilder work to avoid changing public interface and this method is exposed in ProcessContext so any user can use it if they want.
There was a problem hiding this comment.
Ah, yes. The old interface between the SDK and runner v1 is that the runner v1 provides a ProcessContext that will route the outputs to the correct place. When we added OutputReceiver we just made it a wrapper instead of porting runner v1 to the new design fully.
I think it is still OK to make the change you have here. The OutputBuilder work was also to make sure that the metadata was propagated, so it is still necessary. If a user choose to make a new WindowedValue from scratch and output it... well, it is not ideal but it could be worse. TBH I wish to deprecate the use of Contexts by users (ever since https://s.apache.org/a-new-dofn) since it is a hopeless interface in some ways.
I think the only alternative is to adjust runner v1 (and other runners) to implement OutputReceiver directly as though ProcessContext (and friends) do not exist. Never invested in this because of runner v2 being the focus plus it didn't seem too bad.
90306f3 to
7beaf1e
Compare
|
few tests to fix as it looks like this approached skipped some timestamp validation. |
cb1c99c to
fee5855
Compare
|
/gemini review |
|
Run Java_PVR_Prism_Loopback PreCommit |
There was a problem hiding this comment.
Code Review
This pull request introduces a new outputWindowedValue(WindowedValue) interface to better propagate metadata, replacing the older interface that took exploded parameters. The changes are well-implemented and plumbed through various runners and components. The new tests for metadata propagation are a great addition.
I've found a few areas for improvement:
- There are a couple of instances of code duplication in new methods that could be refactored for better maintainability.
- I noticed a potential correctness issue in
SimpleDoFnRunnerwhere a timestamp check is missing in newly added methods. - The new test class
MetadataPropagationTesthas a test isolation issue due to a shared static flag, which could lead to flaky tests.
Overall, this is a solid contribution that improves the SDK's metadata handling capabilities. Addressing the points above will make it even better.
runners/core-java/src/main/java/org/apache/beam/runners/core/SimpleDoFnRunner.java
Show resolved
Hide resolved
sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MetadataPropagationTest.java
Show resolved
Hide resolved
...n/java/org/apache/beam/runners/core/OutputAndTimeBoundedSplittableProcessElementInvoker.java
Show resolved
Hide resolved
sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/DoFnTester.java
Show resolved
Hide resolved
fee5855 to
55439e2
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new outputWindowedValue(WindowedValue) interface to simplify metadata propagation, deprecating the older interface that required deconstructing the WindowedValue. The changes are plumbed through various DoFn runners and contexts, and new tests are added to verify the propagation of CausedByDrain metadata. The changes are well-implemented and consistent. I have a couple of minor suggestions for the new test file to improve maintainability.
sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MetadataPropagationTest.java
Show resolved
Hide resolved
sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MetadataPropagationTest.java
Outdated
Show resolved
Hide resolved
|
Run Java_PVR_Prism_Loopback PreCommit |
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
| new DoFn<KV<K, V>, KV<K, ValueInSingleWindow<V>>>() { | ||
| @ProcessElement | ||
| public void processElement( | ||
| ProcessContext pc, |
There was a problem hiding this comment.
This should be getting the record metadata through magic parametrs, not process context
There was a problem hiding this comment.
I don't have yet currentRecordId currentRecordOffset exposed in doFn. Let me prepare follow up PR to make it work.
- add tests to cover metadata propagation across parDos in single and mulitple stages for direct runner - plumbs metadata propagation, where it was lost previously.
bbd5a2d to
578cb09
Compare
|
Run Java_PVR_Prism_Loopback PreCommit |
1 similar comment
|
Run Java_PVR_Prism_Loopback PreCommit |
53ee0b3 to
f565365
Compare
2cc5cc3 to
7732a10
Compare
7732a10 to
80c7a49
Compare
|
Assigning reviewers: R: @chamikaramj for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
When data is outputted with processContext, outputReceiver or builder, it's going through sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/DoFnOutputReceivers.java which was still using context.outputWindowedValue(element, ts, windows, pane ...) interface which we decided to abandon as adding new metadata requires changing this interface and we should use builder and windowedValue interface.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
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, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.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)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.