flytekit icon indicating copy to clipboard operation
flytekit copied to clipboard

[BUG] sync_node_executions fails for workflows with BranchNode

Open machichima opened this issue 6 months ago • 1 comments

Tracking issue

Part of https://github.com/flyteorg/flyte/issues/6490

Why are the changes needed?

When using flytekit's FlyteRemote and calling remote.wait on an execution of a workflow that contains a BranchNode, we will get following error:

   execution = remote.wait(execution=execution, timeout=timeout)
../../../../../anaconda3/envs/flyte/lib/python3.10/site-packages/flytekit/remote/remote.py:2384: in wait
    execution = self.sync_execution(execution, sync_nodes=sync_nodes)
../../../../../anaconda3/envs/flyte/lib/python3.10/site-packages/flytekit/remote/remote.py:2479: in sync_execution
    node_execs[n.id.node_id] = self.sync_node_execution(n, node_mapping)  
E           AttributeError: 'FlyteBranchNode' object has no attribute 'interface'

../../../../../anaconda3/envs/flyte/lib/python3.10/site-packages/flytekit/remote/remote.py:2648: AttributeError

What changes were proposed in this pull request?

In some cases, the execution.metadata.is_parent_node for branch node is not True, which lead to the block without managing branch node separately. Moving the logic handling branch node before checking is_parent_node to handle both is and is not branch node cases

How was this patch tested?

integration test

Setup process

Screenshots

Check all the applicable boxes

  • [ ] I updated the documentation accordingly.
  • [x] All new and existing tests passed.
  • [x] All commits are signed-off.

Related PRs

Docs link

Summary by Bito

This pull request enhances the handling of branch nodes in Flytekit's execution logic, fixing a bug related to their management and ensuring they are handled correctly regardless of their parent node status. It introduces a new conditional workflow and tests to improve the library's robustness for complex workflows by preventing errors associated with missing attributes in branch nodes.

machichima avatar Jun 12 '25 12:06 machichima