|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
Functions | |
| dict | config_to_dict (PintleEngineConfig config) |
| upload_config (UploadFile file=File(...), UserSession session=Depends(get_session), None _=DesignCheckout) | |
| get_config (UserSession session=Depends(get_session)) | |
| load_config_json (dict body, UserSession session=Depends(get_session)) | |
| get_parameters (UserSession session=Depends(get_session)) | |
| get_switch_options (UserSession session=Depends(get_session)) | |
| get_injector_schema (str|None injector_type=None, UserSession session=Depends(get_session)) | |
| switch_config_endpoint (dict body, UserSession session=Depends(get_session), None _=DesignCheckout) | |
| update_config (dict updates, UserSession session=Depends(get_session), None _=DesignCheckout, str|None expect_sha256=Query(default=None, max_length=64, pattern="^[0-9a-f]{64}$")) | |
Variables | |
| router = APIRouter(prefix="/api/config", tags=["config"]) | |
Config management endpoints.
| dict backend.routers.config.config_to_dict | ( | PintleEngineConfig | config | ) |
Convert Pydantic config to JSON-serializable dict.
Definition at line 16 of file config.py.
Referenced by get_config(), load_config_json(), switch_config_endpoint(), update_config(), and upload_config().
| backend.routers.config.get_config | ( | UserSession | session = Depends(get_session) | ) |
Get the current config as JSON.
Definition at line 79 of file config.py.
References config_to_dict().
| backend.routers.config.get_injector_schema | ( | str | None | injector_type = None, |
| UserSession | session = Depends(get_session) ) |
| backend.routers.config.get_parameters | ( | UserSession | session = Depends(get_session) | ) |
| backend.routers.config.get_switch_options | ( | UserSession | session = Depends(get_session) | ) |
| backend.routers.config.load_config_json | ( | dict | body, |
| UserSession | session = Depends(get_session) ) |
Replace the current config with a full config dict (not a merge). Deliberately NOT behind the checkout, unlike the other write routes here. This is how the design bar loads a design into your session when you open it -- including read only -- so gating it would make a design you may only view impossible to open at all. It writes your own session, never the stored design; saving that back is /autosave's job, and that is gated. The per-user saved-config library (/api/configs) stores a complete config; loading it must replace app_state wholesale. PUT deep-merges partial updates, which would leave stale keys behind when the saved config is a different injector type than the one currently loaded.
Definition at line 88 of file config.py.
References config_to_dict().
| backend.routers.config.switch_config_endpoint | ( | dict | body, |
| UserSession | session = Depends(get_session), | ||
| None | _ = DesignCheckout ) |
Switch injector type and/or propellant, auto-reconciling the config to the right physics.
Body: {"injector_type": "pintle"|"impinging"|null, "propellant_preset": "methalox"|...|null}.
Injector change LOADS THE CANONICAL config for that type wholesale (configs/canonical/<type>.yaml);
the two canonical configs are intentionally independent (pintle fixed Cd vs impinging geometry-Cd —
they must NOT stay in sync). Propellant change overlays the preset identity onto the live geometry.
Then validates and stores. This is the engine behind the UI's first-class injector/propellant toggles.
IN-MEMORY ONLY: a quick injector/propellant toggle must NOT overwrite the config file on disk —
doing so silently clobbered configs/default.yaml when a user flipped the dropdown. The switch
updates app_state (so it holds for the session); persisting is an explicit Save action, not a
side effect of toggling.
A propellant overlay leaves the chamber seeded for the previous propellant; the response carries a
``design_warning`` ("needs re-optimization") so the UI can flag the design as a seed, not a solution.
That is the chamber's staleness only: fluid properties off their preset (a canonical config's
stale LOX block, say) come back separately as ``fluid_warning`` -- the chamber is still valid,
and a clean injector swap must not read as "needs re-optimization".
Definition at line 172 of file config.py.
References config_to_dict().
| backend.routers.config.update_config | ( | dict | updates, |
| UserSession | session = Depends(get_session), | ||
| None | _ = DesignCheckout, | ||
| str | None | expect_sha256 = Query(default=None, max_length=64, pattern="^[0-9a-f]{64}$") ) |
Update the current config with partial updates. Accepts a nested dict of updates that will be merged with the current config. ``expect_sha256``: the design the update was computed for (Layer X's fitted feed, a reconciled injector). If the live design is no longer that one the write is refused with 409: a K0 fitted to one design must not land in another because a tab was a few seconds stale.
Definition at line 226 of file config.py.
References config_to_dict().
| backend.routers.config.upload_config | ( | UploadFile | file = File(...), |
| UserSession | session = Depends(get_session), | ||
| None | _ = DesignCheckout ) |
Upload a YAML config file and parse it.
Definition at line 22 of file config.py.
References config_to_dict().