Add baseline_recalc_ordering/src/baseline_recalc_ordering/cli.py
This commit is contained in:
parent
ca7a2b6c16
commit
ff4cde4344
1 changed files with 44 additions and 0 deletions
44
baseline_recalc_ordering/src/baseline_recalc_ordering/cli.py
Normal file
44
baseline_recalc_ordering/src/baseline_recalc_ordering/cli.py
Normal file
|
|
@ -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()
|
||||||
Loading…
Reference in a new issue