The execution workflow of the PipeLoop Snap enables the parent pipeline to control and manage iterative processes using the child pipeline, for scenarios where repeated processing is needed until a specific condition is satisfied. Here are the key steps in the execution of the PipeLoop Snap:
The parent pipeline passes the input document to the child pipeline.
The child pipeline executes.
The PipeLoop Snap collects the output document from the child pipeline.
The PipeLoop Snap evaluates the stop condition based on the child pipeline’s output document.
If the stop condition is false, the Snap checks if the iteration limit is reached.
If the iteration limit is not reached, the Snap passes the output document to input (back to Step 1). The iteration stops if the stop condition is evaluated to true or the iteration limit is reached.”
Example
The following example pipeline demonstrates the flow of PipeLoop Snap.This example pipeline demonstrates how to use the PipeLoop Snap to iteratively execute a child pipeline that increments a numerical value until it reaches the specified threshold.
Broadly, the pipelines perform the following tasks:
Parent pipeline: The parent pipeline generates the initial input using the JSON Generator Snap. The PipeLoop Snap iteratively calls the child pipeline until the condition specified in the Stop condition is met or the iteration limit is reached.
Child pipeline: The Mapper Snap in the child pipeline processes the mapping and transformation of data as needed during each iteration.
...
...
Parent Pipeline
Configure the JSON Generator Snap with the input parameters to pass to the PipeLoop Snap. This Snap generates the initial input data for the PipeLoop Snap and the JSON data produced here will be passed as input to the child pipeline.
Configure the PipeLoop Snap with the following settings:
Select the child pipeline to call within the PipeLoop Snap.
If your pipeline requires specific parameters for the run, set up the Pipeline parameters.
Specify the Stop condition. This condition determines when the iteration should terminate. The stop condition is evaluated after each iteration from the first (or only) document coming out from the child pipeline. If the stop condition is not met after the specified number of iterations based on the iteration limit, the loop will terminate automatically. Configure the Iteration limit:
Configure the error handling settings in the Views tab as needed.
Child Pipeline
This pipeline increments the $num
variable by 1 and adds the passed-in _foo
parameter to the output document.
...