When developing a set of Flows, you may need to chain Flows together. This article covers the steps necessary to run a Flow as a step in a different one.
Triggering Another Flow
In order to trigger another Flow from within a Step, you will need to implement the on_run_success()
function of the Step
abstract base class. This function can execute arbitrary callbacks on completion of a Step.
In order to actually trigger a separate Flow, you will call the trigger_flow_execution
function from predict_backend.page.utils
.
Using these two functions together, you can now successfully trigger a Flow at the completion of a Step in your original flow. Below is an example of triggering a flow named DashboardTestFlow
.
When this step completes successfully, a new Flow DashboardTestFlow
will be started. You can find the Flow in the Flows Management Console.
from predict_backend.page.utils import trigger_flow_execution
class SimpleStep(Step):
def run(self, flow_metadata):
pass
def on_run_success(self, store_interface, *args, **kwargs):
trigger_flow_execution('DashboardTestFlow', store_interface=store_interface)
What to Expect
If you go to the Flows Management Console, you will see that the second Flow ("Dashboard Test Flow") has successfully completed.
Previous Article |
Next Article |