flowrep.nodes.if_recipe module
- class flowrep.nodes.if_recipe.IfRecipe(*, type: Literal[RecipeElementType.IF] = RecipeElementType.IF, inputs: Annotated[list[Annotated[str, BeforeValidator(func=_validate_label, json_schema_input_type=PydanticUndefined)]], AfterValidator(func=validate_unique)], outputs: Annotated[list[Annotated[str, BeforeValidator(func=_validate_label, json_schema_input_type=PydanticUndefined)]], AfterValidator(func=validate_unique)], description: str | None = None, cases: list[ConditionalCase], else_case: LabeledRecipe | None = None, input_edges: dict[TargetHandle, InputSource], prospective_output_edges: dict[OutputTarget, Annotated[list[SourceHandle], AfterValidator(func=validate_unique)]])[source]
Bases:
NodeRecipeWalk through one or more cases, executing and returning the body result for the first case with a positive condition evaluation. This is a dynamic node, which must actualize the body of its subgraph at runtime.
Intended recipe realization: 1. Instantiate the first case’s condition node 2. Connect input to this node according to input edges 3. Execute and evaluate the condition node 4. If it evaluates negatively, repeat steps (1-3) as long as new cases are available 5. If it evaluates positively (or finally for the else case if it is provided),
instantiate, connect, and execute the body node as for the condition node(s)
- Use the matrix of output edges to connect the output of the actualized case
body/else case to the node outputs
- type
The node type – always “if”.
- Type:
Literal[base_models.RecipeElementType.IF]
- inputs
The available input port names.
- outputs
The available output port names.
- cases
The condition-body pairs to be walked over searching for a positive condition evaluation.
- Type:
- input_edges
Edges from workflow inputs to inputs of body node instances.
- Type:
edge_models.InputEdges
- prospective_output_edges
For each output, sources from each possible body node to fill that output. Note that exactly one of these possible edges will be actualized at runtime based on which body/else case node actually runs.
- Type:
dict[edge_models.OutputTarget, base_models.UniqueList[edge_models.SourceHandle]]
- else_case
Optional body node to execute if no positive case condition can be found.
- Type:
helper_models.LabeledRecipe | None
Note
In this way, the if-node is guaranteed to have a concrete set of outputs which are fulfilled, regardless of which case runs internally. In the event that none of the conditional cases evaluate and no else case is provided, these outputs will be left in a state of non-data.
- cases: list[helper_models.ConditionalCase]
- else_case: helper_models.LabeledRecipe | None
- input_edges: edge_models.InputEdges
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- property prospective_nodes: Recipes
- prospective_output_edges: dict[edge_models.OutputTarget, base_models.UniqueList[edge_models.SourceHandle]]
- type: Literal[base_models.RecipeElementType.IF]