Goal
The goal of this system is to make it easy to:
- Add/remove state machines from Workspaces
- Add/remove state machine types from Workspaces
- Change the type of a capability's state machine (e.g. make
null
have QA or makestd_calibration
have two-stage QA) - Ensure correctness of state machines
- Modify existing state machine templates from within Python and eliminate the need for tedious/error-prone database table manipulation
Design
Overview
The short version of the design is that I want to add a state machine initialization step to the initialization process of the system. This state machine initialization will perform the following steps:
- Clear the following tables of entries:
capability_state_transitions
capability_state_actions
- Get the list of state machines from a new database table:
capability_state_machines
capability_state_machines
definition: Three columns:capability_name: varchar
(primary key)- and
machine_type: varchar
- For each entry in that table, populate
capability_state_transitions
andcapability_state_actions
based on in-code definitions (using SQLAlchemy model objects)
New files
state_machine_info.py
- Parallel tocapability_info.py
; performs necessary CRUD database operations for state machine manipulation/initializationstate_machine_schema.py
- Holds declarative model for state-machine table
Unanswered questions
- How should the in-code state machine representations be coded? I want to use SQLAlchemy model classes, but is it possible?
- My plan to answer this is to just mess around in-code and see how easy/hard it is to hard-code the definitions in
- Is clearing/re-creating those two tables every time the system starts up a good idea? Should I instead do an audit of those tables to check that all the appropriate rows are in place and no additional ones are (harder and more time-consuming)?