Thread
#prefect-community
    d

    damien michelle

    6 months ago
    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
    Kevin Kho

    Kevin Kho

    6 months ago
    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

    6 months ago
    Hi @Kevin Kho, Do you have an example to illustrate what you suggest ?
    Kevin Kho

    Kevin Kho

    6 months ago
    There is an example in this blog. Look for the
    get_task_run_result
    d

    damien michelle

    6 months ago
    I don't understand how this helps in my case where i want "to map" a flow
    Kevin Kho

    Kevin Kho

    6 months ago
    Sorry I’m confused here. You can just do
    create_flow_run.map()
    right?
    something like this?
    @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

    6 months ago
    It's exactly what I was searching for ! Thx you @Kevin Kho 👍