State machine templating system
State Machine Templating System
What it does
This system makes it much simpler to
- Add new state machines
- Add new state machine templates
- Modify existing state machines/templates
- Ensure correctness of state machines
Now, when the system starts up, it looks through a new table capability_state_machines
and grabs all the defined state machines from there. Once it has all those machines in code, it clears the existing state machine tables (capability_state_transitions
and capability_state_actions
), and persists the new machines as defined in their in-code classes (which can be found in state_machine_schema.py
).
How to use it
- To add a new state machine, add a new entry to the
capability_state_machines
table - To change the state machine type of an existing capability state machine, modify the
machine_type
column of the existing entry - To modify a state machine template (the machine itself), go into
state_machine_schema.py
and modify the state machine dictionary representation in theinit_state_machine
method of the corresponding state machine class you want to edit (right now there's onlySimpleStateMachin
andSingleQAStateMachine
) - To add a new state machine template, create a new class in
state_machine_schema.py
and fill in itsinit_state_machine
method