Merge feature/tea-eeg-analysis into feature/tea-eeg-baseline-bundles

This commit is contained in:
AlbertoPMDM
2026-11-20 09:38:00 -06:00
2 changed files with 50 additions and 3 deletions
+31
View File
@@ -125,6 +125,37 @@ def test_a_promoted_baseline_scores_the_analysis(mlflow_tracking, reference):
assert baselines.label("eeg-posterior-rhythm") == f"tea-eeg-posterior-rhythm/{version}"
def test_loading_a_baseline_leaves_the_import_path_alone(mlflow_tracking, reference):
"""Pins down: loading a promoted baseline leaves `sys.path` as it was and `tea` the installed package, so a Dask
worker spawned after the first batch still imports `tea.pipeline`.
Fails if `Baselines` loads through MLflow without restoring `sys.path`: the model's bundled partial `tea` would
shadow the library in every worker spawned afterwards, and each of their studies would fail with
`No module named 'tea.pipeline'`.
"""
import subprocess
import sys
import tea
from models.io.registry import registry
from models.tea.eeg.baselines import Baselines
found, studies = reference
(version, _) = train.train_all(settings(), "PROD", found=found, studies=studies)["eeg-posterior-rhythm"]
registry.attach_reports("tea", "eeg-posterior-rhythm", version, technical_validation_report_uri="r://t",
clinical_validation_report_uri="r://c", interpretability_report_uri="r://i")
registry.promote("tea", "eeg-posterior-rhythm", version)
before, package = list(sys.path), tea.__file__
assert Baselines("tea").module("eeg-posterior-rhythm") is not None
assert sys.path == before
assert sys.modules["tea"].__file__ == package
spawned = subprocess.run([sys.executable, "-c", "import sys, json; sys.path[:] = json.loads(sys.argv[1]); "
"import tea.pipeline", __import__("json").dumps(sys.path)], capture_output=True)
assert spawned.returncode == 0, spawned.stderr.decode()[-300:]
def test_run_takes_only_train_and_promote_for_the_baselines(mlflow_tracking):
"""Pins down: `models run tea eeg` runs the baselines' own steps: a cohort step is refused, and promoting with
nothing trained says so and fails.