What’s the best practice for starting the run of a...
# ask-community
m
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
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
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
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
Is there a reason we can’t use StartFlowRun?
k
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
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
I see it in the run. I think as long you are on 0.15.0+, it should be around?
m
Ah nice! That seemed to work
k
Nice!