STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
backend.routers.config Namespace Reference

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"])

Detailed Description

Config management endpoints.

Function Documentation

◆ config_to_dict()

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().

◆ get_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().

◆ get_injector_schema()

backend.routers.config.get_injector_schema ( str | None injector_type = None,
UserSession session = Depends(get_session) )
Per-injector field schema for the UI to render the RIGHT controls (frozen params, geometry)
instead of hardcoding pintle fields (INJECTOR_PARITY_PLAN W5). Defaults to the loaded config's type.

Definition at line 147 of file config.py.

◆ get_parameters()

backend.routers.config.get_parameters ( UserSession session = Depends(get_session))
Every parameter of the loaded config -- value, schema default, units, description -- and the
physics constants that live in code (engine/pipeline/parameter_registry.py). Edits go through
PUT /api/config like any other change.

Definition at line 114 of file config.py.

◆ get_switch_options()

backend.routers.config.get_switch_options ( UserSession session = Depends(get_session))
Available injector types and propellant presets for the UI selectors (UNIFICATION P6).

Definition at line 131 of file config.py.

◆ load_config_json()

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().

◆ switch_config_endpoint()

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().

◆ update_config()

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().

◆ upload_config()

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().

Variable Documentation

◆ router

backend.routers.config.router = APIRouter(prefix="/api/config", tags=["config"])

Definition at line 13 of file config.py.