Imports follow the models package's new layout #7

Merged
edgar merged 1 commits from feature/model-proto into dev 2026-11-04 13:11:50 -06:00
2 changed files with 8 additions and 6 deletions
+6 -4
View File
@@ -19,8 +19,10 @@ def client(wire_domain):
def test_imported_rows_are_what_models_reads_and_model_writes_are_what_the_api_serves(client):
"""Rows imported over HTTP are read back through `models`' repository, and a row written there is served by
the API. Fails if `resolve_repository` stops returning the objects WebApi writes with."""
from core.cama.models import Mastografia
from models.cama import CaMaModel
from models.io.repositories import resolve_repository
csv = b"Expediente,BIRADS\nRT-1,BI-RADS 4\nRT-2,2\n"
response = client.post(
@@ -38,11 +40,11 @@ def test_imported_rows_are_what_models_reads_and_model_writes_are_what_the_api_s
)
assert response.get_json()["results"][0]["created"] == 2
model = CaMaModel()
seen = {row["pac_id_hospital"]: row["mast_birads"] for row in model.dataset("mastografia")}
repository = resolve_repository("cama", "mastografia")
seen = {row.pac_id_hospital: row.mast_birads for row in repository.iter_all()}
assert seen == {"RT-1": "B4", "RT-2": "B2"}
model.repository("mastografia").create(Mastografia(pac_id_hospital="RT-FROM-MODEL", mast_birads="B1"))
repository.create(Mastografia(pac_id_hospital="RT-FROM-MODEL", mast_birads="B1"))
served = client.get("/data/cama.Mastografia").get_json()
assert served["total"] == 3
assert "RT-FROM-MODEL" in {row["pac_id_hospital"] for row in served["rows"]}
+2 -2
View File
@@ -1,7 +1,7 @@
"""Model governance (ML, MLD, EL and VAR requirements): model versions and
their promotion, and the OCR extraction jobs with their manual review queue.
Versions and artifacts live in MLflow (`models.registry`); training runs
Versions and artifacts live in MLflow (`models.io.registry`); training runs
elsewhere and registers its result through `POST /model-versions`, naming
the indicator kit cohort build it was trained on (`cohorte_armado_id`).
"""
@@ -11,8 +11,8 @@ from core.governance.enums import EstatusExtraccion
from core.governance.models import ExtractionRun
from core.ocr import OcrEstatus
from flask import Blueprint, Response, jsonify, request
from models.io.registry import REPORT_TAGS, PromotionBlocked, registry
from models.ocr import OCR_JOBS, OcrJob, run_pending_extractions
from models.registry import REPORT_TAGS, PromotionBlocked, registry
from persistance.governance import extraction_run_repository
from persistance.repository import Repository