https://prefect.io logo
Title
d

Dragan

12/01/2022, 11:10 AM
Hi all, maybe a basic question, but here goes We have a flow that is triggered to run every hour In random situations we have longer calculations that make the job run for more than an hour Is there a validation that can be added that a flow should not start before previous one finishes, something like
wait until finish
if it is running in same flow, we can check triggers, but can we do it on the flow level?
k

Khuyen Tran

12/02/2022, 4:41 PM
Are you using Prefect 2?
d

Dragan

12/04/2022, 9:14 AM
No, we still haven’t migrated, but we plan to do it in next couple of weeks If this is doable in version 2, this would be an even more reason to hurry up with the migration process
is it available in Prefect 2 or in 1 at all?
k

Khuyen Tran

12/06/2022, 5:25 PM
You can use
wait_for
with tasks in 2.0. Here is the doc for that
Off the top of my head, you can make sure one flow run after another one finishes in 2.0 by using subflows:
from prefect import flow

@flow 
def run_first():
  ...

@flow 
def run_second():
  ...

@flow
def main():
  run_first()
  run_second()
d

Dragan

12/07/2022, 10:44 AM
Perfect, thank you, we will try it out
but not sure if this would work, since this is the same flow and has multiple runs, so it will run hourly and we can’t really define run_first() or run_second() hence this is the same flow just running hourly so the idea would be that if in the same flow we have multiple runs and one of them runs longer, we simply tell the next run to wait