TEA EEG analysis and age curves, TEA jobs; CaMa recurrence on METABRIC and SCAN-B; reference-data models and routine runs
This commit is contained in:
+8
-1
@@ -46,6 +46,8 @@ from core.pipeline import (
|
||||
from persistance import config_log, nodes, silver
|
||||
|
||||
MIN_WORDS = 5 # fewer than this from a PDF means it has no text layer
|
||||
# Files kept whole (catalog `file` fields), once each, keyed by their content hash.
|
||||
FILES = {"key": {"data_type": "text"}, "content": {"data_type": "binary"}}
|
||||
READ_COLUMNS = { # declared, so a load where every file read cleanly still has `error`
|
||||
"text": {"data_type": "text", "nullable": True},
|
||||
"ocr": {"data_type": "bool"},
|
||||
@@ -387,10 +389,14 @@ def run_target(p: str, node: Target, kinds: dict[str, str]):
|
||||
linked = {r[RECORD]: r for r in nodes.rows(p, link)}
|
||||
person = {k: r["person_id"] for k, r in linked.items()}
|
||||
model, study = catalog.model(node.entity), catalog.studies()[node.entity]
|
||||
observations, held_rows = [], []
|
||||
observations, held_rows, files = [], [], {}
|
||||
kept = [n for n, f in study.fields.items() if f.type == "file"]
|
||||
for i in (i for i in node.inputs if i != link):
|
||||
for row in nodes.rows(p, i):
|
||||
values = {f: row.get(f) for f in model.model_fields if row.get(f) is not None}
|
||||
for name in (n for n in kept if n in values): # kept once, named by its hash
|
||||
files[key := hashlib.sha256(values[name]).hexdigest()] = values[name]
|
||||
values[name] = key
|
||||
held = json.loads(row.get(HELD) or "[]") + validate(node.entity, values)
|
||||
if row[RECORD] not in person:
|
||||
held.append("no identity linked to this record")
|
||||
@@ -408,6 +414,7 @@ def run_target(p: str, node: Target, kinds: dict[str, str]):
|
||||
if (value := getattr(clean, name)) is not None:
|
||||
observations.append({**base, "instance": instance, "field": name,
|
||||
catalog.value_column(field): value}) # fmt: skip
|
||||
nodes.remember("files", [{"key": k, "content": c} for k, c in files.items()], FILES)
|
||||
nodes.stage("observation", p, node.id, observations, silver.OBSERVATION)
|
||||
return nodes.stage("held", p, node.id, held_rows, silver.HELD_ROWS)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user