Skip to content

procedure

procedure #

Procedure operator procedures perform meta-operations on other procedures.

ProcedureEqual compares two results; ProcedureOr provides fallback. Whether a procedure produced a value is asked with ProcedureCompleted (the basis of path.exists()); conditionality is otherwise expressed with data dependencies and cg.do_optional().

ProcedureEqual #

Bases: Procedure[Bool]

Compare two procedures, returning true if their results are equal.

Evaluates both procedures and returns true if their results are equivalent, false otherwise. Useful for validation and conditional logic based on procedure outputs.

Attributes:

Name Type Description
left Input[CGType]

The first procedure to compare.

right Input[CGType]

The second procedure to compare.

Source code in capturegraph-lib/capturegraph/procedures/nodes/process/operators/procedure.py
@make_procedure
class ProcedureEqual(Procedure[Bool]):
    """Compare two procedures, returning true if their results are equal.

    Evaluates both procedures and returns true if their results are
    equivalent, false otherwise. Useful for validation and conditional
    logic based on procedure outputs.

    Attributes:
        left: The first procedure to compare.
        right: The second procedure to compare.
    """

    left: Input[CGType]
    right: Input[CGType]

ProcedureOr #

Bases: Procedure[T]

Return the result of the first procedure, or the second if the first fails.

Attempts the primary procedure first; if it fails or returns null, the fallback runs instead. Both procedures must return the same type T.

Attributes:

Name Type Description
primary Input[T]

The procedure to attempt first.

fallback Input[T]

The procedure to use if primary fails.

Source code in capturegraph-lib/capturegraph/procedures/nodes/process/operators/procedure.py
@make_procedure
@forward_types(CGType, "primary", "fallback")
class ProcedureOr[T: CGType](Procedure[T]):
    """Return the result of the first procedure, or the second if the first fails.

    Attempts the primary procedure first; if it fails or returns null, the
    fallback runs instead. Both procedures must return the same type ``T``.

    Attributes:
        primary: The procedure to attempt first.
        fallback: The procedure to use if ``primary`` fails.
    """

    primary: Input[T]
    fallback: Input[T]