Hi, Is there a way to trigger a flow/s from anothe...
# ask-metaflow
b
Hi, Is there a way to trigger a flow/s from another flow automatically when it has finished?
1
👍 1
f
This is one way to achieve it
b
Hi, thanks for answering! couple of questions: 1. does this also apply if i have flow_a that is a prerequisite for flow_b & flow_c (where flows b + c are not related or connected in any way) 2. when you say
flow_b.py
will then interrogate
.flow/
to look for the highest
.flow/FlowA<runid>
file, we are talking that it will query for my namespaced flow highest run-id, right? 3. Does flow_b know automatically that flow_a is its prerequisite, or i need to mention that in some way?
b
I second these questions. thanks for asking 🤗
v
yes! Great timing with the question! There’s a
@trigger_on_finish
decorator that allows you to launch a flow on Argo Workflows when another finishes. It’s very new - we’ll be officially announcing it in a few days excited It’ll show up in docs then too
🙌 1
b
Yep, I have noticed it in the latest version and tried to use it but I’m missing some env vars that relates to Argo events. I still need to check out the values for them Great, Thanks! Can’t wait 👌
v
even triggering is finally available! https://docs.metaflow.org/production/event-triggering/
b
I just saw it! 🤩 thanks!! I went over it and wanted to ask if we can have Multiple (optional) events that will trigger the flow with multiple configs: @trigger(events=[“first event”, “second event”]) (And have multiple flows being triggered) Or alternatively if I can pass metadata for one event? (and I will post several events to trigger the flow multiple times)) I’m asking cause I have a generic flow that runs a certain logic (importing the logic on the fly) depends on input params, and I want to see if I can trigger multiple flows like that 😋
v
you can think of event name as "a topic" in event-bus terms, so you define one topic you depend on but then each event instance can have an arbitrary payload that configures the logic on the fly
so instead of having
events=['first event', 'second event']
you can depend on a single
event='some_event'
but parametrize the behavior based on the payload
Copy code
mode = Parameter('mode')
that you can set for each event/run individually:
ArgoEvent().publish(payload={'mode': 'dothis'})
like you suggested, you can certainly implement this by importing the desired business logic from a module on the fly, depending on the
mode
parameter like here
would this work?
b
Interesting! Thanks, I think it will serve my needs 🙏
👍 1