Condition
junjo.Condition
Kind: Class
SDK version: 0.64.0
Documentation channel: Next source preview
Abstract base class for edge conditions in a workflow graph.
Implement a concrete condition that determines whether a transition along an edge should occur based only on the current state.
This is designed to be used with the Edge class, which
represents a directed edge in the workflow graph. The condition is
evaluated when determining whether to transition from the tail node to the
head node.
StateT is the state type that the condition evaluates against. It
should be a subclass of BaseState.
Conditions should follow these rules:
- The condition should be stateless and depend only on the current state.
- Do not use side effects in the condition, such as network calls or database queries.
- The condition should be a pure function of the state.
.. rubric:: Example
``python class MyCondition(Condition[MyState]): def evaluate(self, state: MyState) -> bool: return state.some_property == “some_value”
my_condition = MyCondition() edges = [ Edge(tail=node_1, head=node_2, condition=my_condition), Edge(tail=node_2, head=node_3), ] ``
Members
Section titled “Members”evaluate
Section titled “evaluate”evaluate(state: StateT) -> boolEvaluate whether the transition should occur based on the current workflow state.
Parameters
Section titled “Parameters”| Name | Type | Description | Default |
|---|---|---|---|
state |
StateT |
The current workflow state. |
Returns
Section titled “Returns”bool:Trueif the transition should occur,Falseotherwise.