Create a Watch transform in Python
Currently we have a Watch transform in the Java SDK that is very useful when periodically polling for new input to a pipeline. We would like a parallel transform in Python.
https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Watch.java
Imported from Jira BEAM-14261. Original Jira may contain additional context. Reported by: johnjcasey.
I put together a focused PoC for the Python Watch transform to validate the core execution model before trying to build a full implementation.
PoC branch: https://github.com/Eliaaazzz/beam-native-streaming-poc
For the Watch side specifically, the PoC currently has 56 passing tests.
The current prototype is mainly exploring whether the main Watch lifecycle can be represented cleanly in Python using an SDF-based implementation shape. So far, it includes:
- a builder-style
Watch.growth_of(...)API with poll interval / termination configuration - a
PollResultabstraction carrying outputs, optional watermark, and completion - composable per-input termination conditions
- a
GrowthStatehierarchy separating active polling state from replay state - a custom
GrowthStateCoderwith structured encoding and backward-compatibility decode paths - a
GrowthStateTrackerwith explicit three-casetry_split()behavior modeled after JavaWatch.GrowthTracker - an SDF
process()flow that distinguishes replay from active polling - output dedup via
output_key_fnand stable hashing - watermark / completion handling in the polling path
The goal of this first step was not full parity or production hardening yet, but to de-risk the design and get executable validation around the hardest parts first: state evolution, resumption, split behavior, termination behavior, and watermark-related semantics.
If this direction looks reasonable, my next step would be to tighten it further against the Java semantics and then expand it toward a more complete implementation.
Feedback would be very helpful.
.take-issue
.take-issue