Skip to content

Looper Node

kleer001 edited this page Feb 6, 2025 · 1 revision

Looper Node

A powerful node for iterative processing of data with configurable loop behavior. Enables iterative operations by managing internal input and output connections, making it ideal for tasks that require repeated processing or accumulation of results. Functions similarly to a sophisticated 'for' loop while maintaining node graph connectivity.

Parameters

Core Loop Control

min (int)

Starting value for the loop iteration. Must be non-negative.

max (int)

Ending value for the loop iteration. Must be non-negative.

step (int)

Increment value between iterations. Cannot be zero. Can be negative for reverse iteration.

Loop Behavior

max_from_input (bool)

When enabled, sets max iterations based on input data length.

feedback_mode (bool)

Enables feedback loop mode where each iteration's output feeds into the next.

Testing Options

use_test (bool)

When enabled, runs only a single test iteration.

test_number (int)

Specific iteration to run when use_test is enabled. Must be between min and max.

cook_loops (bool)

Controls whether to force cook operations on each loop iteration.

Advanced Configuration

input_hook (str)

Custom input processing hook (advanced usage).

output_hook (str)

Custom output processing hook (advanced usage).

Resource Limits

timeout_limit (float)

Maximum execution time in seconds. Default: 300.0

data_limit (int)

Maximum memory usage in bytes. Default: 200MB

Operation Modes

Standard Loop

  • Iterates from min to max by step
  • Each iteration processes fresh input data
  • Example: Processing a series of numbered files or generating sequences

Input-Driven Loop

  • Activated with max_from_input=True
  • Number of iterations matches input data length
  • Ideal for processing lists or arrays item by item
  • Example: Processing each item in a list with complex operations

Feedback Loop

  • Activated with feedback_mode=True
  • Output of each iteration becomes input for the next
  • Useful for recursive or cumulative operations
  • Example: Iterative refinement or accumulation of results

Test Mode

  • Activated with use_test=True
  • Runs single iteration specified by test_number
  • Useful for debugging and development
  • Example: Testing specific iteration behavior without running full loop

Technical Details

Safety Features

  • Timeout protection via timeout_limit
  • Memory usage limits via data_limit
  • Automatic cleanup of stale loops
  • Parameter validation to prevent invalid configurations

Internal Structure

The node operates using two internal nodes:

  • inputNullNode: Handles input data for each iteration
  • outputNullNode: Collects and manages output from each iteration

Important Notes

  • Iterations stop if timeout_limit is reached
  • Warns if iterations produce null/blank values
  • Last valid output is preserved in staging_data
  • All iterations must process List[str] data types

Usage Examples

Basic Counting Loop

min=1, max=10, step=1
# Result: Processes 10 iterations

Input-Driven Processing

max_from_input=True
# Result: Iterations match input data length

Feedback Processing

feedback_mode=True
# Result: Each iteration processes previous iteration's output

Debug Specific Iteration

use_test=True, test_number=5
# Result: Only processes iteration #5

Clone this wiki locally