Thanatos9404 opened a new pull request, #41575:
URL: https://github.com/apache/beam/pull/41575

   Fixes #41574
   
   `AfterProcessingTime` takes its delay in seconds, but only whole seconds 
worked:
   
   - `to_runner_api` set `delay_millis` to a float for a fractional delay, 
which the proto rejects. A pipeline using `AfterProcessingTime(0.5)` failed 
with `Unable to translate WindowInto(WindowIntoFn)`.
   - `from_runner_api` floored the delay to whole seconds, so 1500 ms became 1 
and 500 ms became 0.
   - `__repr__` used `%d`, so `AfterProcessingTime(0.5)` showed as `delay=0`.
   - There was no `__eq__` or `__hash__`, so two identical triggers were not 
equal. That made `Flatten` warn about different windowing for identically 
windowed inputs.
   
   Now:
   - `to_runner_api` rounds the delay to whole milliseconds.
   - `from_runner_api` keeps the fraction. A delay of whole seconds stays an 
int, so those triggers look the same as before.
   - `__repr__` uses `%s`.
   - `__eq__` and `__hash__` compare the delay, like the other triggers do.
   
   Tests in `trigger_test.py`:
   - `test_after_processing_time_encoding` round-trips delays of 10, 0.5 and 
1.5 seconds, checking `delay_millis`, equality and the repr.
   - `test_trigger_encoding` now also covers `AfterProcessingTime(10)` and 
`AfterWatermark(early=AfterProcessingTime(0.5))`. It couldn't include 
`AfterProcessingTime` before, because the trigger had no `__eq__`.
   
   Both tests fail without the change, and the rest of `trigger_test.py` 
passes. yapf and ruff are clean. I also added a `CHANGES.md` entry under 
Bugfixes for 2.79.0.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [PR] [Python] Support fraction... Thanatos9404 (via GitHub) via github

Reply via email to