When developing a suite of Apps using the Virtualitics SDK, chaining multiple Apps together allows for modular, reusable workflows where each App handles specific tasks like data preprocessing, analysis, or visualization.
Chaining Apps automates workflows, ensuring consistent results and saving time by passing data and execution control seamlessly between Apps. It also enables dynamic interactions, where one App’s output can refine the behavior of the next, creating adaptable, multi-step analyses. This article explains how to trigger one App from within another.
Triggering Another App to Run
To trigger another App to run from within a Step of your current App, 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 App, you will call the trigger_flow_execution()
function which appears under “trigger” in the Virtualitics SDK.
Using these two functions together, you can now successfully trigger an App at the completion of a Step in the user’s original flow. Below is an example of triggering an App named TriggerFlowTest.
When this step completes successfully, TriggerFlowTest will be started. You can find a newly created run of this App in the App History tab in the left navigation bar of the Virtualitics AI Platform (VAIP).
from virtualitics_sdk 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("TriggerFlowTest", store_interface=store_interface)
What to Expect
Once this code executes, if you navigate to the App History Page, you will see that a new flow has been created based on the "TriggerFlowTest" App.
You can also optionally define input parameters within the trigger_flow_execution()
function which will be passed to the triggered app. For example, if TriggerFlowTest contains two drop-downs titled “Dropdown One” and “Dropdown Two” on the “Data Input” Step, you can set the argument values for these drop-downs like so:
trigger_flow_execution(flow_name="TriggerFlowTest",
store_interface=store_interface,
input_parameters={"steps": {
"Data Input": {
"Dropdown One": {"value": "A", "description": "", "card_title": "User Input Card"},
"Dropdown Two": {"value": "B", "card_title": "User Input Card"}}}})
Any input parameters will be used to supply default values to the inputs of a specific Step. The input parameters have a syntax as follows:
{
"steps": {
"{step_name}": {
"{element_title}": {
"value": "{value to pass to element's update_from_user_input function}",
"description": "{optional description}",
"card_title": "{title of the card that contains this element}"
}
}
}
}