I am trying to execute 4 independent tasks, each running a notebook with papermill. Whatever I do, tasks are executed sequentially.
from prefect import flow, task
from prefect_dask.task_runners import DaskTaskRunner
from prefect.task_runners import ConcurrentTaskRunner
import papermill as pm
@task(name="Sea ice plot monthly")
def sea_ice_plot_monthly(settings, hemisphere, month):
settings["hemisphere"] = hemisphere
settings["month"] = month
pm.execute_notebook(
"ice_plot_month.ipynb",
f"ice_plot_month_{hemisphere}_{month}.ipynb",
parameters=settings,
)
@task(name="Sea ice plot monthly2")
def sea_ice_plot_monthly2(settings, hemisphere, month):
settings["hemisphere"] = hemisphere
settings["month"] = month
pm.execute_notebook(
"ice_plot_month.ipynb",
f"ice_plot_month_{hemisphere}_{month}.ipynb",
parameters=settings,
)
@flow(name="My Example Flow", task_runner=ConcurrentTaskRunner())
def my_flow(settings):
a = sea_ice_plot_monthly(settings, "n", 3)
b = sea_ice_plot_monthly2(settings, "n", 9)
c = sea_ice_plot_monthly(settings, "s", 3)
d = sea_ice_plot_monthly2(settings, "s", 9)
return a, b, c, d
if __name__ == "__main__":
status = my_flow(settings)
I’ve tried DaskTaskRunner with the same effect. Is it me missing a concept of how prefect should operate in this case (running 4 tasks in the same time)?