Add run_summary/src/run_summary/cli.py
This commit is contained in:
parent
69ce58136d
commit
5305a248a0
1 changed files with 50 additions and 0 deletions
50
run_summary/src/run_summary/cli.py
Normal file
50
run_summary/src/run_summary/cli.py
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
from run_summary import core
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
"""CLI-Einstiegspunkt zur Erstellung einer Run-Summary und Ausgabe der Gate-Decision."""
|
||||||
|
parser = argparse.ArgumentParser(description="Generiere Run-Summary und Gate-Decision.")
|
||||||
|
parser.add_argument("--input", required=True, help="Pfad zur JSON-Datei mit den Rohdaten.")
|
||||||
|
parser.add_argument("--summary", required=True, help="Pfad zur zu schreibenden Run-Summary-Datei.")
|
||||||
|
parser.add_argument("--debug", required=False, help="Pfad zur optionalen Debug-Ausgabedatei.")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
input_path = Path(args.input)
|
||||||
|
summary_path = Path(args.summary)
|
||||||
|
debug_path = Path(args.debug) if args.debug else None
|
||||||
|
|
||||||
|
# Validierung: Eingabedatei prüfen
|
||||||
|
if not input_path.exists():
|
||||||
|
raise FileNotFoundError(f"Die Eingabedatei {input_path} wurde nicht gefunden.")
|
||||||
|
|
||||||
|
# Rohdaten laden
|
||||||
|
with input_path.open("r", encoding="utf-8") as f:
|
||||||
|
raw_events = json.load(f)
|
||||||
|
|
||||||
|
if not isinstance(raw_events, list):
|
||||||
|
raise ValueError("Die Eingabedatei muss eine Liste von Events enthalten.")
|
||||||
|
|
||||||
|
# Summary generieren
|
||||||
|
summary = core.generate_summary(raw_events)
|
||||||
|
|
||||||
|
# Summary-Datei schreiben
|
||||||
|
summary_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
with summary_path.open("w", encoding="utf-8") as f:
|
||||||
|
json.dump(summary, f, indent=2)
|
||||||
|
|
||||||
|
# Gate Entscheidung treffen
|
||||||
|
gate_result = core.make_gate_decision(summary)
|
||||||
|
print(gate_result)
|
||||||
|
|
||||||
|
# Optional Debug-Artifact erzeugen
|
||||||
|
if debug_path:
|
||||||
|
debug_output = core.export_debug_artifact(raw_events, str(debug_path))
|
||||||
|
if debug_output:
|
||||||
|
print(f"Debug-Artifact gespeichert unter: {debug_output}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
Reference in a new issue