Repository navigation
[Python] Preserve data and timer payloads in the final Fn API block - #41447
wozhenbang2004 wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR resolves #21164 for the Python SDK by ensuring InMemoryDataChannel and _GrpcDataChannel yield Elements.Data and Elements.Timers messages containing payloads even when marked with is_last=True, while still recording stream completion and ignoring empty end-of-stream markers. The changes are minimal, accurate, and accompanied by unit tests covering both data and timer final payloads.
🔍 General Feedback
- The condition
if element.<payload> or not element.is_last:in_GrpcDataChannel.input_elementsandInMemoryDataChannel.input_elementscleanly preserves final block payloads while suppressing empty end-of-stream markers. - Note for
InMemoryDataChannel.input_elements: line 399 still checksif element.data or element.is_last:(thoughInMemoryDataChannel.output_streamnever setsis_last=True). In a future cleanup or if desired here, aligning it toif element.data or not element.is_last:would make both channels completely consistent if an external caller ever appends an emptyData(is_last=True)marker.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
Assigning reviewers: R: @jrmccluskey for label python. 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). |
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41447 +/- ##
============================================
- Coverage 59.47% 59.37% -0.11%
Complexity 5123 5123
============================================
Files 1468 1468
Lines 187422 187424 +2
Branches 3807 3807
============================================
- Hits 111478 111279 -199
- Misses 72545 72746 +201
Partials 3399 3399
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Reminder, please take a look at this pr: @jrmccluskey |
|
Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment R: @damccorm for label python. Available commands:
|
There was a problem hiding this comment.
📋 Review Summary
This PR fixes Fn API data channels (_GrpcDataChannel and InMemoryDataChannel) so that non-empty data and timer payloads attached to final messages (is_last=True) are yielded to consumers while still recording stream completion and suppressing empty end-of-stream markers. The changes are minimal, preserve existing behavior for non-final and empty final blocks, and include unit test coverage for both channels.
🔍 General Feedback
- No code issues found.
- Note: the PR currently has a merge conflict (
mergeable_state: "dirty", likely inCHANGES.md) and will need a rebase ontomaster.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
damccorm
left a comment
There was a problem hiding this comment.
Thanks - I'll merge once checks pass
|
Could you please pull in the latest changes from master? We'll need #41870 for CI to go green |
Fixes #21164.
The Python gRPC data channel drops payloads in blocks marked with
is_last=True; the in-memory channel does the same for timers. Preserve those payloads while keeping the end-of-stream bookkeeping and empty end markers unchanged.Added regressions for both channels. The data-plane tests and the gRPC runner tests for ordinary input, timer firing and timer clearing pass. A localhost BeamFnData RPC also preserves encoded data and timers in the final block.