Estimates stored as batches of risks in the domain's database: models store and run --store; a kit file is read as dbt's only when its producer is dbt
This commit is contained in:
@@ -48,9 +48,10 @@ def model_sha(model_dir: str | Path) -> str:
|
||||
|
||||
def cohort_reference(metadata: dict[str, str], file_sha256: str) -> dict[str, str]:
|
||||
"""How a run, a version or an estimate points to the cohort build file it used: its cohort, who built it (`kit` or
|
||||
`dbt`), its number in that source and the file's hash. A kit build's number is its `armado_id`."""
|
||||
source = metadata.get("producer", "kit")
|
||||
build = metadata["armado_id"] if source == "kit" else metadata["build"]
|
||||
`dbt`), its number in that source and the file's hash. Only a file whose producer is `dbt` is dbt's; any other is a kit
|
||||
build, numbered by its `armado_id`."""
|
||||
source = "dbt" if metadata.get("producer") == "dbt" else "kit"
|
||||
build = metadata["build"] if source == "dbt" else metadata["armado_id"]
|
||||
return {COHORT_URL_TAG: metadata["url"], COHORT_SOURCE_TAG: source, COHORT_BUILD_TAG: str(build),
|
||||
COHORT_FILE_TAG: file_sha256}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""Where the pipelines' data lives and how it's read and written: Parquet files (cohort builds and estimates), dbt's
|
||||
manifest, and a domain's Persistance repositories.
|
||||
manifest, a domain's Persistance repositories, and the batches of risks they store.
|
||||
|
||||
The kit's builds are `<root>/<domain>/<cohort>/<armado_id>.parquet`. The builds of dbt's rules go in a `dbt/` folder
|
||||
beside them, numbered in order, so a lookup of the kit's builds never picks one up. Persistance is imported only where a
|
||||
@@ -133,6 +133,13 @@ def read_queries(manifest: str | Path, url: str) -> CohortQueries:
|
||||
date.fromisoformat(meta["cutoff"]), json.loads(meta.get("parameters", "{}")))
|
||||
|
||||
|
||||
def store_risk_batch(domain: str, armado_id: int, provenance: dict, outcome: str, rows: list[tuple]) -> tuple[int, bool]:
|
||||
"""Writes a batch of risks for a kit build through the domain's `cohorte_repository`: its `lote_id` and whether it's
|
||||
new. The only write the pipelines make to the database; risks of anyone outside the build are refused."""
|
||||
cohorts = importlib.import_module(f"persistance.{domain}").cohorte_repository
|
||||
return cohorts.guardar_lote(armado_id, provenance, outcome, rows)
|
||||
|
||||
|
||||
def resolve_repository(domain: str, entity: str):
|
||||
"""`entity` is the repository's name in `persistance.<domain>` without
|
||||
the suffix, e.g. `"paciente"`, `"citologia_cervical"`."""
|
||||
|
||||
Reference in New Issue
Block a user