from __future__ import annotations

import argparse
from pathlib import Path

from scripts._experiment_utils import REPO_ROOT, add_model_config_arguments, model_config_from_namespace
from src.busopt.runner import run_open_access, run_public_operation, save_result


def build_parser() -> argparse.ArgumentParser:
    parser = argparse.ArgumentParser(description="Run regime comparison variants based on nested GBD.")
    parser.add_argument("--output-dir", type=Path, default=REPO_ROOT / "results" / "mode_comparison")
    add_model_config_arguments(parser, exclude={"s_bar"})
    return parser


def main() -> None:
    args = build_parser().parse_args()
    args.output_dir.mkdir(parents=True, exist_ok=True)
    base_config = model_config_from_namespace(args)
    config = base_config.with_overrides(s_bar=1.5, Psi0=100)

    public_operation_result = run_public_operation(config)
    save_result(public_operation_result, args.output_dir / "public_operation.json")

    open_access_result = run_open_access(config)
    save_result(open_access_result, args.output_dir / "open_access.json")


if __name__ == "__main__":
    main()
