From ff4cde43443589e9d6c312014e0c383efbb05e0c Mon Sep 17 00:00:00 2001 From: Mika Date: Fri, 19 Dec 2025 16:32:38 +0000 Subject: [PATCH] Add baseline_recalc_ordering/src/baseline_recalc_ordering/cli.py --- .../src/baseline_recalc_ordering/cli.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 baseline_recalc_ordering/src/baseline_recalc_ordering/cli.py diff --git a/baseline_recalc_ordering/src/baseline_recalc_ordering/cli.py b/baseline_recalc_ordering/src/baseline_recalc_ordering/cli.py new file mode 100644 index 0000000..77d7d2e --- /dev/null +++ b/baseline_recalc_ordering/src/baseline_recalc_ordering/cli.py @@ -0,0 +1,44 @@ +import argparse +import json +from pathlib import Path + +from baseline_recalc_ordering import core + +def main() -> None: + parser = argparse.ArgumentParser( + description="Analysiert Latenzmetriken unter verschiedenen baseline_recalc-Reihenfolgen." + ) + parser.add_argument( + "--input", + required=True, + help="Pfad zur JSON-Datei mit den Reihenfolgedaten." + ) + parser.add_argument( + "--output", + required=True, + help="Pfad für die Analyseausgabe im JSON-Format." + ) + + args = parser.parse_args() + + input_path = Path(args.input) + output_path = Path(args.output) + + if not input_path.exists(): + raise FileNotFoundError(f"Input-Datei nicht gefunden: {input_path}") + + with input_path.open("r", encoding="utf-8") as f: + data = json.load(f) + + order_sequence = data.get("order_sequence") + if not isinstance(order_sequence, list) or not all(isinstance(x, str) for x in order_sequence): + raise ValueError("Ungültiges Format: 'order_sequence' muss eine Liste von Strings sein.") + + result = core.analyze_latency(order_sequence) + + output_path.parent.mkdir(parents=True, exist_ok=True) + with output_path.open("w", encoding="utf-8") as f: + json.dump(result, f, indent=2, ensure_ascii=False) + +if __name__ == "__main__": + main()