Files
siemens_ragas/main.py

55 lines
1.7 KiB
Python
Raw Permalink Normal View History

2026-06-12 14:02:15 +08:00
from __future__ import annotations
import argparse
import logging
from pathlib import Path
2026-06-12 14:02:15 +08:00
from rag_eval.dataset_builder.runner import run_dataset_build
from rag_eval.execution.runner import run_scenario
def parse_args() -> argparse.Namespace:
"""Parse CLI arguments for either evaluation or dataset build workflows."""
parser = argparse.ArgumentParser(description="Run a RAG evaluation scenario.")
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
"--scenario",
help="Path to a YAML scenario file.",
)
group.add_argument(
"--dataset-build-config",
help="Path to a YAML dataset build config file.",
)
parser.add_argument(
"--log-file",
default=None,
help="Write evaluation logs to this file (in addition to stderr). "
"Example: logs/eval.log",
)
parser.add_argument(
"--log-level",
default="INFO",
choices=["DEBUG", "INFO", "WARNING", "ERROR"],
help="Logging verbosity level (default: INFO). Use DEBUG for per-metric detail.",
)
2026-06-12 14:02:15 +08:00
return parser.parse_args()
def main() -> None:
"""Dispatch the CLI call to the requested workflow."""
args = parse_args()
log_level = getattr(logging, args.log_level.upper(), logging.INFO)
log_file = Path(args.log_file) if args.log_file else None
2026-06-12 14:02:15 +08:00
if args.dataset_build_config:
result = run_dataset_build(args.dataset_build_config)
print(f"Completed dataset build: {result.artifact_paths.root_dir}")
return
result = run_scenario(args.scenario, log_file=log_file, log_level=log_level)
2026-06-12 14:02:15 +08:00
print(f"Completed run: {result.scenario.output_dir}")
if __name__ == "__main__":
main()