https://prefect.io logo
#prefect-community
Title
# prefect-community
i

Ilhom Hayot o'g'li

05/23/2022, 12:08 PM
HI! I wanted to run 2 or more flows independently for ETL processes with cron. What are the best practices? Is there some way of doing so ?
a

Anna Geller

05/23/2022, 12:34 PM
Hi @Ilhom Hayot o'g'li, you can do that using Prefect. Specifically for CRON check this page https://orion-docs.prefect.io/concepts/schedules/#cronschedule
Copy code
from prefect.deployments import DeploymentSpec
from prefect.orion.schemas.schedules import CronSchedule

DeploymentSpec(
    name="cron-schedule-deployment",
    flow_location="/path/to/flow.py",
    schedule=CronSchedule(
        cron="0 0 * * *",
        timezone="America/New_York"),
)
i

Ilhom Hayot o'g'li

05/23/2022, 12:42 PM
ok I got about cron part... How about running 2 flows independently?
a

Anna Geller

05/23/2022, 12:44 PM
that works natively with Prefect, no need to do anything else here 🙂 you can just schedule two flows with the same schedule/cron expression
i

Ilhom Hayot o'g'li

05/23/2022, 1:10 PM
ok lets explain with img its faster. I need flow that runs other flows
a

Anna Geller

05/23/2022, 1:55 PM
the syntax I shared before was for Prefect 2.0 - in Prefect 2.0 there is a concept of subflows allowing you to call flows from other flows by calling those as any other function
i

Ilhom Hayot o'g'li

05/23/2022, 1:57 PM
what is about prefect==1.2.0 is that possible in that version too?
a

Anna Geller

05/23/2022, 2:01 PM
no, Prefect 2.0 is a completely new product with a different API behind it
in Prefect 1.0 (we're talking 1.0 as a generation of a product, not a specific version) there is a concept of flow of flows (aka "orchestrator pattern") allowing you to call a flow from another flow - you can read more about it here (including many examples)
This was exact answer which I found from your link
Thank you for your care👍
a

Anna Geller

05/23/2022, 2:40 PM
that's fantastic, so glad this has helped 🙌
please only cross-check the syntax - the article was using a much older Prefect version
i

Ilhom Hayot o'g'li

05/23/2022, 2:42 PM
sure thanks
👍 1
5 Views