TEA gate: TEA_GATE_SLOW stretches its waits on a busy shared server (default 1)
This commit is contained in:
+9
-6
@@ -30,6 +30,8 @@ from models.definitions import tea_preview
|
||||
from persistance import config, previews
|
||||
|
||||
ROOT = Path(__file__).parents[2]
|
||||
# A busy shared server runs the gate slower: its waits stretch by this factor (default 1).
|
||||
SLOW = float(os.environ.get("TEA_GATE_SLOW", "1"))
|
||||
HOSPITAL = Path(os.environ.get("TEA_HOSPITAL", Path.home() / "isssteleon-data"))
|
||||
# The age curves' reference cohort (public, outside git) and where its measures are kept.
|
||||
os.environ.setdefault("TEA_REFERENCE_DIR", "/mnt/drive/eeg-helsinki")
|
||||
@@ -146,7 +148,7 @@ def _day(value) -> date:
|
||||
|
||||
|
||||
def _wait_for_sensor_analysis(api):
|
||||
deadline = time.monotonic() + 3600
|
||||
deadline = time.monotonic() + 3600 * SLOW
|
||||
while time.monotonic() < deadline:
|
||||
runs = ok(api.get("/runs", params={"job": "tea_eeg", "domain": "tea"}))
|
||||
for run in runs:
|
||||
@@ -166,7 +168,7 @@ def scored_hospital(api, platform):
|
||||
pipeline = json.loads(PIPELINE.read_text().replace("{hospital}", str(HOSPITAL)))
|
||||
put_concept_map(api, "hospital_tea")
|
||||
ok(api.put("/ingest/pipelines/tea", json=pipeline))
|
||||
wait_for(api, ok(api.post("/ingest/pipelines/tea/runs", json={}))["run_id"], 1800)
|
||||
wait_for(api, ok(api.post("/ingest/pipelines/tea/runs", json={}))["run_id"], int(1800 * SLOW))
|
||||
_wait_for_sensor_analysis(api)
|
||||
q = platform.query
|
||||
|
||||
@@ -230,7 +232,7 @@ def scored_hospital(api, platform):
|
||||
# The age curves: one training run gives a version of each, from the reference cohort;
|
||||
# promoted after their clinical validation, they score every analysed EEG as the
|
||||
# current platform's curves do.
|
||||
wait_for(api, ok(api.post("/models/tea/train", json={}))["run_id"], 3600)
|
||||
wait_for(api, ok(api.post("/models/tea/train", json={}))["run_id"], int(3600 * SLOW))
|
||||
names = ok(api.get("/models/tea"))
|
||||
assert len(names) == 7
|
||||
files = {"file": ("validacion.pdf", b"%PDF-1.4 clinical validation", "application/pdf")}
|
||||
@@ -238,7 +240,7 @@ def scored_hospital(api, platform):
|
||||
ok(api.post(f"/models/tea/{name}/versions/1/reports/clinical_validation", files=files))
|
||||
ok(api.post(f"/models/tea/{name}/versions/1/promote"))
|
||||
pending = {"scope": {"mode": "pending"}}
|
||||
wait_for(api, ok(api.post("/tea/eegs/analyze", json=pending))["run_id"], 1800)
|
||||
wait_for(api, ok(api.post("/tea/eegs/analyze", json=pending))["run_id"], int(1800 * SLOW))
|
||||
scored = {(e, c): r for e, c, *r in q(
|
||||
"select edf, code, z, outside, p5, median, p95 from gold.tea_eeg_metrics")} # fmt: skip
|
||||
for key, theirs in metrics.items():
|
||||
@@ -253,12 +255,13 @@ def scored_hospital(api, platform):
|
||||
|
||||
def _association_gate(api, platform):
|
||||
name = "ados2_association"
|
||||
wait_for(api, ok(api.post("/models/tea/train", json={"models": [name]}))["run_id"], 3600)
|
||||
training = ok(api.post("/models/tea/train", json={"models": [name]}))["run_id"]
|
||||
wait_for(api, training, int(3600 * SLOW))
|
||||
files = {"file": ("validacion.pdf", b"%PDF-1.4 clinical validation", "application/pdf")}
|
||||
ok(api.post(f"/models/tea/{name}/versions/1/reports/clinical_validation", files=files))
|
||||
ok(api.post(f"/models/tea/{name}/versions/1/promote"))
|
||||
pending = {"scope": {"mode": "pending"}}
|
||||
wait_for(api, ok(api.post("/tea/eegs/analyze", json=pending))["run_id"], 1800)
|
||||
wait_for(api, ok(api.post("/tea/eegs/analyze", json=pending))["run_id"], int(1800 * SLOW))
|
||||
|
||||
tables = REFERENCE / "tables"
|
||||
biomarkers = {
|
||||
|
||||
Reference in New Issue
Block a user