Add rollup_rollout/src/rollup_rollout/cli.py
This commit is contained in:
parent
39a8082bb3
commit
bcc6acc3f6
1 changed files with 54 additions and 0 deletions
54
rollup_rollout/src/rollup_rollout/cli.py
Normal file
54
rollup_rollout/src/rollup_rollout/cli.py
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
# Lokaler Import der Kernfunktionalität
|
||||||
|
def _import_core_function() -> Any:
|
||||||
|
try:
|
||||||
|
from rollup_rollout.core import generate_rollout_series
|
||||||
|
except ImportError as e:
|
||||||
|
raise SystemExit(f"Fehler: Konnte generate_rollout_series nicht importieren: {e}")
|
||||||
|
return generate_rollout_series
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
"""CLI-Einstiegspunkt zum Generieren der Rollout-Serie."""
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Aggregiert CI-Ergebnisse aus mehreren 'gate_result.json'-Dateien zu einer Rollout-CSV-Datei."
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--input",
|
||||||
|
required=True,
|
||||||
|
help="Pfad zur Eingabe-JSON-Datei (gate_result.json)",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--output",
|
||||||
|
required=True,
|
||||||
|
help="Pfad zur Ausgabedatei rollout_series.csv",
|
||||||
|
)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
input_path = Path(args.input)
|
||||||
|
output_path = Path(args.output)
|
||||||
|
|
||||||
|
# Basale Validierung der Argumente: CI-Ready & input_validation_required
|
||||||
|
assert input_path.suffix.lower() == ".json", "Eingabedatei muss .json sein"
|
||||||
|
assert output_path.suffix.lower() == ".csv", "Ausgabedatei muss .csv sein"
|
||||||
|
if not input_path.exists():
|
||||||
|
raise SystemExit(f"Fehler: Eingabedatei {input_path} existiert nicht.")
|
||||||
|
|
||||||
|
generate_rollout_series = _import_core_function()
|
||||||
|
|
||||||
|
try:
|
||||||
|
generate_rollout_series(str(input_path), str(output_path))
|
||||||
|
except Exception as exc:
|
||||||
|
print(f"Fehler bei der Rollout-Generierung: {exc}", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
print(f"Rollout-Serie erfolgreich erzeugt: {output_path}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
Reference in a new issue