commit ca9d3ad81ff085b874a0ea75f7aa1296851a6688 Author: Roberto Treviño Cervantes Date: Mon Sep 21 10:23:42 2026 -0600 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d10c79 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +__pycache__/ +*.pyc +.venv/ +.pytest_cache/ +.coverage +*.egg-info/ +.env +uv.lock diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/models/base.py b/models/base.py new file mode 100644 index 0000000..509ef9d --- /dev/null +++ b/models/base.py @@ -0,0 +1,21 @@ +from abc import ABC, abstractmethod +from typing import Any + + +class ScreeningModel(ABC): + """Standard train()/predict() interface every screening model implements, + regardless of which of the three data marts (CaCu/CaMa/TEA) it targets. + + Implementations are free to pull their own data straight from + `persistance.` — the same standard repository API WebApi uses — + or accept already-fetched rows from a caller; `data` is intentionally + untyped at this scaffolding stage. + """ + + @abstractmethod + def train(self, data: Any = None) -> None: + """Fit the model, optionally on `data` passed in by the caller.""" + + @abstractmethod + def predict(self, data: Any) -> Any: + """Score `data` and return predictions.""" diff --git a/models/cacu.py b/models/cacu.py new file mode 100644 index 0000000..df218f8 --- /dev/null +++ b/models/cacu.py @@ -0,0 +1,19 @@ +from typing import Any + +from models.base import ScreeningModel + + +class CaCuModel(ScreeningModel): + """Scaffold for the CaCu (cervical cancer) screening model. + + Can pull its own training data straight from `persistance.cacu`'s + repositories (`paciente_repository`, `citologia_cervical_repository`, + `biopsia_cervical_repository`, ...) or be handed already-fetched rows. + No real model yet — this is interface scaffolding only. + """ + + def train(self, data: Any = None) -> None: + raise NotImplementedError("CaCu training is not implemented yet.") + + def predict(self, data: Any) -> Any: + raise NotImplementedError("CaCu prediction is not implemented yet.") diff --git a/models/cama.py b/models/cama.py new file mode 100644 index 0000000..b95c61e --- /dev/null +++ b/models/cama.py @@ -0,0 +1,19 @@ +from typing import Any + +from models.base import ScreeningModel + + +class CaMaModel(ScreeningModel): + """Scaffold for the CaMa (breast cancer) screening model. + + Can pull its own training data straight from `persistance.cama`'s + repositories (`paciente_repository`, `mastografia_repository`, + `biopsia_mama_repository`, ...) or be handed already-fetched rows. + No real model yet — this is interface scaffolding only. + """ + + def train(self, data: Any = None) -> None: + raise NotImplementedError("CaMa training is not implemented yet.") + + def predict(self, data: Any) -> Any: + raise NotImplementedError("CaMa prediction is not implemented yet.") diff --git a/models/tea.py b/models/tea.py new file mode 100644 index 0000000..725187e --- /dev/null +++ b/models/tea.py @@ -0,0 +1,19 @@ +from typing import Any + +from models.base import ScreeningModel + + +class TeaModel(ScreeningModel): + """Scaffold for the TEA (autism spectrum disorder) screening model. + + Can pull its own training data straight from `persistance.tea`'s + repositories (`pacientes_repository`, `evaluacion_psicologica_repository`, + ...) or be handed already-fetched rows. No real model yet — this is + interface scaffolding only. + """ + + def train(self, data: Any = None) -> None: + raise NotImplementedError("TEA training is not implemented yet.") + + def predict(self, data: Any) -> Any: + raise NotImplementedError("TEA prediction is not implemented yet.") diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c2c254c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,23 @@ +[project] +name = "models" +version = "0.1.0" +description = "train()/predict() interfaces for the CaCu, CaMa and TEA screening models." +requires-python = ">=3.11" +dependencies = [ + "persistance", +] + +[tool.uv.sources] +persistance = { path = "../Persistance", editable = true } + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.build.targets.wheel] +packages = ["models"] + +[dependency-groups] +dev = [ + "pytest>=8.0.0", +] diff --git a/tests/test_interfaces.py b/tests/test_interfaces.py new file mode 100644 index 0000000..a5b0fee --- /dev/null +++ b/tests/test_interfaces.py @@ -0,0 +1,19 @@ +import pytest + +from models.cacu import CaCuModel +from models.cama import CaMaModel +from models.tea import TeaModel + + +@pytest.mark.parametrize("cls", [CaCuModel, CaMaModel, TeaModel]) +def test_train_not_implemented(cls): + model = cls() + with pytest.raises(NotImplementedError): + model.train() + + +@pytest.mark.parametrize("cls", [CaCuModel, CaMaModel, TeaModel]) +def test_predict_not_implemented(cls): + model = cls() + with pytest.raises(NotImplementedError): + model.predict(data=None)