Hi, I'm new to prefect and I am facing an issue. ...
# prefect-community
d
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
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
Hi @Kevin Kho, Do you have an example to illustrate what you suggest ?
k
There is an example in this blog. Look for the
get_task_run_result
d
I don't understand how this helps in my case where i want "to map" a flow
k
Sorry I’m confused here. You can just do
create_flow_run.map()
right?
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
It's exactly what I was searching for ! Thx you @Kevin Kho 👍