Skip to content

State machine templating system

Nathan Hertz requested to merge state-machine-templating into main

State Machine Templating System

What it does

This system makes it much simpler to

  1. Add new state machines
  2. Add new state machine templates
  3. Modify existing state machines/templates
  4. 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 the init_state_machine method of the corresponding state machine class you want to edit (right now there's only SimpleStateMachin and SingleQAStateMachine)
  • To add a new state machine template, create a new class in state_machine_schema.py and fill in its init_state_machine method

Merge request reports