Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """Seed catalog + firm projects for full PLAN §10/§13 measurable local metrics. | |
| Usage (from backend/): | |
| python3 scripts/seed_ecosystem_12m_all.py | |
| """ | |
| from __future__ import annotations | |
| import json | |
| import os | |
| import sys | |
| sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| from core.subscription.db import SessionLocal, init_models # noqa: E402 | |
| from core.grants.seed_ecosystem_12m_catalog import seed_ecosystem_12m_catalog # noqa: E402 | |
| from core.projects.seed_ecosystem_12m_projects import seed_ecosystem_12m_projects # noqa: E402 | |
| from core.grants.catalog_service import get_catalog_stats # noqa: E402 | |
| from core.projects.instrument_ops import ( # noqa: E402 | |
| build_plan_12m_metrics_snapshot, | |
| compute_instrument_project_metrics, | |
| ) | |
| def main() -> int: | |
| init_models() | |
| db = SessionLocal() | |
| try: | |
| cat = seed_ecosystem_12m_catalog(db, commit=True) | |
| firm = seed_ecosystem_12m_projects(db, commit=True) | |
| pm = compute_instrument_project_metrics(db) | |
| cs = get_catalog_stats(db) | |
| snap = build_plan_12m_metrics_snapshot(project_metrics=pm, catalog_stats=cs) | |
| out = { | |
| "catalog_seed": { | |
| "meets_dod_70_not_blind": cat.get("meets_dod_70_not_blind"), | |
| "pct_not_blind": cat.get("pct_not_blind"), | |
| "sample_size": cat.get("sample_size"), | |
| }, | |
| "firm_seed": firm, | |
| "plan_12m_measured": snap.get("measured"), | |
| "section_13_status": snap.get("section_13_status"), | |
| "sla_claim_allowed": snap.get("sla_claim_allowed"), | |
| "dod_all_pass": snap.get("dod_all_pass"), | |
| } | |
| print(json.dumps(out, indent=2, default=str)) | |
| ok = bool(cat.get("meets_dod_70_not_blind")) and bool(snap.get("dod_all_pass")) | |
| return 0 if ok else 2 | |
| finally: | |
| db.close() | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |