Transition#
This module defines a transition class that is used to specify conditions and destinations for transitions to nodes.
- class Transition(*, cnd=True, dst, priority=None)[source]#
Bases:
BaseModelA basic class for a transition to a node.
- cnd: AnyCondition#
A condition that determines if transition is allowed to happen.
- dst: AnyDestination#
Destination node of the transition.
- priority: AnyPriority#
Priority of the transition. Higher priority transitions are resolved first.
- async get_next_label(ctx, transitions, default_priority)[source]#
Determine the next node based on
transitionsandctx.The process is as follows:
Condition result is calculated for every transition.
Transitions are filtered by the calculated condition.
Priority result is calculated for every transition that is left.
default_priorityis used for priorities that returnTrueorNoneas perBasePriority. Those that returnFalseare filtered out.Destination result is calculated for every transition that is left.
The highest priority transition is chosen. If there are multiple transition of the higher priority, choose the first one of that priority in the
transitionslist. Order oftransitionsis as follows:node transitions, local transitions, global transitions.
If at any point any
BaseCondition,BaseDestinationorBasePriorityproduces an exception, the corresponding transition is filtered out.- Return type:
Optional[AbsoluteNodeLabel]- Returns:
Label of the next node or
Noneif no transition is left by the end of the process.