diff --git a/trace_agg/src/trace_agg/cli.py b/trace_agg/src/trace_agg/cli.py new file mode 100644 index 0000000..b090055 --- /dev/null +++ b/trace_agg/src/trace_agg/cli.py @@ -0,0 +1,32 @@ +import argparse +import json +import sys +from pathlib import Path +from trace_agg.core import aggregate_em_data + +def main(): + parser = argparse.ArgumentParser(description="Aggregiert EM-Tracedaten und berechnet Summary-Metriken.") + parser.add_argument("--input", required=True, help="Pfad zur Eingabe-CSV-Datei mit EM-Traces.") + parser.add_argument("--output", required=True, help="Pfad zur JSON-Datei mit den Ergebnissen.") + parser.add_argument("--num-trials", type=int, default=None, help="Anzahl der Trials, die aggregiert werden sollen.") + args = parser.parse_args() + + input_path = Path(args.input) + output_path = Path(args.output) + + if not input_path.exists() or not input_path.is_file(): + print(f"Eingabedatei nicht gefunden: {input_path}", file=sys.stderr) + sys.exit(1) + + try: + results = aggregate_em_data(num_trials=args.num_trials) + output_path.parent.mkdir(parents=True, exist_ok=True) + with open(output_path, "w", encoding="utf-8") as f: + json.dump(results, f, indent=2) + print(f"Aggregation beendet. Ergebnisse gespeichert in {output_path}.") + except Exception as e: + print(f"Fehler bei der Aggregation: {e}", file=sys.stderr) + sys.exit(1) + +if __name__ == "__main__": + main() \ No newline at end of file