dbt is the only definition of a cohort: the stored build runs dbt's queries

The WebApi cycle's build (models.cohorts.build.build_of) runs the cohort's queries from dbt's manifest with the same
chain as the export, instead of a Python frame per cohort; the TOML definitions, their frames and definition.py are
removed. A cohort may have no exclusions (cacu/cohorte_total, for models whose rules don't fit SQL) and an optional
`variables` query; the population meta carries the cohort's version. cohort_urls lists a domain's cohorts in the
manifest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmQxVJVNR5FYkPAregGEQ7
This commit is contained in:
2026-11-20 19:52:05 -06:00
parent 06829a4498
commit ea6db36b23
8 changed files with 164 additions and 109 deletions
+4 -1
View File
@@ -51,7 +51,7 @@ ESTIMATE_FRAME = pandera.DataFrameSchema(
"probabilidad": pandera.Column(float, pandera.Check.in_range(0, 1))},
strict=True, ordered=True, unique=["pac_id", "horizonte_anios"], name="estimate")
POPULATION, INDEX, EXCLUSION = "population", "index", "exclusion"
POPULATION, INDEX, EXCLUSION, VARIABLES = "population", "index", "exclusion", "variables"
class CohortFileError(ValueError):
@@ -93,6 +93,9 @@ class CohortQueries:
rules: tuple[ExclusionRule, ...]
cutoff: date
parameters: dict
version: str = "" # the population meta's `version`: bumped when a rule changes
# optional: the members' stored variables, long (`pac_id`, `variable`, `valor_codigo`, `valor_numerico`)
variables: str | None = None
@dataclass(frozen=True)