Control Pipeline
Flow
This guide addresses how to programmatically control the Pipeline
UI flow.
By default, controlling the flow between different stages is done using the "Previous" and "Next" buttons. However, we often want to control the UI flow programmatically from within a stage. We can do this with the following parameters:
The
ready_parameter
can block (False
) or unblock (True
) potential advancement to the next stage.The
auto_advance
parameter will automatically advance to the next stage if unblocked by theready_parameter
.The
next_parameter
argument can be used to dynamically set which stage will be next.
In this way we can control the workflow programmatically from inside the stages.
In the example below we create a branching and converging workflow that can be used without the buttons by declaring ready_parameter
and auto_advance
for each of the stages, which we can toggle with a custom button or simply set to True
by default to automatically proceed to the next stage.
We will also control which branching stage to switch to from within a stage by declaring a parameter which will hold the name of the next stage to switch to. In this case, we create a parameter to select between Add
and Multiply
stages. Later, we will point the pipeline to this parameter using the next_parameter
argument.
First, let's create our stages:
Now let's add the stages to a pipeline and define the graph:
Finally we display the pipeline without the Next
button, which is appropriate because all the flow control is now handled from within the stages:
As you can see, a panel Pipeline can be used to set up complex workflows when needed, with each stage controlled either manually or from within the stage, without having to define complex callbacks or other GUI logic.
Here is the complete code for this section in case you want to easily copy it:
Related Resources
The How to > Customize Pipeline Layout guide provides some context for the custom layout used here.
The How to > Create a Non-Linear Pipeline guide walks through the creation of branching pipeline that commonly used in the context of controlling pipeline flow.