teff.graph.conditions¶
teff.graph.conditions
¶
Edge condition parsing and evaluation.
Conditions are lightweight string expressions attached to edges. They
are evaluated against the current workflow state to decide which node
runs next. Splitting them out from the :class:~teff.graph.Graph class
keeps the execution engine free of expression-language details.
Functions:
| Name | Description |
|---|---|
evaluate |
Whether condition matches state. |
find_error_edge |
Return the |
matched_condition |
Return the condition of the first edge matching state and target_id. |
resolve_edge |
Return the target of the first edge matching state, or |
evaluate
¶
evaluate(condition, state)
Whether condition matches state.
Supports equality/inequality on string keys, comma-separated
disjunctions (key=a,b), numeric comparisons
(key>=N / key<=N / key>N / key<N), and callable
predicates fn(state) -> bool (evaluated verbatim).
Source code in teff/graph/conditions.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
find_error_edge
¶
find_error_edge(edges, node_id)
Return the __error__ edge leaving node_id, if any.
Source code in teff/graph/conditions.py
106 107 108 109 110 111 | |
matched_condition
¶
matched_condition(edges, state, target_id)
Return the condition of the first edge matching state and target_id.
Source code in teff/graph/conditions.py
124 125 126 127 128 129 130 131 132 133 | |
resolve_edge
¶
resolve_edge(edges, state)
Return the target of the first edge matching state, or None.
Source code in teff/graph/conditions.py
114 115 116 117 118 119 120 121 | |