19 lines
935 B
Python
19 lines
935 B
Python
"""Lo que el ciclo necesita saber de las definiciones de un proyecto: sus periodos (dbt) y sus cohortes (el kit)."""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from indicadores_kit.oro.cohortes.definicion import RAIZ
|
|
|
|
|
|
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]:
|
|
"""Los TOML de cohortes que el ciclo arma (`<proyecto>/cohortes/*.toml`): hoy solo CaCu (vigilancia). Las de `cohortes/propuestas/` no (T-21h)."""
|
|
return sorted((RAIZ / proyecto / "cohortes").glob("*.toml"))
|