control
control
#
Procedures that manage conditional logic and program flow.
Control flow procedures manage conditional logic, assertions, and program flow within workflows. These enable dynamic behavior, validation, and decision-making based on data conditions, user input, and runtime state.
AssertBool
#
Assert that a boolean condition is true, failing with a message if false.
Used to validate conditions and assumptions during procedure execution. If the condition evaluates to false, the procedure will fail with the provided error message.
Attributes:
| Name | Type | Description |
|---|---|---|
condition |
Input[Bool]
|
The boolean condition that must be true. |
text |
Input[String]
|
Error text shown to the user if the condition is false. |
Source code in capturegraph-lib/capturegraph/procedures/nodes/process/control.py
DoNothing
#
Do nothing and return immediately (no-op).
Useful as a placeholder or default branch in conditional logic where one path should perform no action.
Source code in capturegraph-lib/capturegraph/procedures/nodes/process/control.py
IfThenElse
#
Bases: Procedure[T]
Execute one of two branches based on a boolean condition.
Executes the true or false branch depending on the condition's result.
Both branches must return the same type T. This enables dynamic
workflows that adapt based on user input, data conditions, or environmental
factors. The with cg.when(condition): block builds the common one-sided
case (a DoNothing false branch); construct this node directly for a
two-sided branch.
Attributes:
| Name | Type | Description |
|---|---|---|
condition |
Input[Bool]
|
Boolean procedure to evaluate. |
true_branch |
Input[T]
|
Procedure to execute if condition is true. |
false_branch |
Input[T]
|
Procedure to execute if condition is false. |
Source code in capturegraph-lib/capturegraph/procedures/nodes/process/control.py
NullProcedure
#
Bases: Procedure[T]
Return a null/empty value of type T.
Used as a placeholder that produces no actual data but maintains type compatibility. Useful for optional branches or default values.
Attributes:
| Name | Type | Description |
|---|---|---|
output_type |
Setting[type[T]]
|
The CGType this procedure returns. Consumed at
construction — |
Example
Source code in capturegraph-lib/capturegraph/procedures/nodes/process/control.py
__post_init__()
#
Consume output_type into _return_type and clear the setting.
Source code in capturegraph-lib/capturegraph/procedures/nodes/process/control.py
ProcedureCompleted
#
Report whether a procedure completes successfully, as a boolean.
Runs procedure and returns true when it produces a value, false
when it fails — without propagating the failure. This turns a value's mere
presence into a condition: pairing it with LoadPath asks "is there a value
at this position?" (the basis of path.exists()), which gates a block with
cg.when(...) rather than letting a missing value abort the run.
Attributes:
| Name | Type | Description |
|---|---|---|
procedure |
Procedure[CGType]
|
The procedure whose completion is tested; its value is discarded. |