"""What the cycle needs to know of a project's definitions: its period types (dbt) and its cohorts (`models.cohorts`).""" import json from pathlib import Path from models.cohorts.definition import ROOT def period_types(proyecto: str, manifest: Path) -> list[str]: """The period types the project's measures publish, from their `meta.tipos_periodo` in dbt's manifest.""" metrics = json.loads(manifest.read_text(encoding="utf-8"))["metrics"].values() return sorted({t for m in metrics for t in m["config"].get("meta", {}).get("tipos_periodo", []) if m["config"]["meta"].get("measure_url", "").startswith(f"{proyecto}/")}) def cohort_definitions(proyecto: str) -> list[Path]: """The cohort TOMLs the cycle builds (`models/cohorts//*.toml`): today only CaCu's surveillance cohort. Those in `/proposals/` aren't built.""" return sorted((ROOT / proyecto).glob("*.toml"))