这是indexloc提供的服务,不要输入任何密码
Skip to content

Feature Proposal: Fan out ability to heterogeneous downstream nodes #94

@redreamality

Description

@redreamality

Background

From the source code, I'm not sure whether the current pocketflow mechanism supports heterogeneous downstream nodes to be executed in parallel. Therefore, I proposed two ways of implementing it:

  • Method one is like add the nodes one by one in a flat way
  • I personally fond of method two, where we need to hack pocketflow to accept a list for multiple downstream nodes.

Method 1

def create_fanout_flow():
    """Create and configure the fan-out test flow."""
    # Create nodes
    print_one = PrintOneNode()
    fanout_print = [PrintTwoPointOneNode(), PrintTwoPointTwoNode()]
    print_three = PrintThreeNode()
    
    # Configure transitions
    print_one - "fanout" >> fanout_print[0]
    print_one - "fanout" >> fanout_print[1]
    fanout_print[0] - "final" >> print_three
    fanout_print[1] - "final" >> print_three

Method 2

def create_fanout_flow():
    """Create and configure the fan-out test flow."""
    # Create nodes
    print_one = PrintOneNode()
    fanout_print = [PrintTwoPointOneNode(), PrintTwoPointTwoNode()]
    print_three = PrintThreeNode()
    
    # Configure transitions
    print_one - "fanout" >> fanout_print
    fanout_print - "final" >> print_three

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions