Hi all, I’m building a <dependent flow>, and want...
# ask-community
a
Hi all, I’m building a dependent flow, and wanted to verify if my understanding of a limitation there is correct, or am I missing something. Assuming I have something like the following script (simplified from the example in the docs):
Copy code
flow_a = StartFlowRun(flow_name="A", project_name="examples", wait=True)
flow_b = StartFlowRun(flow_name="B", project_name="examples", wait=True)

## Flow of flows

with Flow("parent-flow") as flow:
    flow_b.set_upstream(flow_a)

flow.run()
as far as I can see, running this script waits with the scheduling of
flow_b
, until
flow_a
is completed. Is there a way to schedule them both, but wait with running
flow_b
until
flow_a
is completed? My use case is I use a VM to run the flows, but my local machine (or phone) to run a small script that schedules them ad-hoc.
flow_a
is often long, while
flow_b
is a short one - and so as it currently stands any issues with my local machine might interrupt scheduling
flow_b
. There are a couple of ways I can imagine to solve this, but I wanted to make sure if my understanding is correct, or if there is a way to schedule both at and create a dependency for the
running
of the flow?
k
Hey @Amit Gal! Just to be clear, the issue is that
flow_b
is scheduled after
flow_a
. You want
flow_b
to be scheduled so that if
flow_a
fails,
flow_b
would still trigger right?
There is no built-in mechanism for this. I would probably put a state handler on
flow_a
to schedule
flow_b
whether it fails or succeeds. This won't work though if the local machine just dies completely.
a
Thanks @kevin! You’re correct that I want
flow_b
to run whether
flow_a
was successful or not. However, it should only run after
flow_b
finished (successfully or not). My issue is literally that the scheduling of
flow_b
occurs after
flow_a
finishes running, while what I’d like to happen is to schedule both of them at the same time, with the logic of “`flow_b` after `flow_a`”, and then I could shut down my local machine.
k
Did you try
wait=False
in the StartFlowRun?
a
I did now, but not getting the result I am looking for. Setting
wait=False
for
flow_b
does schedule both together, but without the logic ensuring
flow_b
runs only after
flow_a
is finished. The
state_handler
idea is interesting, I am going to look into it and see if I can make it work. Thanks for your thoughts!