Spaces:
Running
Running
| from __future__ import annotations | |
| import argparse | |
| from pathlib import Path | |
| from .calibration import BDR_MODEL_PRESETS, DEFAULT_CLASS_CONFIG, REFERENCE_CLASS | |
| from .pipeline import generate_report, run_evolution_cli, run_pipeline, thresholds_from_json | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description="RF mode pack v5.1/v6.0 engineering screening CLI") | |
| parser.add_argument("--n-designs", type=int, default=1000) | |
| parser.add_argument("--seed", type=int, default=7) | |
| parser.add_argument("--bdr-preset", choices=list(BDR_MODEL_PRESETS.keys()), default="nominal") | |
| parser.add_argument("--reference-class", default=REFERENCE_CLASS) | |
| parser.add_argument("--out-dir", default="rf_mode_pack_v5_1_outputs") | |
| parser.add_argument("--report-only", action="store_true") | |
| parser.add_argument("--skip-report", action="store_true") | |
| parser.add_argument("--class-config-json", default="") | |
| parser.add_argument("--run-ga", action="store_true") | |
| parser.add_argument("--ga-pop-size", type=int, default=300) | |
| parser.add_argument("--ga-generations", type=int, default=20) | |
| parser.add_argument("--ga-target-class", default="B_development") | |
| args = parser.parse_args() | |
| out_dir = Path(args.out_dir) | |
| class_config = DEFAULT_CLASS_CONFIG | |
| if args.class_config_json: | |
| class_config = thresholds_from_json(Path(args.class_config_json)) | |
| if args.reference_class not in class_config: | |
| raise SystemExit(f"reference class '{args.reference_class}' is not in class config") | |
| if args.ga_target_class not in class_config: | |
| raise SystemExit(f"GA target class '{args.ga_target_class}' is not in class config") | |
| if args.report_only: | |
| report_path = out_dir / "rf_mode_pack_v5_1_report.md" | |
| generate_report(out_dir, report_path, class_order=list(class_config.keys()), reference_class=args.reference_class) | |
| print("Saved report to:", report_path) | |
| return | |
| if args.run_ga: | |
| run_evolution_cli( | |
| pop_size=args.ga_pop_size, | |
| generations=args.ga_generations, | |
| seed=args.seed, | |
| bdr_preset=args.bdr_preset, | |
| target_class=args.ga_target_class, | |
| out_dir=out_dir, | |
| skip_report=args.skip_report, | |
| class_config=class_config, | |
| ) | |
| return | |
| run_pipeline( | |
| n_designs=args.n_designs, | |
| seed=args.seed, | |
| bdr_preset=args.bdr_preset, | |
| reference_class=args.reference_class, | |
| out_dir=out_dir, | |
| class_config=class_config, | |
| skip_report=args.skip_report, | |
| ) | |
| if __name__ == "__main__": | |
| main() | |