fix(pyamber): allow worker state to transit READY -> COMPLETED#5214
Merged
mengw15 merged 2 commits intoMay 26, 2026
Conversation
A Python UDF worker whose upstream produces zero tuples receives an
EndChannel marker before any data, so it never visits RUNNING. When
`_process_end_channel` then calls `complete()`, the state machine in
`Context` rejected the transition because READY's allowed targets were
`{PAUSED, RUNNING}`, and the worker thread died with
`InvalidTransitionException: Cannot transit from READY to COMPLETED`.
The downstream operator stayed in READY and the workflow hung.
The Scala-side WorkerStateManager already includes COMPLETED in
READY's allowed targets; the Python state graph had drifted out of
sync. Add `WorkerState.COMPLETED` to the READY set so the two stay
aligned and zero-input workers can complete cleanly.
Lift the state-transition graph out of `Context.__init__` into a
module-level `WORKER_STATE_TRANSITIONS` constant so the test fixture
can import it (single source of truth) and so the graph is built once
per process instead of once per Context.
Closes apache#5197.
Contributor
|
let's call it pyamber, because we have other components like pybuilder as well. calling it python is a bit too general. |
Contributor
|
also it will be ideal to simplify pr description. it is a bit too detailed. Especially on the "How was this PR tested?" part |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5214 +/- ##
=========================================
Coverage 48.33% 48.33%
Complexity 2342 2342
=========================================
Files 1042 1042
Lines 39973 39974 +1
Branches 4251 4251
=========================================
+ Hits 19322 19323 +1
Misses 19507 19507
Partials 1144 1144
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
A Python UDF worker whose upstream produces zero tuples receives an
EndChannelmarker before any data, so it never visitsRUNNING. When_process_end_channelcallscomplete(), the state machine inContextrejectedREADY → COMPLETEDand the worker died withInvalidTransitionException, leaving the downstream operator stuck and the workflow hung.The Scala-side
WorkerStateManageralready listsCOMPLETEDinREADY's allowed targets — this is a Python ↔ Scala parity drift. AddWorkerState.COMPLETEDto the PythonREADYset.Also lift the state-transition graph out of
Context.__init__into a module-levelWORKER_STATE_TRANSITIONSconstant so the test fixture can import it (single source of truth — the previous fixture independently duplicated the graph, which is what masked the parity gap from existing tests).Any related issues, documentation, discussions?
Closes #5197.
How was this PR tested?
Added a regression test in
test_state_manager.pycoveringREADY → COMPLETED. Also manually verified the issue's reproducer workflow now completes; previously hung with the worker stuck inREADY.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (claude-opus-4-7)