STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
check_config_load.py
Go to the documentation of this file.
1"""Check that engine config YAMLs load, and say what the loader thinks of them.
2
3 python3 check_config_load.py configs/ethalox_6800N.yaml [more.yaml ...]
4
5Each file goes through the app's own loader (engine.pipeline.io.load_config: propellant preset
6merged, identity checked, schema validated), then the injector bindings check and the design
7warning forward mode would show (stale chamber seed, fluids off their preset). Any injector type.
8Exit status: 0 when every file loads, 1 when one does not, 2 on no arguments.
9
10It used to read one hard-coded path on one laptop and check a pintle-only field.
11"""
12
13from __future__ import annotations
14
15import sys
16from pathlib import Path
17from typing import List, Optional
18
19sys.path.insert(0, str(Path(__file__).resolve().parent))
20
21
22def check(path: str) -> bool:
23 from engine.core.dispatch import validate_config_bindings
24 from engine.pipeline.config_switch import design_staleness
25 from engine.pipeline.io import load_config
26
27 try:
28 config = load_config(path)
29 except Exception as e: # the loader's own message is the point
30 print(f"FAIL {path}: {type(e).__name__}: {e}")
31 return False
32 injector = getattr(getattr(config, "injector", None), "type", None)
33 print(f"OK {path}: injector {injector}, propellant {config.propellant_preset or 'custom'}")
34 for w in validate_config_bindings(config):
35 print(f" binding: {w}")
36 warning = design_staleness(config)
37 if warning:
38 print(f" design: {warning}")
39 return True
40
41
42def main(argv: Optional[List[str]] = None) -> int:
43 paths = sys.argv[1:] if argv is None else argv
44 if not paths:
45 print(__doc__.strip().splitlines()[2].strip())
46 return 2
47 results = [check(p) for p in paths]
48 return 0 if all(results) else 1
49
50
51if __name__ == "__main__":
52 sys.exit(main())
bool check(str path)
int main()