<#3148 Eager cleanup> Pull request opened by <wild...
# flyte-github
c
#3148 Eager cleanup Pull request opened by wild-endeavor Why are the changes needed? Eager tasks operate outside of the fundamental assumptions made when Flyte was designed. This leads to potentially orphaned executions - executions that were launched by an eager task that aren't terminated when a parent eager task fails. What changes were proposed in this pull request? This PR adds an imperative workflow for each eager task, similar to what Admin does for single task executions. However it also attaches a failure node handler in cases where an eager task fails. • Added a new task type
EagerFailureHandlerTask
that's similar to the
EchoTask
. It is used to mimic the input interface of an eager task since the inputs to the failure node have to match that of the parent workflow/eager task. This failure task leverages the execution tags functionality as well as the tags that eager tasks add to child executions to make sure they're all cleaned up. • Added a new task resolver for that task type that always returns an
EagerFailureHandlerTask
instance with no input interface at runtime. Since we don't need to transform the inputs at failure handling runtime, we don't need to store a path to the original eager task to retrieve the Python types. • Added failure node for imperative workflows. (mostly takes care of flyteorg/flyte#5913) • Noticed a corresponding
ValueNotIn
filter object was missing but ended up not using it. How was this patch tested? Setup process This was tested on Union internal clusters. (Testing on Flyte clusters is not yet possible due to missing single-task-execution labels.) Wrote an eager task that created some downstream executions that take varying amounts of time. One of the downstream tasks is set to fail, triggering a cleanup of the remaining ones. @task(container_image=image) def add_one(x: int) -> int: print(os.environ) return x + 1 @task(container_image=image) async def double(x: int) -> int: print_env() if x == 2: return 42 if x == 5: raise AssertionError("x is 5") await asyncio.sleep(20 + x) return x * 2 @eager(container_image=image) async def level_1() -> typing.Tuple[int, int]: a1 = asyncio.create_task(double(x=1)) a2 = asyncio.create_task(double(x=2)) a3 = asyncio.create_task(double(x=3)) a4 = asyncio.create_task(double(x=4)) a5 = asyncio.create_task(double(x=5)) (i1, i2, i3, i4, i5) = await asyncio.gather(a1, a2, a3, a4, a5) x, y = i1 + i2, i3 + i4 + i5 print(f"Final result: {x}, {y}") return x, y Screenshots image Failure node tasks do not run if everything succeeds. image Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. Related PRs Docs link Summary by Bito This PR implements and enhances the eager task cleanup mechanism with EagerFailureHandlerTask, introducing configurable delay settings and failure handler system. It removes debug print statements, unused imports, and temporary cleanup code while streamlining EagerAsyncPythonFunctionTask implementation. The changes improve union API handling, error management, and ensure proper cleanup of downstream executions when parent eager tasks fail. Unit tests added: True Estimated effort to review (1-5, lower is better): 3 flyteorg/flytekit