Dask scheduler and workers for the test profile and CI; writes-overlap, cancel and remote-mode tests: run concurrency and cancel tests; TEA gate cancels a re-analysis and checks nothing changed
This commit is contained in:
@@ -267,6 +267,37 @@ def test_tea_from_the_hospital_to_indicators(api, scored_hospital, monkeypatch):
|
||||
|
||||
_preview_matches_the_analysis_and_leaves_bronze_unchanged(scored_hospital, monkeypatch)
|
||||
_reanalysis_by_id_in_local_mode_matches_sync(api, scored_hospital)
|
||||
_cancel_during_analysis_leaves_bronze_and_gold_untouched(api, scored_hospital)
|
||||
|
||||
|
||||
def _cancel_during_analysis_leaves_bronze_and_gold_untouched(api, platform):
|
||||
def snapshot():
|
||||
return (
|
||||
platform.query(
|
||||
"select edf, valid, level, analysed_at from bronze.eeg_analysis order by edf"
|
||||
),
|
||||
platform.count("bronze.eeg_metrics"),
|
||||
platform.count("gold.tea_eeg_metrics"),
|
||||
)
|
||||
|
||||
before = snapshot()
|
||||
ids = [study["id"] for study in ok(api.get("/tea/eegs")) if study["valid"]]
|
||||
body = {"scope": {"mode": "ids", "ids": ids}}
|
||||
run_id = ok(api.post("/tea/eegs/analyze", json=body))["run_id"]
|
||||
url = f"/runs/{run_id}"
|
||||
deadline = time.monotonic() + 300
|
||||
while (run := ok(api.get(url)))["state"] != "running":
|
||||
assert run["state"] not in {"succeeded", "failed", "cancelled"}, run
|
||||
assert time.monotonic() < deadline, run
|
||||
time.sleep(1)
|
||||
|
||||
ok(api.post(f"{url}/cancel"))
|
||||
deadline = time.monotonic() + 900
|
||||
while (run := ok(api.get(url)))["state"] != "cancelled":
|
||||
assert run["state"] not in {"succeeded", "failed"}, run
|
||||
assert time.monotonic() < deadline, run
|
||||
time.sleep(1)
|
||||
assert snapshot() == before
|
||||
|
||||
|
||||
def _reanalysis_by_id_in_local_mode_matches_sync(api, platform):
|
||||
|
||||
Reference in New Issue
Block a user