beam icon indicating copy to clipboard operation
beam copied to clipboard

Create a Watch transform in Python

Open damccorm opened this issue 4 years ago • 3 comments

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.

damccorm avatar Jun 05 '22 00:06 damccorm

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 PollResult abstraction carrying outputs, optional watermark, and completion
  • composable per-input termination conditions
  • a GrowthState hierarchy separating active polling state from replay state
  • a custom GrowthStateCoder with structured encoding and backward-compatibility decode paths
  • a GrowthStateTracker with explicit three-case try_split() behavior modeled after Java Watch.GrowthTracker
  • an SDF process() flow that distinguishes replay from active polling
  • output dedup via output_key_fn and 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.

Eliaaazzz avatar Mar 13 '26 15:03 Eliaaazzz

.take-issue

Eliaaazzz avatar Mar 13 '26 15:03 Eliaaazzz

.take-issue

shaheeramjad avatar Mar 19 '26 17:03 shaheeramjad