F1a: user fixes
Keep the flat Dagster source config and validate it with the same Pydantic union as WebApi. Default to SiteTrainingSource when a run omits the source and reuse the site measurements computed at 60 Hz. Keep the existing folder measurement default and cache keys.
This commit is contained in:
@@ -9,7 +9,7 @@ from models.jobs import EmptyCohort
|
||||
from models.tea import jobs
|
||||
from models.tea.eeg import reference
|
||||
from persistance import eeg
|
||||
from persistance.cluster import TrainingSource
|
||||
from persistance.cluster import FolderTrainingSource, SiteTrainingSource
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -40,23 +40,23 @@ def test_bad_folders_fail_with_a_reason(folder):
|
||||
cohort, ages = folder
|
||||
for name in ("..", ".", "nope"):
|
||||
with pytest.raises(ValueError) as exc:
|
||||
jobs._cohort(TrainingSource(kind="folder", folder=name), date(2026, 1, 1))
|
||||
jobs._cohort(FolderTrainingSource(kind="folder", folder=name), date(2026, 1, 1))
|
||||
assert str(exc.value) == f"no reference cohort {name!r}"
|
||||
|
||||
ages.write_text("path,age\n0.edf,12\n1.edf,48\nnight/2.edf,60\n")
|
||||
with pytest.raises(
|
||||
ValueError, match="folder 'hel' has no EDF with an age from 16 to 36 months"
|
||||
):
|
||||
jobs._cohort(TrainingSource(kind="folder", folder="hel"), date(2026, 1, 1))
|
||||
jobs._cohort(FolderTrainingSource(kind="folder", folder="hel"), date(2026, 1, 1))
|
||||
|
||||
ages.unlink()
|
||||
with pytest.raises(ValueError, match=r"folder 'hel' has no edades\.csv"):
|
||||
jobs._cohort(TrainingSource(kind="folder", folder="hel"), date(2026, 1, 1))
|
||||
jobs._cohort(FolderTrainingSource(kind="folder", folder="hel"), date(2026, 1, 1))
|
||||
|
||||
with pytest.raises(ValidationError, match="folder"):
|
||||
TrainingSource(kind="folder")
|
||||
FolderTrainingSource(kind="folder")
|
||||
with pytest.raises(ValidationError, match="line_hz"):
|
||||
TrainingSource(kind="folder", folder="hel", line_hz=55)
|
||||
FolderTrainingSource(kind="folder", folder="hel", line_hz=55)
|
||||
|
||||
|
||||
def test_the_site_trains_on_children_without_the_diagnosis_by_the_cut_off(fresh_platform):
|
||||
@@ -94,8 +94,8 @@ def test_the_site_trains_on_children_without_the_diagnosis_by_the_cut_off(fresh_
|
||||
{"key": "a", "age_months": 20.0, "valid": True, "error": None,
|
||||
"features": {"eeg-gradient": {"value": 1.0}}},
|
||||
] # fmt: skip
|
||||
digest, measured, cohort, hz = jobs._cohort(TrainingSource(), cut)
|
||||
digest, measured, cohort, hz = jobs._cohort(SiteTrainingSource(kind="site"), cut)
|
||||
assert (cohort, hz, [m["key"] for m in measured]) == ("site", None, ["a"])
|
||||
assert len(digest) == 64
|
||||
with pytest.raises(EmptyCohort, match="without the diagnosis by 2025-01-01"):
|
||||
jobs._cohort(TrainingSource(), date(2025, 1, 1))
|
||||
jobs._cohort(SiteTrainingSource(kind="site"), date(2025, 1, 1))
|
||||
|
||||
Reference in New Issue
Block a user