https://prefect.io logo
Title
m

Matthew Seligson

04/21/2022, 4:25 PM
What’s the best practice for starting the run of a subflow X hours after the start of a flow? I have a StartFlowRun task that takes a scheduled_start_time. But will that scheduled start time get fixed at flow registration time? This should be dynamic depending on the start of the main flow.
k

Kevin Kho

04/21/2022, 4:55 PM
create_flow_run
takes in a delay so you can schedule it a few hours later. There was a recent PR for that. Is that what you need?
m

Matthew Seligson

04/21/2022, 5:44 PM
What if we need more complex scheduling of subflows than just a delay? Like suppose we wanted to start the subflow immediately if it’s past noon, otherwise wait until noon.
k

Kevin Kho

04/21/2022, 5:48 PM
You can have a task beforehand that makes the inputs into
create_flow_run
because that is the run method already you are calling
m

Matthew Seligson

04/21/2022, 8:16 PM
Is there a reason we can’t use StartFlowRun?
k

Kevin Kho

04/21/2022, 8:19 PM
It doesn’t have the keyword argument for the delay to start the new flow run. You could have a task that produces the
scheduled_start_time
and you then pass it to
StartFlowRun
create_flow_run
was introduced just because
StartFlowRun
has an inconsistent return depending if
wait=True/False
. If you do
wait=True
, it’s very hard to new the new flow run id. So these functions were decoupled to
create_flow_run
and
wait_for_flow_run
m

Matthew Seligson

04/21/2022, 8:21 PM
I think the difference is that with StartFlowRun, the scheduled start time parameter is an INIT parameter and not a RUN parameter. I think you couldn’t generate a start time in a task and then pass it to StartFlowRun
k

Kevin Kho

04/21/2022, 8:22 PM
I see it in the run. I think as long you are on 0.15.0+, it should be around?
m

Matthew Seligson

04/21/2022, 8:27 PM
Ah nice! That seemed to work
k

Kevin Kho

04/21/2022, 8:28 PM
Nice!