Adding conditions to the pipeline
Add conditions to a pipeline to handle various scenarios.
Configuring conditions for the pipeline
As you create a pipeline, you can specify conditions that must be met before you run the pipeline. For example, you can set a condition that the output from a node must satisfy a particular condition before you proceed with the pipeline execution.
To define a condition:
-
Hover over the link between two nodes.
-
Click Add condition.
-
Choose the type of condition:
- Condition Response checks a condition on the status of the previous node.
- Simple condition is a no-code condition in the form of an if-then statement.
- Advanced condition Advanced condition uses expression code, providing the most features and flexibility.
-
Define and save your expression.
When you define your expression, a summary captures the condition and the expected result. For example:
If Run AutoAI is Successful, then Create deployment node.
When you return to the flow, you see an indicator that you defined a condition. Hover over the icon to edit or delete the condition.
Configuring a condition based on node status
If you select Condition Response as your condition type, the previous node status must satisfy at least one of these conditions to continue with the flow:
- Completed - the node activity is completed without error.
- Completed with warnings - the node activity is completed but with warnings.
- Completed with errors - the node activity is completed, but with errors.
- Failed - the node activity failed to complete.
- Cancelled - the previous action or activity was canceled.
Alternatively, you can select Otherwise, execute next action when specified conditions for other nodes connected from the same parent are not met.
Customizing link colors
The color of the links can now be changed depending on whether their condition was met. You must update the colors of the links by clicking the link and then clicking Change color. The default colors are as follows:
- Green if node execution was successful.
- Yellow if node execution completed with warnings.
- Red if node execution failed.
- Military green if nodes have no conditions.
- Blue if nodes have an advanced condition, such as user status, return value, or custom.
- Black if node conditions do not meet any conditions above.
Configuring a simple condition
To configure a simple condition, choose the condition that must be satisfied to continue with the flow.
- Optional: edit the default name.
- Depending on the node, choose a variable from the drop-down options. For example, if you are creating a condition based on a Run AutoAI node, you can choose Model metric as the variable to base your condition on.
- Based on the variable, choose an operator from: Equal to, Not equal to, Greater than, Less than, Greater than or equal to, Less than or equal to.
- Specify the required value. For example, if you are basing a condition on an AutoAI metric, specify a list of values that consists of the available metrics.
- Optional: click the plus icon to add an And (all conditions must be met) or an Or (either condition must be met) to the expression to build a compound conditional statement.
- Review the summary and save the condition.
Configuring an advanced condition
Use coding constructs to build a more complex condition. The next node runs when the condition is met. You build the advanced condition by using the expression builder.
- Optional: edit the default name.
- Add items from the Expression elements panel to the Expression canvas to build your condition. You can also type your conditions and the elements autocomplete.
- When your expression is complete, review the summary and save the condition.
Learn more
For more information on using the code editor to build an expression, see:
- Functions used in pipelines Expression Builder
- DataStage Functions used in pipelines Expression Builder
Parent topic: Creating a pipeline