rename: tea-modulo / tea_modulo -> tea (distribution, package, entry-point groups, MLflow names, image paths)

This commit is contained in:
AlbertoPMDM
2026-11-19 08:26:43 -06:00
parent fe36d5d859
commit e8e5b96755
320 changed files with 360 additions and 360 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ def make_prep(seconds=60.0, fs=250.0, channels=("Fp1", "Fp2", "O1", "O2"), seed=
window_s=4.0, step_s=2.0):
"""A small Preprocessed made in memory (white noise, one variant)."""
import mne
from tea_modulo.contracts import Preprocessed
from tea.contracts import Preprocessed
rng = np.random.default_rng(seed)
n = int(seconds * fs)
+3 -3
View File
@@ -12,7 +12,7 @@ import numpy as np
import pandas as pd
import pytest
from tea_modulo.contracts import (
from tea.contracts import (
CONTRACT_VERSION,
DEVIATION_COLUMNS,
ContractError,
@@ -21,7 +21,7 @@ from tea_modulo.contracts import (
Study,
check_module,
)
from tea_modulo.contracts.testing import check_biomarker, check_process
from tea.contracts.testing import check_biomarker, check_process
class ConstantState:
@@ -144,7 +144,7 @@ def test_fake_biomarker_passes_the_suite():
def test_recording_from_edf(tmp_path):
"""Recording.from_edf reads an EDF with MNE and keeps only the file stem."""
import mne
from tea_modulo.contracts import Recording
from tea.contracts import Recording
info = mne.create_info(["Fp1", "O1"], 250.0, "eeg")
raw = mne.io.RawArray(np.random.default_rng(0).normal(0, 20e-6, (2, 2500)), info, verbose="error")
p = tmp_path / "study.edf"
+7 -7
View File
@@ -17,11 +17,11 @@ import pytest
import ktlx_synth as tr
from edfio import EdfSignal
from tea_modulo.export import edf_export as ex
from tea_modulo.export import ktlx
from tea_modulo.export.edf_annotations import BAD_ACQ_SKIP, clamped
from tea_modulo.export.edf_header import EDF_RECORDING_LEN, recording_header
from tea_modulo.export.edf_signals import DIGITAL_RANGE, build_signals, half_range
from tea.export import edf_export as ex
from tea.export import ktlx
from tea.export.edf_annotations import BAD_ACQ_SKIP, clamped
from tea.export.edf_header import EDF_RECORDING_LEN, recording_header
from tea.export.edf_signals import DIGITAL_RANGE, build_signals, half_range
ACCENTED = "Fotoestimulación ñandú"
ACCENTED_STAMP = 200
@@ -223,7 +223,7 @@ def test_start_time_without_snc_is_utc(study, tmp_path, monkeypatch):
def test_cli_reports_errors_without_traceback(tmp_path, caplog, capsys):
from tea_modulo.export import cli
from tea.export import cli
with caplog.at_level(logging.ERROR):
assert cli.main([str(tmp_path / "missing")]) == 1
assert "La carpeta no existe" in caplog.text
@@ -231,7 +231,7 @@ def test_cli_reports_errors_without_traceback(tmp_path, caplog, capsys):
def test_cli_converts(study, tmp_path, capsys):
from tea_modulo.export import cli
from tea.export import cli
out = tmp_path / "cli.edf"
assert cli.main([str(study.folder), "-o", str(out)]) == 0
assert out.exists() and str(out) in capsys.readouterr().out
+2 -2
View File
@@ -1,11 +1,11 @@
"""Unit tests for the sex / birthdate extraction (tea_modulo.export.patient)."""
"""Unit tests for the sex / birthdate extraction (tea.export.patient)."""
import struct
from datetime import date, datetime, timedelta
import pytest
from tea_modulo.export import patient
from tea.export import patient
@pytest.mark.parametrize("raw, expected", [
+1 -1
View File
@@ -13,7 +13,7 @@ from pathlib import Path
import numpy as np
from tea_modulo.export import ktlx
from tea.export import ktlx
FS = 256.0
N_CHAN = 20
+4 -4
View File
@@ -11,10 +11,10 @@ import numpy as np
import pytest
from synth_edf import make_edf
from tea_modulo.contracts.testing import check_preprocessed
from tea_modulo.legacy.preprocessing import MODULE, PlanNotSupported, windows_from_qc
from tea_modulo.legacy.validation import MODULE as VAL
from tea_modulo.preprocessing import DIRECTOR_CLI, DIRECTOR_CLUSTER
from tea.contracts.testing import check_preprocessed
from tea.legacy.preprocessing import MODULE, PlanNotSupported, windows_from_qc
from tea.legacy.validation import MODULE as VAL
from tea.preprocessing import DIRECTOR_CLI, DIRECTOR_CLUSTER
ROOT = Path(__file__).resolve().parents[2]
PREPROCESO = ROOT / "biomarcadores-tea" / "preproceso"
+8 -8
View File
@@ -16,14 +16,14 @@ import pandas as pd
import pytest
from synth_edf import make_edf
from tea_modulo.contracts import Study
from tea_modulo.contracts.testing import check_biomarker, check_process
from tea_modulo.legacy.biomarkers.posterior_rhythm import LegacyPosteriorRhythm
from tea_modulo.legacy.preprocessing import MODULE as PRE
from tea_modulo.legacy.processes.annotation_mask import MODULE as AM
from tea_modulo.legacy.processes.sleep_state import MODULE as SS
from tea_modulo.legacy.validation import MODULE as VAL
from tea_modulo.preprocessing import DIRECTOR_CLUSTER
from tea.contracts import Study
from tea.contracts.testing import check_biomarker, check_process
from tea.legacy.biomarkers.posterior_rhythm import LegacyPosteriorRhythm
from tea.legacy.preprocessing import MODULE as PRE
from tea.legacy.processes.annotation_mask import MODULE as AM
from tea.legacy.processes.sleep_state import MODULE as SS
from tea.legacy.validation import MODULE as VAL
from tea.preprocessing import DIRECTOR_CLUSTER
ROOT = Path(__file__).resolve().parents[2]
BT = ROOT / "biomarcadores-tea"
+3 -3
View File
@@ -2,7 +2,7 @@
Legacy validation = the director's code, exactly.
The submodule's own scripts (biomarcadores-tea/preproceso via sys.path) and
tea_modulo.legacy.validation run on the same synthetic EDF must give identical
tea.legacy.validation run on the same synthetic EDF must give identical
results: channel table, dropped channels, window QC and triage.
"""
@@ -20,8 +20,8 @@ import pandas as pd
import pytest
from synth_edf import SCALP, make_edf
from tea_modulo.contracts.testing import check_validation
from tea_modulo.legacy.validation import MODULE
from tea.contracts.testing import check_validation
from tea.legacy.validation import MODULE
ROOT = Path(__file__).resolve().parents[2]
PREPROCESO = ROOT / "biomarcadores-tea" / "preproceso"
+4 -4
View File
@@ -8,13 +8,13 @@ import numpy as np
import pytest
from synth_edf import make_edf
from tea_modulo.contracts.testing import check_biomarker
from tea_modulo.pipeline import Pipeline
from tea_modulo.preprocessing import DIRECTOR_CLUSTER
from tea.contracts.testing import check_biomarker
from tea.pipeline import Pipeline
from tea.preprocessing import DIRECTOR_CLUSTER
ROOT = Path(__file__).resolve().parents[1]
BIO = ROOT / "biomarcadores-tea" / "biomarcadores"
LEG = ROOT / "src" / "tea_modulo" / "legacy" / "biomarkers"
LEG = ROOT / "src" / "tea" / "legacy" / "biomarkers"
@pytest.mark.skipif(not BIO.exists(), reason="submodule absent")
+9 -9
View File
@@ -1,7 +1,7 @@
"""
The boundary rule: a module imports only `tea_modulo.contracts`, the standard
The boundary rule: a module imports only `tea.contracts`, the standard
library and its approved third-party libraries. It never imports another
`tea_modulo` module, so any module can be replaced without touching the rest.
`tea` module, so any module can be replaced without touching the rest.
"""
from __future__ import annotations
@@ -12,7 +12,7 @@ from pathlib import Path
import pytest
SRC = Path(__file__).resolve().parents[1] / "src" / "tea_modulo"
SRC = Path(__file__).resolve().parents[1] / "src" / "tea"
# Approved third-party libraries (top-level import names).
BASE = {"numpy", "scipy", "pandas", "mne", "sklearn", "antropy", "fooof", "yasa",
@@ -31,7 +31,7 @@ LEGACY_ADAPTERS = {"_adapter.py", "fhir.py", "api.py", "__init__.py"}
def unit_of(path: Path) -> tuple[str, ...]:
"""The replaceable unit a file belongs to, as a path tuple under tea_modulo."""
"""The replaceable unit a file belongs to, as a path tuple under tea."""
rel = path.relative_to(SRC).parts
if rel[0] == "legacy":
rest = rel[1:]
@@ -82,20 +82,20 @@ FILES = sorted(p for p in SRC.rglob("*.py"))
@pytest.mark.parametrize("path", FILES, ids=[str(p.relative_to(SRC)) for p in FILES])
def test_imports_respect_boundaries(path):
unit = unit_of(path)
own = "tea_modulo." + ".".join(unit) if unit else "tea_modulo"
own = "tea." + ".".join(unit) if unit else "tea"
bad = []
for mod, line in imports_of(path):
top = mod.split(".")[0]
if top == "tea_modulo":
if top == "tea":
if unit and unit[0] == "export":
ok = mod == own or mod.startswith(own + ".")
elif not unit:
ok = mod in ("tea_modulo", "tea_modulo.contracts") or mod.startswith("tea_modulo.contracts.")
ok = mod in ("tea", "tea.contracts") or mod.startswith("tea.contracts.")
else:
ok = (mod == "tea_modulo.contracts" or mod.startswith("tea_modulo.contracts.")
ok = (mod == "tea.contracts" or mod.startswith("tea.contracts.")
or mod == own or mod.startswith(own + "."))
if unit == ("contracts",):
ok = mod.startswith("tea_modulo.contracts")
ok = mod.startswith("tea.contracts")
elif top in sys.stdlib_module_names or top == "__future__":
ok = True
else:
+5 -5
View File
@@ -7,10 +7,10 @@ import pandas as pd
import pytest
from synth_edf import make_edf
from tea_modulo.contracts import Labels, Study
from tea_modulo.contracts.testing import check_biomarker
from tea_modulo.pipeline import Pipeline
from tea_modulo.preprocessing import DIRECTOR_CLUSTER
from tea.contracts import Labels, Study
from tea.contracts.testing import check_biomarker
from tea.pipeline import Pipeline
from tea.preprocessing import DIRECTOR_CLUSTER
from conftest import make_prep
@@ -60,5 +60,5 @@ def test_biomarker_contract(tmp_path):
pipe = Pipeline.default("modern")
sts = [pipe.study(make_edf(tmp_path / f"s{i}.edf", minutes=6, seed=i), plan=DIRECTOR_CLUSTER,
age_months=20 + 4 * i) for i in range(3)]
from tea_modulo.biomarkers.coupling import Coupling
from tea.biomarkers.coupling import Coupling
check_biomarker(Coupling(baseline="age_blocks"), sts, [20, 24, 28])
+4 -4
View File
@@ -11,9 +11,9 @@ import numpy as np
import pytest
from synth_edf import make_edf
from tea_modulo.contracts.testing import check_biomarker
from tea_modulo.pipeline import Pipeline
from tea_modulo.preprocessing import DIRECTOR_CLUSTER
from tea.contracts.testing import check_biomarker
from tea.pipeline import Pipeline
from tea.preprocessing import DIRECTOR_CLUSTER
BT = Path(__file__).resolve().parents[1] / "biomarcadores-tea"
@@ -82,5 +82,5 @@ def test_biomarker_contract(tmp_path):
pipe = Pipeline.default("modern")
sts = [pipe.study(make_edf(tmp_path / f"s{i}.edf", minutes=6, seed=i), plan=DIRECTOR_CLUSTER,
age_months=20 + 4 * i) for i in range(3)]
from tea_modulo.biomarkers.gradient import Gradient
from tea.biomarkers.gradient import Gradient
check_biomarker(Gradient(baseline="age_blocks"), sts, [20, 24, 28])
+2 -2
View File
@@ -11,8 +11,8 @@ import numpy as np
import pytest
from synth_edf import make_edf
from tea_modulo.pipeline import Pipeline
from tea_modulo.preprocessing import DIRECTOR_CLUSTER
from tea.pipeline import Pipeline
from tea.preprocessing import DIRECTOR_CLUSTER
TOL = 1e-4
+6 -6
View File
@@ -5,11 +5,11 @@ from __future__ import annotations
import pytest
from synth_edf import make_edf
from tea_modulo.contracts import Study
from tea_modulo.contracts.testing import check_biomarker, check_process
from tea_modulo.pipeline import Pipeline
from tea_modulo.preprocessing import DIRECTOR_CLI, DIRECTOR_CLUSTER
from tea_modulo.processes.sleep_state import SleepState
from tea.contracts import Study
from tea.contracts.testing import check_biomarker, check_process
from tea.pipeline import Pipeline
from tea.preprocessing import DIRECTOR_CLI, DIRECTOR_CLUSTER
from tea.processes.sleep_state import SleepState
ANN = [(5, None, "Paciente despierto"), (240.5, None, "Dormido"), (100, 20, "Fotica 5 Hz"), (150, None, "llanto")]
@@ -50,7 +50,7 @@ def test_biomarker_contract(tmp_path):
pipe = Pipeline.default("modern")
sts = [pipe.study(make_edf(tmp_path / f"s{i}.edf", minutes=4, seed=i, rhythm_hz=6 + 0.4 * i),
plan=DIRECTOR_CLUSTER, age_months=20 + 4 * i) for i in range(3)]
from tea_modulo.biomarkers.posterior_rhythm import PosteriorRhythm
from tea.biomarkers.posterior_rhythm import PosteriorRhythm
check_biomarker(PosteriorRhythm(baseline="age_blocks"), sts, [20, 24, 28])
+4 -4
View File
@@ -10,9 +10,9 @@ import pandas as pd
import pytest
from synth_edf import SCALP, make_edf
from tea_modulo.pipeline import NotValid, Pipeline, order_for
from tea_modulo.pipeline import dask_runner
from tea_modulo.preprocessing import DIRECTOR_CLUSTER
from tea.pipeline import NotValid, Pipeline, order_for
from tea.pipeline import dask_runner
from tea.preprocessing import DIRECTOR_CLUSTER
BIOS = ("posterior_rhythm",)
@@ -105,7 +105,7 @@ def test_annotation_text_not_utf8_is_not_an_error(tmp_path):
biomarkers=("posterior_rhythm",),
**({"cluster": "sync"} if impl == "modern" else {}))
assert t.error.iloc[0] == "", (impl, t.error.iloc[0])
from tea_modulo.legacy.preprocessing.api import _annotations
from tea.legacy.preprocessing.api import _annotations
a = _annotations(p)
assert any(d.startswith("ojos cerr") for d in a.description)
+1 -1
View File
@@ -6,7 +6,7 @@ import json
import pytest
from tea_modulo.preprocessing import (
from tea.preprocessing import (
DIRECTOR_CLI,
DIRECTOR_CLUSTER,
PreprocessPlan,
+5 -5
View File
@@ -9,11 +9,11 @@ import numpy as np
import pytest
from synth_edf import make_edf
from tea_modulo.contracts.testing import check_preprocessed
from tea_modulo.legacy.preprocessing import MODULE as LEGACY
from tea_modulo.legacy.validation import MODULE as LVAL
from tea_modulo.preprocessing import DIRECTOR_CLI, DIRECTOR_CLUSTER, MODULE, PreprocessPlan
from tea_modulo.validation import MODULE as VAL
from tea.contracts.testing import check_preprocessed
from tea.legacy.preprocessing import MODULE as LEGACY
from tea.legacy.validation import MODULE as LVAL
from tea.preprocessing import DIRECTOR_CLI, DIRECTOR_CLUSTER, MODULE, PreprocessPlan
from tea.validation import MODULE as VAL
# the director stores variants as float32: compare to float32 precision
TOL_UV = 1e-3
+7 -7
View File
@@ -13,9 +13,9 @@ import pytest
mlflow = pytest.importorskip("mlflow")
from tea_modulo.legacy.biomarkers.posterior_rhythm import LegacyPosteriorRhythm # noqa: E402
from tea_modulo.preprocessing import DIRECTOR_CLUSTER, PreprocessPlan # noqa: E402
from tea_modulo.serving import Forbidden, load_biomarker, load_plan, log_biomarker, log_plan # noqa: E402
from tea.legacy.biomarkers.posterior_rhythm import LegacyPosteriorRhythm # noqa: E402
from tea.preprocessing import DIRECTOR_CLUSTER, PreprocessPlan # noqa: E402
from tea.serving import Forbidden, load_biomarker, load_plan, log_biomarker, log_plan # noqa: E402
@pytest.fixture
@@ -69,20 +69,20 @@ def test_biomarker_model_runs_with_only_its_code(store, tmp_path):
import sys, json, mlflow, pandas as pd
mlflow.set_tracking_uri({store!r}); mlflow.set_registry_uri({store!r})
m = mlflow.pyfunc.load_model("models:/tea-bio-iso/{bv.version}")
import tea_modulo
import tea
out = m.predict(pd.DataFrame({{"posterior_rhythm_hz": [5.0], "age_months": [30.0]}}))
try:
import tea_modulo.pipeline
import tea.pipeline
other = "importable"
except ImportError:
other = "missing"
print(json.dumps({{"pkg": tea_modulo.__file__, "pipeline": other, "outside": int(out.outside.iloc[0])}}))
print(json.dumps({{"pkg": tea.__file__, "pipeline": other, "outside": int(out.outside.iloc[0])}}))
"""
out = subprocess.run([sys.executable, "-W", "ignore", "-c", code], capture_output=True, text=True,
cwd=tmp_path, env={**__import__("os").environ, "MLFLOW_DISABLE_AGENT_HINT": "1"})
assert out.returncode == 0, out.stderr[-2000:]
r = json.loads(out.stdout.strip().splitlines()[-1])
assert "code" in Path(r["pkg"]).parts, r["pkg"] # tea_modulo comes from the model's code
assert "code" in Path(r["pkg"]).parts, r["pkg"] # tea comes from the model's code
assert r["pipeline"] == "missing" # nothing else of the library is there
assert r["outside"] == -1
+6 -6
View File
@@ -12,11 +12,11 @@ import pandas as pd
import pytest
from synth_edf import make_edf
from tea_modulo.contracts import Study
from tea_modulo.contracts.testing import check_biomarker, check_process
from tea_modulo.pipeline import Pipeline
from tea_modulo.preprocessing import DIRECTOR_CLUSTER
from tea_modulo.processes.slow_wave_staging import api as sws
from tea.contracts import Study
from tea.contracts.testing import check_biomarker, check_process
from tea.pipeline import Pipeline
from tea.preprocessing import DIRECTOR_CLUSTER
from tea.processes.slow_wave_staging import api as sws
BT = Path(__file__).resolve().parents[1] / "biomarcadores-tea"
@@ -84,5 +84,5 @@ def test_biomarker_contract(tmp_path):
pipe = Pipeline.default("modern")
sts = [pipe.study(make_edf(tmp_path / f"s{i}.edf", minutes=6, seed=i), plan=DIRECTOR_CLUSTER,
age_months=20 + 4 * i) for i in range(3)]
from tea_modulo.biomarkers.slow_waves import SlowWaves
from tea.biomarkers.slow_waves import SlowWaves
check_biomarker(SlowWaves(baseline="age_blocks"), sts, [20, 24, 28])
+5 -5
View File
@@ -6,10 +6,10 @@ import numpy as np
import pytest
from synth_edf import make_edf
from tea_modulo.contracts import Study
from tea_modulo.contracts.testing import check_biomarker, check_process
from tea_modulo.pipeline import Pipeline
from tea_modulo.preprocessing import DIRECTOR_CLUSTER
from tea.contracts import Study
from tea.contracts.testing import check_biomarker, check_process
from tea.pipeline import Pipeline
from tea.preprocessing import DIRECTOR_CLUSTER
@pytest.fixture(scope="module")
@@ -44,5 +44,5 @@ def test_biomarker_contract(tmp_path):
pipe = Pipeline.default("modern")
sts = [pipe.study(make_edf(tmp_path / f"s{i}.edf", minutes=5, seed=i, bad={"spikes": ["C3"]}),
plan=DIRECTOR_CLUSTER, age_months=20 + 4 * i) for i in range(3)]
from tea_modulo.biomarkers.spikes import Spikes
from tea.biomarkers.spikes import Spikes
check_biomarker(Spikes(baseline="age_blocks"), sts, [20, 24, 28])
+6 -6
View File
@@ -6,9 +6,9 @@ import numpy as np
import pytest
from synth_edf import SPINDLE, make_edf
from tea_modulo.contracts.testing import check_biomarker
from tea_modulo.pipeline import Pipeline
from tea_modulo.preprocessing import DIRECTOR_CLUSTER
from tea.contracts.testing import check_biomarker
from tea.pipeline import Pipeline
from tea.preprocessing import DIRECTOR_CLUSTER
@pytest.fixture(scope="module")
@@ -20,8 +20,8 @@ def studies(tmp_path_factory):
@pytest.mark.parametrize("laplacian", [False, True])
def test_modern_agrees_with_legacy(studies, laplacian):
from tea_modulo.biomarkers.spindle_topography import SpindleTopography
from tea_modulo.legacy.biomarkers.spindle_topography import LegacySpindleTopography
from tea.biomarkers.spindle_topography import SpindleTopography
from tea.legacy.biomarkers.spindle_topography import LegacySpindleTopography
m = SpindleTopography(laplacian=laplacian).measure(studies[0])
l = LegacySpindleTopography(laplacian=laplacian).measure(studies[1])
for k in m:
@@ -39,5 +39,5 @@ def test_biomarker_contract(tmp_path):
pipe = Pipeline.default("modern")
sts = [pipe.study(make_edf(tmp_path / f"s{i}.edf", minutes=6, seed=i), plan=DIRECTOR_CLUSTER,
age_months=20 + 4 * i) for i in range(3)]
from tea_modulo.biomarkers.spindle_topography import SpindleTopography
from tea.biomarkers.spindle_topography import SpindleTopography
check_biomarker(SpindleTopography(baseline="age_blocks"), sts, [20, 24, 28])
+5 -5
View File
@@ -11,10 +11,10 @@ import numpy as np
import pytest
from synth_edf import make_edf
from tea_modulo.contracts import Study
from tea_modulo.contracts.testing import check_biomarker, check_process
from tea_modulo.pipeline import Pipeline
from tea_modulo.preprocessing import DIRECTOR_CLUSTER
from tea.contracts import Study
from tea.contracts.testing import check_biomarker, check_process
from tea.pipeline import Pipeline
from tea.preprocessing import DIRECTOR_CLUSTER
BT = Path(__file__).resolve().parents[1] / "biomarcadores-tea"
@@ -99,7 +99,7 @@ def test_biomarker_contract(tmp_path):
pipe = Pipeline.default("modern")
sts = [pipe.study(make_edf(tmp_path / f"s{i}.edf", minutes=6, seed=i), plan=DIRECTOR_CLUSTER,
age_months=20 + 4 * i) for i in range(3)]
from tea_modulo.biomarkers.spindles import Spindles
from tea.biomarkers.spindles import Spindles
check_biomarker(Spindles(baseline="age_blocks"), sts, [20, 24, 28])
+3 -3
View File
@@ -5,9 +5,9 @@ from __future__ import annotations
import pytest
from synth_edf import SCALP, make_edf
from tea_modulo.contracts.testing import check_validation
from tea_modulo.legacy.validation import MODULE as LEGACY
from tea_modulo.validation import MODULE, Validation, ValidationConfig
from tea.contracts.testing import check_validation
from tea.legacy.validation import MODULE as LEGACY
from tea.validation import MODULE, Validation, ValidationConfig
CASES = {
"faults": dict(bad={"flat": ["P3"], "bursts": ["P4"], "bridge": [("F3", "C3")]}),
+1 -1
View File
@@ -81,4 +81,4 @@ def test_age_groups(m, g):
def test_verification_is_not_in_the_package():
import importlib.util
assert importlib.util.find_spec("tea_modulo.verify") is None
assert importlib.util.find_spec("tea.verify") is None