Hi,
I'm new to prefect and I am facing an issue.
I have a flow A which takes a country_code as a paremeter. I would like to know how to map the flow A to a list of country_code ?
Currently, I was thinking triggering the flow A by mapping the flow A to each country_code specified in a flow B (as shown in the images)
Thanks by advance
k
Kevin Kho
03/01/2022, 3:08 PM
Hi @damien michelle, it is a bit less straightfroward to do it with a subflow if you can avoid it because you need to use the
get_task_run_result
task in order to pull it out back into the main Flow.
It will be easier if you could capture this in a task and use the task int he main flow.
d
damien michelle
03/01/2022, 3:19 PM
Hi @Kevin Kho, Do you have an example to illustrate what you suggest ?
I don't understand how this helps in my case where i want "to map" a flow
k
Kevin Kho
03/01/2022, 3:56 PM
Sorry I’m confused here. You can just do
create_flow_run.map()
right?
Kevin Kho
03/01/2022, 4:05 PM
something like this?
Copy code
@task
def get_params_list(codes):
res = []
for code in codes:
res.append({"country_code":code}
return res
with Flow(...) as flow:
codes = Parameter("codes", [123, 456])
params_list = get_params_list(codes)
create_flow_run.map(flow_name=unmapped("name"), project_name=unmapped("name"), parameters=params_list)
d
damien michelle
03/01/2022, 4:18 PM
It's exactly what I was searching for ! Thx you @Kevin Kho 👍
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.