CaCu's dummy model in its own folder
This commit is contained in:
@@ -31,7 +31,7 @@ from sqlalchemy import column, select, table
|
||||
from sqlalchemy.engine import make_url
|
||||
from sqlalchemy.exc import DBAPIError
|
||||
|
||||
from models.io.cohorts import SCHEMA
|
||||
from models.io.cohorts import SCHEMA, cohort_lineage
|
||||
|
||||
ROW_ORDER = ["pac_id", "fecha", "clase", "tipo", "fuente_id"]
|
||||
|
||||
@@ -55,12 +55,6 @@ def cohort_file(build: CohortBuild, root: Path) -> Path:
|
||||
return root / domain / cohort / f"{build.armado_id}.parquet"
|
||||
|
||||
|
||||
def lineage_of(path: Path) -> dict[str, str]:
|
||||
"""The lineage in the file's metadata, without reading any rows."""
|
||||
metadata = pq.read_metadata(path).metadata
|
||||
return {k.decode(): v.decode() for k, v in metadata.items() if k not in (b"pandas", b"ARROW:schema")}
|
||||
|
||||
|
||||
def read_timeline(repository: TimelineRepository, domain: str) -> list[dict]:
|
||||
"""Every event of the domain, from dbt's view. The cut-offs are applied in `build_table`."""
|
||||
name = f"{domain}_linea_de_tiempo"
|
||||
@@ -115,7 +109,7 @@ def ensure(build: CohortBuild, root: Path, make_table: Callable[[], pa.Table]) -
|
||||
"""The build's file: reused if it's already there and belongs to the build, written once if not."""
|
||||
path = cohort_file(build, root)
|
||||
if path.exists():
|
||||
lineage = lineage_of(path)
|
||||
lineage = cohort_lineage(path)
|
||||
if lineage.get("armado_id") != str(build.armado_id) or lineage.get("n_members") != str(build.n_miembros):
|
||||
raise ValueError(f"{path} doesn't belong to build {build.armado_id}: {lineage}")
|
||||
return path, "reused"
|
||||
|
||||
Reference in New Issue
Block a user