Hi, if I have 2 sub-flows in a main flow like belo...
# prefect-community
e
Hi, if I have 2 sub-flows in a main flow like below, can the flow_b get the output of flow_a as its input?
Copy code
with Flow(...) as flow:
    data = extract_some_data()
    flow_a = create_flow_run(…, parameters={'param-key':data})
    flow_b = create_flow_run(…,parameters={'param-key':output_from_flow_a})
k
You need to use the
get_task_run_result
task to pull a result from
flow_a
and then pass it in to
flow_b
e
i notice that the function asks for flow_run_id, it's generated by prefect right? is there a way to retrieve that in code?
k
the
flow_a
will be the run id because
create_flow_run
returns it
e
got it, so say this is my code. if task_a and task_b are both mapped with 10 items, will prefect execute in a depth first way? namely if item 1 finished first then it will go right to flow_b
Copy code
with Flow(...) as flow:
  data = extract_some_data()
  flow_a = create_flow_run(…, parameters={'param-key':data})
  flow_a_result = get_task_run_result(flow_a, task_a_slug)
  flow_b = create_flow_run(…,parameters={'param-key': flow_a_result})

with Flow(...) as flow_a:
  data = Parameter('param-key')
  a = task_a.map(data)

with Flow(...) as flow_b:
  data = Parameter('param-key')
  b = task_b.map(data)
k
I believe so
e
cool, the reason of having sub-flow is really to maintain the ability of running a portion of the main flow independently. more than happy to know if there is better way of achieving that
k
Of course! That makes sense!
e
great, thanks