Hello everbody, I need to divide dataframe(df) int...
# ask-community
t
Hello everbody, I need to divide dataframe(df) into dataframes -> load them into gpu and works on them. I can write a single task that does all but I prefer to keep them seperated and I already have a subflow that does the job. I wonder if I can call flow in a loop.
a
Hi @Toprak Nihat Deniz Öztürk! Have you used Mapping? You could map over a list of dataframes. If you prefer splitting the tasks into subflows, you can map over flows this way:
Copy code
from prefect import Flow, unmapped
from prefect.tasks.prefect import create_flow_run
from prefect.executors import LocalDaskExecutor

with Flow("MasterFlow_Mapped", executor=LocalDaskExecutor()) as flow:
    mapped_flow_run_ids = create_flow_run.map(
        flow_name=["flow_name_1", "flow_name_2", "flow_name_3"],
        project_name=unmapped("Flow_of_Flows"),
    )
The child flows must be registered beforehand.
t
Thank you for the answer @Anna Geller. I have used map at task level to process list of dataframes and it is probably the way to solve my problem. I should be able to explore your suggestion toworrow, very exited! Looks like it is a good fit to solve different kind of problem, for example: loading same data to database with "flow_name_1" , to a csv file with "flow_name_2" and so on.
👍 1