Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 461d651805 | |||
| 790879513b | |||
| e19121bc42 | |||
| 0f9433949f | |||
| a0407e41d6 | |||
| c430a5bd11 | |||
| 270e229a51 | |||
| 82504bd0bf | |||
| 2296598896 |
+17
-1
@@ -1,6 +1,17 @@
|
||||
# Build context is the repo root (see docker-compose.yml) so the sibling
|
||||
# packages Core/, Persistance/, Extraction/ and models/
|
||||
# can be copied.
|
||||
# can be copied, and Transformation/ compiled.
|
||||
|
||||
# dbt's manifest: the measures' definitions and the compiled SQL of their event
|
||||
# models. The API serves the measures from it and the indicator cycle creates
|
||||
# the views. Compiling needs no data; the SQL is SQLite's, the image's default
|
||||
# engine.
|
||||
FROM python:3.12-slim AS manifest
|
||||
COPY --from=ghcr.io/astral-sh/uv:0.7.9 /uv /uvx /bin/
|
||||
WORKDIR /app/Transformation
|
||||
COPY Transformation/ ./
|
||||
RUN uv sync && uv run --no-sync dbt compile --profiles-dir . --profile tea
|
||||
|
||||
FROM python:3.12-slim
|
||||
|
||||
# Tesseract (with Spanish data) for scanned documents; pytesseract only wraps the binary.
|
||||
@@ -34,6 +45,11 @@ ENV MLFLOW_DISABLE_TELEMETRY=true DO_NOT_TRACK=true
|
||||
ENV WEBAPI_REPORT_DIR=/data/reportes
|
||||
ENV INDICADORES_DIR=/data/indicadores
|
||||
ENV MLFLOW_DISABLE_AGENT_HINT=1
|
||||
# Without it the measure routes (/<domain>/indicadores, /<domain>/fhir) aren't
|
||||
# registered. On another engine, mount a manifest compiled with that dbt target
|
||||
# and point this at it.
|
||||
COPY --from=manifest /app/Transformation/target/manifest.json /app/Transformation/target/manifest.json
|
||||
ENV DBT_MANIFEST=/app/Transformation/target/manifest.json
|
||||
|
||||
RUN chmod +x /app/WebApi/docker-entrypoint.sh
|
||||
|
||||
|
||||
@@ -18,15 +18,13 @@ webapi/
|
||||
│ ├── data.py /data: lectura paginada de cada tabla importable
|
||||
│ ├── cacu.py, cama.py, tea.py /<dominio>/indicadores
|
||||
│ ├── reportes.py /reportes: bitácora de importaciones y estado del recálculo
|
||||
│ └── governance.py /governance: versiones de modelos, notebooks y cola de OCR
|
||||
│ └── governance.py /governance: versiones de modelos y cola de OCR
|
||||
├── imports/
|
||||
│ ├── connectors/ una clase por tipo de fuente (@register_connector)
|
||||
│ ├── schemas/ un esquema pydantic por tabla destino; registry.py los enlista
|
||||
│ ├── mapping/ sugerencia de mapeo de columnas
|
||||
│ ├── services/ validación, combinación de fuentes, enlace de llaves, escritura
|
||||
│ │ y aprendizaje de las correcciones de documentos (review_learning.py)
|
||||
│ ├── services/ validación, combinación de fuentes, enlace de llaves y escritura
|
||||
│ └── audit.py bitácora agregada (sin datos de pacientes)
|
||||
├── nlp.py python -m webapi.nlp evaluate|train: extracción contra una clave de respuestas
|
||||
├── indicadores.py rutas de indicadores (del equipo de indicadores)
|
||||
├── recomputation.py cola y servicio que recalcula indicadores tras cada carga
|
||||
└── seguimiento.py lista de seguimiento por paciente (solo con DEV_REVISION)
|
||||
@@ -47,7 +45,7 @@ y una entrada en `imports/schemas/registry.py`.
|
||||
| `/data/<dominio>.<Tabla>` | Filas de una tabla importable, paginadas (`limit`, `offset`) |
|
||||
| `/<dominio>/indicadores` | Catálogo de indicadores y, por indicador, `/periodos`, `/datos`, `/metadatos` y `/figuras/<figura>` |
|
||||
| `/reportes` | `GET /reportes/importaciones` (resumen y últimos intentos), `/importaciones/descarga`, `GET /reportes/indicadores`, `POST /reportes/indicadores/<dominio>/recalcular` |
|
||||
| `/governance` | Versiones de modelos en MLflow (registro, revisión, promoción, retiro, descarga de sus archivos), notebooks corridos sobre una cohorte exportada (`/governance/experiments`, `/governance/cohort-files`) y cola de revisión de OCR |
|
||||
| `/governance` | Versiones de modelos en MLflow (registro, revisión, promoción, retiro) y cola de revisión de OCR |
|
||||
| `/health` | Verificación de vida |
|
||||
|
||||
Los errores de la solicitud se responden con `{"error": "..."}` y código 400
|
||||
@@ -71,15 +69,6 @@ Los errores de la solicitud se responden con `{"error": "..."}` y código 400
|
||||
| `INDICADORES_INTERVALO_S` | `20` | Cada cuánto revisa la cola |
|
||||
| `INDICADORES_AL_INICIAR` | `1` | Recalcular los tres dominios al arrancar |
|
||||
| `PORT`, `WEBAPI_WORKERS`, `WEBAPI_TIMEOUT` | `5000`, `2`, `600` | gunicorn en el contenedor |
|
||||
| `NOTEBOOK_JOBS_DIR` | sin carpeta | Carpeta compartida con el servicio `notebooks`; con ella los notebooks corren aislados en ese contenedor |
|
||||
| `NOTEBOOK_EXECUTOR` | `contenedor` con `NOTEBOOK_JOBS_DIR`, si no `local` | Dónde corren los notebooks; `local` es en el propio proceso, sin aislar (desarrollo) |
|
||||
| `NOTEBOOK_RUNNER_UID` | ninguno | Usuario del contenedor `notebooks`, dueño de cada carpeta de trabajo |
|
||||
| `NOTEBOOK_JOB_TIMEOUT`, `NOTEBOOK_CELL_TIMEOUT` | `21600`, `1800` | Segundos que espera un notebook completo y una celda |
|
||||
| `NOTEBOOK_MAX_IMPORT_MB` | `500` | Tope de archivos que se importan de lo que entrenó un notebook |
|
||||
| `WEBAPI_NOTEBOOK_WORKERS` | `1` | Notebooks a la vez por proceso de la API |
|
||||
| `EXTRACTION_RANKER` | `auto` | Ranker de extracción de documentos: `auto` (el de producción, si no el último), `produccion` (solo el de producción) o `ninguno` |
|
||||
| `EXTRACTION_LEARNING` | `1` | `0` deja de aprender de las correcciones hechas al revisar documentos |
|
||||
| `NOTEBOOK_RENDERER` | `quarto` si está instalado, si no `jupyter` | Con qué se corre y se arma la página |
|
||||
|
||||
## Ejecución
|
||||
|
||||
@@ -94,15 +83,6 @@ uv run python main.py # http://localhost:5050
|
||||
uv run python -m webapi.recomputation # recálculo de indicadores, en otra terminal
|
||||
```
|
||||
|
||||
Medir la extracción de documentos contra una clave de respuestas (por documento y
|
||||
destino, el valor correcto de cada campo revisado; `null` si debe quedar vacío)
|
||||
y entrenar con ella el ranker del dominio (`Extraction/README.md`):
|
||||
|
||||
```bash
|
||||
uv run python -m webapi.nlp evaluate --documents carpeta/ --key clave.json [--with-values] [--no-ranker]
|
||||
uv run python -m webapi.nlp train --documents carpeta/ --key clave.json
|
||||
```
|
||||
|
||||
Con Docker, desde la raíz del repositorio: `docker compose up --build`. La
|
||||
imagen se construye con `WebApi/Dockerfile` (contexto: la raíz, para copiar
|
||||
los paquetes hermanos); `docker-entrypoint.sh` aplica las migraciones y
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# The notebook runner shares the image but runs with no network, a read-only
|
||||
# system and only the jobs folder (models.io.notebook_jobs): it never touches /data.
|
||||
if [ "$1" = "notebooks" ]; then
|
||||
exec /app/WebApi/.venv/bin/python -m models notebooks serve
|
||||
fi
|
||||
|
||||
mkdir -p /data
|
||||
|
||||
# SQLite won't create a missing parent directory for its database file.
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"flask>=3.0",
|
||||
"persistance",
|
||||
"models[notebooks]",
|
||||
"models[export]",
|
||||
"extraction",
|
||||
"apache-hamilton>=1.90",
|
||||
"pandas>=2.0",
|
||||
|
||||
@@ -31,10 +31,6 @@ os.environ.setdefault("WEBAPI_SQL_ALLOWED_DIALECTS", "sqlite,mysql,mariadb,postg
|
||||
_STATE_DIR = tempfile.mkdtemp(prefix="webapi-tests-")
|
||||
os.environ.setdefault("WEBAPI_REPORT_DIR", os.path.join(_STATE_DIR, "reportes"))
|
||||
os.environ.setdefault("INDICADORES_DIR", os.path.join(_STATE_DIR, "indicadores"))
|
||||
# Extraction ranks by confidence and learns nothing unless a test sets up a
|
||||
# model registry of its own (test_review_learning.py).
|
||||
os.environ.setdefault("EXTRACTION_RANKER", "ninguno")
|
||||
os.environ.setdefault("EXTRACTION_LEARNING", "0")
|
||||
|
||||
ANIO = 2025
|
||||
|
||||
|
||||
+1
-43
@@ -20,18 +20,12 @@ reporte y grado, y una solicitada que todavía no lo tiene.
|
||||
Seis notas médicas con su CIE-10, para el tiempo de la toma al diagnóstico
|
||||
(`NOTAS`; sus casos están en `familias/dias_toma_diagnostico/casos.toml`).
|
||||
|
||||
Texts the silver load reads results from (`TEXTOS`, `INFORME_DE_PATOLOGIA`, `DIAGNOSTICO_DE_NOTA`):
|
||||
H-003's B4A carries density C and a 14 mm lesion, its biopsy a PDF with an invasive ductal carcinoma, grade 2,
|
||||
ER+ 90 %, PR- 0 %, HER2 3+ and Ki-67 25 %, and its oncology note stage IIA. H-101's first mammography says
|
||||
density "tipo E", which the catalog doesn't know: it stays as source text, out of catalog.
|
||||
|
||||
H-001 y H-003 también están en el fixture de CaCu, con otro `pac_id`:
|
||||
lo único común entre los dos sistemas es `pac_id_hospital`.
|
||||
|
||||
Apoyo de pruebas: escribe en la sesión que se le da, nunca en la base del dominio.
|
||||
"""
|
||||
|
||||
import io
|
||||
from datetime import date, timedelta
|
||||
|
||||
from core.cama.models import BiopsiaMama, Mastografia, NotaMedica, OrdenesEstudio, Paciente
|
||||
@@ -75,39 +69,6 @@ NOTAS = (
|
||||
("H-104", None, "C50", ONCOLOGIA), # sin fecha: no cuenta
|
||||
)
|
||||
|
||||
# Index in MASTOGRAFIAS -> the radiologist's interpretation.
|
||||
TEXTOS = {
|
||||
0: "Densidad mamaria: tipo E\nSin hallazgos.",
|
||||
4: "Densidad mamaria: heterogéneamente densas (C).\nNódulo irregular en CSE.\nTamaño de la lesión: 14 mm.",
|
||||
}
|
||||
# Index in BIOPSIAS -> the lines of its pathology report, as a PDF with a text layer.
|
||||
INFORME_DE_PATOLOGIA = {
|
||||
1: (
|
||||
"DIAGNÓSTICO: Carcinoma ductal infiltrante",
|
||||
"Grado histológico: 2 (moderadamente diferenciado)",
|
||||
"Receptores de estrógeno: Positivo (90%)",
|
||||
"Receptores de progesterona: Negativo (0%)",
|
||||
"HER2: 3+",
|
||||
"Ki-67: 25%",
|
||||
),
|
||||
}
|
||||
# Patient -> the diagnosis text of their note.
|
||||
DIAGNOSTICO_DE_NOTA = {"H-003": "Carcinoma de mama izquierda, estadio clínico IIA (T2N0M0)"}
|
||||
|
||||
|
||||
def pdf_de(lineas) -> bytes:
|
||||
"""A one-page PDF with these lines as its text layer."""
|
||||
from reportlab.lib.pagesizes import letter
|
||||
from reportlab.pdfgen import canvas
|
||||
|
||||
buffer = io.BytesIO()
|
||||
hoja = canvas.Canvas(buffer, pagesize=letter)
|
||||
for i, linea in enumerate(lineas):
|
||||
hoja.drawString(72, 720 - 18 * i, linea)
|
||||
hoja.save()
|
||||
return buffer.getvalue()
|
||||
|
||||
|
||||
# Órdenes de estudio: (número, paciente, fecha de la orden, especialidad como la escribe el hospital).
|
||||
# La segunda no es de tamizaje; la tercera está pedida y todavía no tiene mastografía.
|
||||
ORDENES = (
|
||||
@@ -180,12 +141,11 @@ def insertar(sesion: Session) -> None:
|
||||
mast_calidad_imagen=calidad,
|
||||
mast_birads=birads,
|
||||
mast_fecha_reporte=None if sin_reporte else toma + timedelta(days=7),
|
||||
mast_interpretacion=TEXTOS.get(indice),
|
||||
)
|
||||
)
|
||||
sesion.add_all(mastografias)
|
||||
sesion.flush()
|
||||
for numero, (indice, solicitud, reporte, grado) in enumerate(BIOPSIAS):
|
||||
for indice, solicitud, reporte, grado in BIOPSIAS:
|
||||
mastografia = mastografias[indice]
|
||||
sesion.add(
|
||||
BiopsiaMama(
|
||||
@@ -195,7 +155,6 @@ def insertar(sesion: Session) -> None:
|
||||
bx_fecha_solicitud=solicitud,
|
||||
bx_fecha_reporte=reporte,
|
||||
bx_grado_histologico=grado,
|
||||
bx_pdf_blob=pdf_de(INFORME_DE_PATOLOGIA[numero]) if numero in INFORME_DE_PATOLOGIA else None,
|
||||
)
|
||||
)
|
||||
sesion.add_all(
|
||||
@@ -206,7 +165,6 @@ def insertar(sesion: Session) -> None:
|
||||
nm_fecha=fecha,
|
||||
nm_cie_codigo=cie,
|
||||
nm_especialidad=especialidad,
|
||||
nm_diagnostico_texto=DIAGNOSTICO_DE_NOTA.get(hospital) if especialidad == ONCOLOGIA else None,
|
||||
)
|
||||
for numero, (hospital, fecha, cie, especialidad) in enumerate(NOTAS, start=1)
|
||||
)
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
"""What this module covers: CaMa's tumour stratifiers, from the results read from reports to a measure's strata.
|
||||
dbt's `cama_estratificadores` (stage group, early or advanced stage, surrogate molecular subtype, T by size) as
|
||||
timeline facts; `CAMA_BIRADS_CANCER_INVASOR` broken down by them with the `linea_de_tiempo_al_corte` stratum; and the
|
||||
labels a timeline stratum's values carry into FHIR.
|
||||
|
||||
Fixtures: `manifest`, dbt's `manifest.json` (`DBT_MANIFEST`; skipped without it); `base`, the CaMa fixture database
|
||||
(`staging/cama.py`) through the cycle up to `event_models`. Only H-003 has an invasive cancer: biopsy reported on
|
||||
2025-07-28 from her BI-RADS 4A mammogram (14 mm), HER2 3+, and a note of 2025-08-04 with stage IIA.
|
||||
"""
|
||||
|
||||
import os
|
||||
from dataclasses import replace
|
||||
from datetime import date
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from conftest import base_de
|
||||
from sqlalchemy import text
|
||||
from webapi.compositions import answer_composition, composition_definitions
|
||||
from webapi.fhir.measures import _label
|
||||
from webapi.metrics import Question
|
||||
|
||||
URL = "cama/CAMA_BIRADS_CANCER_INVASOR"
|
||||
UNTIL_MODELS = ("catalogs", "load", "views", "registry", "definitions", "event_models")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def manifest():
|
||||
path = os.environ.get("DBT_MANIFEST")
|
||||
if not path:
|
||||
pytest.skip("DBT_MANIFEST isn't set: `dbt compile` in Transformation writes it")
|
||||
return Path(path)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def base(tmp_path, sin_supresion, manifest):
|
||||
base = base_de("cama", tmp_path)
|
||||
base.run(*UNTIL_MODELS, parameters=sin_supresion, allow_undecided=True)
|
||||
yield replace(base, ctx=replace(base.ctx, parameters=sin_supresion, allow_undecided=True))
|
||||
base.motor.dispose()
|
||||
|
||||
|
||||
def answered(base, manifest, period: str, event_cutoff: date | None = None):
|
||||
d = base.dominio
|
||||
definition = composition_definitions(manifest)[URL]
|
||||
return answer_composition("cama", definition, Question(URL, period, event_cutoff=event_cutoff),
|
||||
parameters=d.def_parametro_repository, periods=d.dim_periodo_repository,
|
||||
history=d.history_repository, queries=d.dbt_query_repository, allow_undecided=True)
|
||||
|
||||
|
||||
def stratifiers(base) -> set[str]:
|
||||
with base.motor.connect() as con:
|
||||
return set(con.execute(text("select tipo from cama_estratificadores")).scalars())
|
||||
|
||||
|
||||
def test_the_stratifiers_come_from_h003_s_reports(base):
|
||||
"""Pins down: the view derives the stage's group and early stage from the note, the subtype from the pathology
|
||||
report and T1 from the 14 mm lesion, and nothing for patients without those results. Fails if a rule in
|
||||
`vars.cama.estratos` or a timeline `tipo` it reads changes."""
|
||||
assert stratifiers(base) == {"estadio_ii", "etapa_temprana", "subtipo_her2", "tamano_t1"}
|
||||
|
||||
|
||||
def test_the_measure_breaks_down_the_invasive_cancers_by_tumour(base, manifest):
|
||||
"""Pins down: H-003 counts in S2, the period of her biopsy report, under the BI-RADS of the mammogram that led to
|
||||
it, and in each stratum by what her reports said. S1 has no invasive cancer. Fails if the event model, the
|
||||
category or a stratum's values drift."""
|
||||
assert answered(base, manifest, "2025-S1").categories == {}
|
||||
result = answered(base, manifest, "2025-S2")
|
||||
assert result.categories == {"B4A": 1}
|
||||
assert result.strata == {"grupo_edad": {"50-59": {"B4A": 1}}, "estadio": {"II": {"B4A": 1}},
|
||||
"etapa": {"TEMPRANA": {"B4A": 1}}, "clasificacion": {"HER2": {"B4A": 1}},
|
||||
"tamano": {"T1": {"B4A": 1}}}
|
||||
|
||||
|
||||
def test_a_stratum_by_the_cut_off_sees_only_what_was_dated_by_then(base, manifest):
|
||||
"""Pins down: `linea_de_tiempo_al_corte` reads the timeline up to the event cut-off: on 2025-08-01 the subtype
|
||||
(report of 07-28) is known and the stage (note of 08-04) isn't yet. Fails if the stratum reads before the period's
|
||||
start (H-003 would have nothing) or ignores the cut-off (she'd have her stage)."""
|
||||
strata = answered(base, manifest, "2025-S2", event_cutoff=date(2025, 8, 1)).strata
|
||||
assert strata["clasificacion"] == {"HER2": {"B4A": 1}}
|
||||
assert strata["estadio"] == {"SIN_DATO": {"B4A": 1}}
|
||||
|
||||
|
||||
SUBTIPOS = [
|
||||
({"her2": "H3"}, "subtipo_her2"),
|
||||
({"her2": "H1", "receptor_estrogeno": "NEGATIVO", "receptor_progesterona": "NEGATIVO"}, "subtipo_triple_negativo"),
|
||||
({"her2": "H0", "receptor_progesterona_pct": 50.0, "ki67_pct": 10.0}, "subtipo_luminal_a"),
|
||||
({"her2": "H0", "receptor_progesterona_pct": 50.0, "ki67_pct": 30.0}, "subtipo_luminal_b"),
|
||||
({"her2": "H0", "receptor_progesterona_pct": 10.0, "ki67_pct": 10.0}, "subtipo_luminal_b"),
|
||||
({"her2": "H0", "ki67_pct": None}, None),
|
||||
({"her2": "H2"}, None),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cambios, subtipo", SUBTIPOS)
|
||||
def test_the_surrogate_subtype_follows_its_rules(base, cambios, subtipo):
|
||||
"""Pins down the surrogate subtype from one pathology report: HER2 3+ is HER2-positive; HER2 0 or 1+ with both
|
||||
receptors negative, triple negative; with a positive receptor, luminal A only with Ki-67 under 20 % and
|
||||
progesterone of at least 20 %, else luminal B; without Ki-67, or with an equivocal HER2, none. The fixture's
|
||||
report starts as ER+ 90 %, PR- 0 %, HER2 3+, Ki-67 25 %, with PR made positive here unless a case says otherwise.
|
||||
Fails if a branch of the rule or a threshold in `vars.cama.estratos` changes."""
|
||||
valores = {"receptor_progesterona": "POSITIVO", **cambios}
|
||||
with base.motor.begin() as con:
|
||||
for nombre, valor in valores.items():
|
||||
columna = "valor_numerico" if nombre.endswith("_pct") else "valor_id"
|
||||
con.execute(text(f"update observacion_clinica set {columna} = :v where resultado_id = :r"),
|
||||
{"v": valor, "r": f"biopsia.{nombre}"})
|
||||
assert {t for t in stratifiers(base) if t.startswith("subtipo_")} == ({subtipo} if subtipo else set())
|
||||
|
||||
|
||||
def test_a_timeline_stratum_s_values_carry_their_labels():
|
||||
"""Pins down: FHIR labels a timeline stratum's value from its entry in `valores`, and its `resto` from
|
||||
`resto_etiqueta`. Fails if `_label` reads labels only from a map."""
|
||||
spec = {"valores": [{"valor": "II", "etiqueta": "Estadio II", "si": []}], "resto": "SIN_DATO",
|
||||
"resto_etiqueta": "Sin dato"}
|
||||
assert (_label(spec, "II"), _label(spec, "SIN_DATO"), _label(spec, "IV")) == ("Estadio II", "Sin dato", None)
|
||||
@@ -1,117 +0,0 @@
|
||||
"""`commit_discovered_fields`: writes captions no known field claims
|
||||
straight into `procedimiento`/`observacion`, tagged apart from every
|
||||
staging-derived row with `FUENTE_CATALOGO_ABIERTO`. Fails if a known
|
||||
patient's discovered fields stop landing there, or if an unmatched one
|
||||
stops growing the catalog instead of being silently dropped.
|
||||
"""
|
||||
from datetime import date
|
||||
|
||||
import pytest
|
||||
from sqlmodel import select
|
||||
|
||||
from webapi.orchestration.reference import catalogs as catalogos
|
||||
from webapi.orchestration.tables import tablas_de
|
||||
|
||||
from extraction import ExtractedRecord
|
||||
from extraction.nlp import DiscoveredField, Evidence
|
||||
from webapi.imports.services.catalog_commit_service import FUENTE_CATALOGO_ABIERTO, commit_discovered_fields
|
||||
|
||||
EVIDENCE = Evidence("fila.pdf", 1, "")
|
||||
|
||||
|
||||
def _record(key: str, pairs: list[tuple[str, str]]) -> ExtractedRecord:
|
||||
return ExtractedRecord(
|
||||
values={}, sources=[], key=key, discovered=[DiscoveredField(c, v, EVIDENCE) for c, v in pairs]
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cacu_catalog(tmp_path, monkeypatch):
|
||||
"""`add_resultado`/`sync` write real rows and a real file:
|
||||
kept off the checked-in `cacu.toml` and off any other domain's data."""
|
||||
monkeypatch.setattr(catalogos, "RAIZ_CATALOGOS", tmp_path)
|
||||
(tmp_path / "cacu.toml").write_text(
|
||||
'[citologia]\netiqueta = "Citología cervical"\n\n'
|
||||
'[citologia.resultados.calidad_muestra]\netiqueta = "Calidad de la muestra"\ntipo_valor = "texto"\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
return tmp_path / "cacu.toml"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def known_patient(wire_domain):
|
||||
wire_domain("cacu")
|
||||
from core.cacu.paciente.model import Paciente
|
||||
from persistance.cacu import paciente_repository
|
||||
|
||||
paciente_repository.create(Paciente(pac_id_hospital="DOC-FB-1", pac_fecha_nacimiento=date(1990, 1, 1)))
|
||||
return "DOC-FB-1"
|
||||
|
||||
|
||||
def test_a_matched_field_is_written_on_the_existing_resultado(cacu_catalog, known_patient):
|
||||
result = commit_discovered_fields(
|
||||
[_record(known_patient, [("Calidad de muestra", "Insatisfactoria")])], proyecto="cacu", estudio_id="citologia"
|
||||
)
|
||||
assert (result.records_written, result.fields_matched, result.fields_minted) == (1, 1, 0)
|
||||
|
||||
from persistance.cacu import carga_repository
|
||||
|
||||
with carga_repository.open_session() as sesion:
|
||||
[observacion] = sesion.exec(select(carga_repository.observacion)).all()
|
||||
assert observacion.resultado_id == "citologia.calidad_muestra"
|
||||
assert observacion.valor_texto == "Insatisfactoria"
|
||||
[procedimiento] = sesion.exec(select(carga_repository.procedimiento)).all()
|
||||
assert procedimiento.fuente_tabla == FUENTE_CATALOGO_ABIERTO
|
||||
assert procedimiento.fuente_id == known_patient
|
||||
|
||||
|
||||
def test_an_unmatched_field_is_counted_and_the_catalog_left_untouched(cacu_catalog, known_patient):
|
||||
"""A caption the catalog doesn't know is counted, not written, and the
|
||||
catalog file isn't edited: it's versioned with the code. Fails if the
|
||||
import path mints catalog entries again."""
|
||||
before = cacu_catalog.read_text(encoding="utf-8")
|
||||
result = commit_discovered_fields(
|
||||
[_record(known_patient, [("Tipo de fijador", "Formol")])], proyecto="cacu", estudio_id="citologia"
|
||||
)
|
||||
assert (result.records_written, result.fields_minted, result.fields_unmatched) == (0, 0, 1)
|
||||
assert cacu_catalog.read_text(encoding="utf-8") == before
|
||||
|
||||
from persistance.cacu import carga_repository
|
||||
|
||||
with carga_repository.open_session() as sesion:
|
||||
assert sesion.exec(select(carga_repository.observacion)).all() == []
|
||||
|
||||
|
||||
def test_a_patient_outside_persona_is_skipped_not_dropped_silently(cacu_catalog, known_patient):
|
||||
result = commit_discovered_fields(
|
||||
[_record("NOT-A-PATIENT", [("Calidad de muestra", "x")])], proyecto="cacu", estudio_id="citologia"
|
||||
)
|
||||
assert (result.records_written, result.records_without_patient) == (0, 1)
|
||||
|
||||
|
||||
def test_a_record_without_discovered_fields_is_ignored(cacu_catalog, known_patient):
|
||||
result = commit_discovered_fields([_record(known_patient, [])], proyecto="cacu", estudio_id="citologia")
|
||||
assert result.records_written == 0
|
||||
|
||||
|
||||
def test_a_repeated_caption_is_folded_not_written_twice(cacu_catalog, known_patient):
|
||||
"""A static label printed on several pages of the same document (a date,
|
||||
a signature line) discovers as one `DiscoveredField` per occurrence,
|
||||
on purpose (`discover_captions`'s docstring). Fails if this stops
|
||||
folding repeats before writing: `observacion` has one row per
|
||||
`(procedimiento, resultado_id)`, so a second occurrence of the same
|
||||
resultado_id raises `IntegrityError` and the whole record's fields —
|
||||
including the ones that weren't duplicated — are lost."""
|
||||
result = commit_discovered_fields(
|
||||
[_record(known_patient, [("Calidad de muestra", "Insatisfactoria"), ("Calidad de muestra", "Satisfactoria")])],
|
||||
proyecto="cacu",
|
||||
estudio_id="citologia",
|
||||
)
|
||||
assert (result.records_written, result.fields_matched, result.fields_minted) == (1, 1, 0)
|
||||
|
||||
from persistance.cacu import carga_repository
|
||||
|
||||
with carga_repository.open_session() as sesion:
|
||||
[observacion] = sesion.exec(select(carga_repository.observacion)).all()
|
||||
assert observacion.resultado_id == "citologia.calidad_muestra"
|
||||
assert observacion.valor_texto == "Insatisfactoria"
|
||||
@@ -1,90 +0,0 @@
|
||||
"""`catalog_matching.match_or_mint`: fails if it stops reusing an existing
|
||||
catalog field for an OCR caption that's clearly the same thing worded
|
||||
differently, or if an unmatched caption stops being added to the catalog
|
||||
and silently drops its value instead.
|
||||
"""
|
||||
from datetime import date
|
||||
|
||||
import pytest
|
||||
from webapi.orchestration.reference import catalogs as catalogos
|
||||
from webapi.orchestration.reference.catalogs import Catalogo
|
||||
from webapi.orchestration.tables import tablas_de
|
||||
|
||||
from extraction.nlp import DiscoveredField, Evidence
|
||||
from webapi.imports.schemas.catalog_matching import match_or_mint
|
||||
|
||||
EVIDENCE = Evidence("fila.pdf", 1, "")
|
||||
|
||||
|
||||
def _field(caption: str, value: str) -> DiscoveredField:
|
||||
return DiscoveredField(caption, value, EVIDENCE)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def catalogo() -> Catalogo:
|
||||
tablas = tablas_de("cacu")
|
||||
return Catalogo(
|
||||
estudios=[tablas.CatEstudio(estudio_id="citologia", etiqueta="Citología cervical")],
|
||||
resultados=[
|
||||
tablas.CatResultado(
|
||||
resultado_id="citologia.calidad_muestra", estudio_id="citologia",
|
||||
etiqueta="Calidad de la muestra", tipo_valor="codigo",
|
||||
),
|
||||
tablas.CatResultado(
|
||||
resultado_id="citologia.celulas_glandulares", estudio_id="citologia",
|
||||
etiqueta="Células glandulares", tipo_valor="texto",
|
||||
),
|
||||
],
|
||||
valores=[
|
||||
tablas.CatValor(
|
||||
resultado_id="citologia.calidad_muestra", valor_id="SATISFACTORIO",
|
||||
etiqueta="Satisfactoria", orden=1, estado="vigente",
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def catalogo_toml(tmp_path, monkeypatch):
|
||||
"""`add_resultado` writes to disk; keep it off the real `cacu.toml`."""
|
||||
monkeypatch.setattr(catalogos, "RAIZ_CATALOGOS", tmp_path)
|
||||
(tmp_path / "cacu.toml").write_text("", encoding="utf-8")
|
||||
return tmp_path / "cacu.toml"
|
||||
|
||||
|
||||
def test_a_worded_differently_caption_reuses_the_existing_resultado(catalogo, catalogo_toml):
|
||||
[matched] = match_or_mint(
|
||||
[_field("Calidad de muestra", "SATISFACTORIO")], proyecto="cacu", catalogo=catalogo, estudio_id="citologia"
|
||||
)
|
||||
assert matched.resultado_id == "citologia.calidad_muestra" and not matched.is_new
|
||||
assert matched.observacion["valor_id"] == "SATISFACTORIO"
|
||||
assert catalogo_toml.read_text(encoding="utf-8") == "" # nothing minted
|
||||
|
||||
|
||||
def test_an_unmatched_caption_in_a_known_estudio_is_minted_there(catalogo, catalogo_toml):
|
||||
[matched] = match_or_mint(
|
||||
[_field("Tipo de fijador", "Formol")], proyecto="cacu", catalogo=catalogo, estudio_id="citologia"
|
||||
)
|
||||
assert matched.is_new and matched.resultado_id.startswith("citologia.")
|
||||
assert matched.observacion["valor_texto"] == "Formol"
|
||||
|
||||
sincronizado = catalogos.catalogo_desde_toml(catalogo_toml, tablas=tablas_de("cacu"))
|
||||
assert matched.resultado_id in {r.resultado_id for r in sincronizado.resultados}
|
||||
|
||||
|
||||
def test_an_unmatched_caption_with_no_estudio_falls_back_to_documento_externo(catalogo, catalogo_toml):
|
||||
[matched] = match_or_mint([_field("Observación suelta", "algo")], proyecto="cacu", catalogo=catalogo)
|
||||
assert matched.resultado_id == "documento_externo." + matched.resultado_id.split(".", 1)[1]
|
||||
|
||||
sincronizado = catalogos.catalogo_desde_toml(catalogo_toml, tablas=tablas_de("cacu"))
|
||||
assert "documento_externo" in {e.estudio_id for e in sincronizado.estudios}
|
||||
|
||||
|
||||
def test_the_inferred_tipo_valor_follows_the_value_shape(catalogo, catalogo_toml):
|
||||
fecha, numero, texto = match_or_mint(
|
||||
[_field("Fecha de algo", "15/01/2024"), _field("Cuenta de algo", "12.5"), _field("Nota libre", "ninguna")],
|
||||
proyecto="cacu", catalogo=catalogo, estudio_id="citologia",
|
||||
)
|
||||
assert fecha.observacion["valor_fecha"] == date(2024, 1, 15)
|
||||
assert numero.observacion["valor_numerico"] == 12.5
|
||||
assert texto.observacion["valor_texto"] == "ninguna"
|
||||
@@ -1,77 +0,0 @@
|
||||
"""`add_resultado`: adds a new field to a project's catalog TOML file on
|
||||
disk, for a caller (`webapi.imports.schemas.catalog_matching`) that found a
|
||||
field no catalog entry matches closely enough. Each test pins down one
|
||||
rule of that append; fails if any of them regresses into losing data or
|
||||
duplicating an entry that's already there.
|
||||
"""
|
||||
import pytest
|
||||
|
||||
from webapi.orchestration.reference import catalogs as catalogos
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def catalogo_file(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(catalogos, "RAIZ_CATALOGOS", tmp_path)
|
||||
|
||||
def escribir(contenido: str) -> None:
|
||||
(tmp_path / "prueba.toml").write_text(contenido, encoding="utf-8")
|
||||
|
||||
return escribir
|
||||
|
||||
|
||||
def test_a_new_resultado_is_appended_under_its_existing_estudio(catalogo_file):
|
||||
catalogo_file('[citologia]\netiqueta = "Citología"\n')
|
||||
|
||||
resultado_id = catalogos.add_resultado(
|
||||
"prueba", estudio_id="citologia", nombre="nuevo_campo", etiqueta="Nuevo campo", tipo_valor="texto"
|
||||
)
|
||||
|
||||
assert resultado_id == "citologia.nuevo_campo"
|
||||
leido = catalogos._leer(catalogos.ruta_de_catalogo("prueba"))
|
||||
assert leido["citologia"]["etiqueta"] == "Citología" # what was already there survives
|
||||
assert leido["citologia"]["resultados"]["nuevo_campo"] == {"etiqueta": "Nuevo campo", "tipo_valor": "texto"}
|
||||
|
||||
|
||||
def test_a_resultado_of_an_unknown_estudio_also_creates_the_estudio(catalogo_file):
|
||||
catalogo_file("")
|
||||
|
||||
catalogos.add_resultado(
|
||||
"prueba",
|
||||
estudio_id="documento_externo",
|
||||
nombre="campo",
|
||||
etiqueta="Campo",
|
||||
tipo_valor="fecha",
|
||||
estudio_etiqueta="Documento externo",
|
||||
)
|
||||
|
||||
leido = catalogos._leer(catalogos.ruta_de_catalogo("prueba"))
|
||||
assert leido["documento_externo"]["etiqueta"] == "Documento externo"
|
||||
assert leido["documento_externo"]["resultados"]["campo"]["tipo_valor"] == "fecha"
|
||||
|
||||
|
||||
def test_adding_the_same_resultado_twice_does_not_touch_the_file(catalogo_file):
|
||||
"""Fails if re-discovering the same field on a later row duplicates it
|
||||
or rewrites what a human already edited in the file."""
|
||||
original = '[citologia]\netiqueta = "Citología"\n\n[citologia.resultados.campo]\netiqueta = "Campo"\ntipo_valor = "texto"\n'
|
||||
catalogo_file(original)
|
||||
|
||||
catalogos.add_resultado("prueba", estudio_id="citologia", nombre="campo", etiqueta="Otra cosa", tipo_valor="numero")
|
||||
|
||||
assert catalogos.ruta_de_catalogo("prueba").read_text(encoding="utf-8") == original
|
||||
|
||||
|
||||
def test_an_unknown_tipo_valor_is_rejected(catalogo_file):
|
||||
catalogo_file("")
|
||||
with pytest.raises(catalogos.CatalogoInvalido):
|
||||
catalogos.add_resultado("prueba", estudio_id="x", nombre="y", etiqueta="Y", tipo_valor="no_existe")
|
||||
|
||||
|
||||
def test_a_quote_in_a_label_does_not_break_the_file(catalogo_file):
|
||||
"""Fails if a caption or label read off a document (arbitrary text)
|
||||
produces TOML the next `catalogo_desde_toml` can't parse."""
|
||||
catalogo_file("")
|
||||
catalogos.add_resultado(
|
||||
"prueba", estudio_id="nota", nombre="campo", etiqueta='Dx: "sospechoso"', tipo_valor="texto"
|
||||
)
|
||||
leido = catalogos._leer(catalogos.ruta_de_catalogo("prueba"))
|
||||
assert leido["nota"]["resultados"]["campo"]["etiqueta"] == 'Dx: "sospechoso"'
|
||||
@@ -1,180 +0,0 @@
|
||||
"""Options that let one document source cope with however its rows are
|
||||
stored: columns carried through as field values, a column grouping rows
|
||||
into records, filters that pick which documents feed a target, documents
|
||||
kept as hex or base64 text, unreadable rows, and queries that a derived
|
||||
table can't hold as written.
|
||||
|
||||
Fixtures: `client` (the app wired to a fresh CaCu database) and
|
||||
`documents_table`, a SQLite table built per test whose rows carry two
|
||||
reports of one order, a third report of the same patient under another
|
||||
order, and an unrelated kind of report.
|
||||
"""
|
||||
import base64
|
||||
|
||||
import pytest
|
||||
from sqlalchemy import create_engine, text
|
||||
|
||||
from extraction.testing import text_pdf
|
||||
from webapi.imports.connectors.document import document_bytes
|
||||
from webapi.imports.connectors.sql import SqlConnector, _without_trailing_order_by
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def client(wire_domain):
|
||||
wire_domain("cacu")
|
||||
|
||||
from webapi import create_app
|
||||
|
||||
app = create_app()
|
||||
app.config.update(TESTING=True)
|
||||
with app.test_client() as test_client:
|
||||
yield test_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def documents_table(tmp_path):
|
||||
"""Rows 1 and 2 are two reports of order 10 of patient P-1, row 3 is
|
||||
a report of order 11 of the same patient, and row 4 is a report of a
|
||||
kind the CaCu cytology target doesn't take. No body prints the
|
||||
patient id the structured columns hold."""
|
||||
url = f"sqlite:///{tmp_path / 'docs.db'}"
|
||||
rows = [
|
||||
(1, "P-1", 10, "Prueba de VPH\nVPH alto riesgo: POSITIVO"),
|
||||
(2, "P-1", 10, "Prueba de VPH\nGenotipo 18: DETECTADO"),
|
||||
(3, "P-1", 11, "Prueba de VPH\nVPH alto riesgo: NEGATIVO"),
|
||||
(4, "P-1", 12, "Informe de otra especialidad\nSin datos de VPH"),
|
||||
]
|
||||
with create_engine(url).begin() as conn:
|
||||
conn.execute(text("CREATE TABLE docs (row_id INTEGER, patient INTEGER, order_ref INTEGER, body TEXT)"))
|
||||
for row in rows:
|
||||
conn.execute(text("INSERT INTO docs VALUES (:a, :b, :c, :d)"), dict(zip("abcd", row)))
|
||||
return url
|
||||
|
||||
|
||||
def _payload(url: str, **sql) -> dict:
|
||||
base = {"connection_string": url, "table": "docs", "column": "body", "key_column": "row_id"}
|
||||
return {"sql": {**base, **sql}, "target": "cacu.CitologiaCervical"}
|
||||
|
||||
|
||||
def _extract(client, payload: dict) -> dict:
|
||||
response = client.post("/imports/sources/document/extract", json=payload)
|
||||
assert response.status_code == 200, response.get_json()
|
||||
return response.get_json()
|
||||
|
||||
|
||||
def test_group_column_keeps_orders_apart_and_merges_within_one(client, documents_table):
|
||||
"""Rows sharing `group_column` become one record; the same patient's
|
||||
other order stays its own record. Fails if `group_column` stops
|
||||
reaching `record_keys`."""
|
||||
body = _extract(
|
||||
client,
|
||||
_payload(
|
||||
documents_table,
|
||||
fields={"pac_id_hospital": "patient", "ord_numero_hospital": "order_ref"},
|
||||
group_column="order_ref",
|
||||
)
|
||||
| {"exclude_pattern": "otra especialidad"},
|
||||
)
|
||||
by_key = {record["key"]: record for record in body["records"]}
|
||||
assert set(by_key) == {"10", "11"}
|
||||
assert by_key["10"]["fields"]["cit_vph_genotipo_18"]["value"] == 1
|
||||
assert by_key["11"]["fields"]["cit_vph_resultado"]["value"] == "NEGATIVO"
|
||||
assert by_key["10"]["fields"]["pac_id_hospital"]["value"] == "P-1"
|
||||
|
||||
|
||||
def test_filters_leave_out_other_kinds_of_report_and_say_so(client, documents_table):
|
||||
"""`include_pattern` keeps only matching documents, matched without
|
||||
regard to case or accents, and the rest are listed as skipped. Fails
|
||||
if the filters stop applying or `skipped` stops reporting them."""
|
||||
body = _extract(
|
||||
client,
|
||||
_payload(documents_table, fields={"pac_id_hospital": "patient"}) | {"include_pattern": "prueba de vph"},
|
||||
)
|
||||
assert [skipped["document"] for skipped in body["skipped"]] == ["4"]
|
||||
|
||||
|
||||
def test_a_filter_that_matches_nothing_is_an_error(client, documents_table):
|
||||
"""Filtering out every document is reported instead of returning an
|
||||
empty import. Fails if `_extract` stops refusing an empty selection."""
|
||||
response = client.post(
|
||||
"/imports/sources/document/extract", json=_payload(documents_table) | {"include_pattern": "no aparece"}
|
||||
)
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
def test_an_invalid_filter_is_a_bad_request(client, documents_table):
|
||||
"""A filter that isn't a valid regular expression is rejected with a
|
||||
message naming it. Fails if `_compile_filter` lets `re.error` through."""
|
||||
response = client.post("/imports/sources/document/extract", json=_payload(documents_table) | {"exclude_pattern": "("})
|
||||
assert response.status_code == 400 and "exclude_pattern" in response.get_json()["error"]
|
||||
|
||||
|
||||
def test_documents_stored_as_hex_or_base64_text_are_decoded():
|
||||
"""A PDF kept in a text column as hex (with or without `0x`) or base64
|
||||
reaches the readers as the PDF itself, and ordinary text stays text.
|
||||
Fails if `document_bytes` stops recognizing either encoding."""
|
||||
pdf = text_pdf([["Expediente: X-1"]])
|
||||
assert document_bytes("0x" + pdf.hex()) == pdf
|
||||
assert document_bytes(pdf.hex().upper()) == pdf
|
||||
assert document_bytes(base64.b64encode(pdf).decode()) == pdf
|
||||
assert document_bytes("Expediente: X-1") == b"Expediente: X-1"
|
||||
|
||||
|
||||
def test_an_unreadable_row_is_skipped_not_fatal(client, tmp_path):
|
||||
"""One corrupt document among readable ones is listed as skipped while
|
||||
the rest are extracted. Fails if a single unreadable row aborts the
|
||||
whole source again."""
|
||||
url = f"sqlite:///{tmp_path / 'mixed.db'}"
|
||||
with create_engine(url).begin() as conn:
|
||||
conn.execute(text("CREATE TABLE docs (row_id INTEGER, body BLOB)"))
|
||||
conn.execute(text("INSERT INTO docs VALUES (1, :b)"), {"b": b"%PDF-1.4 truncated"})
|
||||
conn.execute(text("INSERT INTO docs VALUES (2, :b)"), {"b": text_pdf([["Expediente: X-2", "VPH alto riesgo: POSITIVO"]])})
|
||||
body = _extract(client, _payload(url))
|
||||
assert [record["key"] for record in body["records"]] == ["X-2"]
|
||||
assert [skipped["document"] for skipped in body["skipped"]] == ["1"]
|
||||
|
||||
|
||||
def test_repeated_key_column_values_still_name_rows_apart(tmp_path):
|
||||
"""Two rows with the same `key_column` value get distinct names, so
|
||||
neither one's fields or pages overwrite the other's. Fails if
|
||||
`_files_from_sql` stops suffixing repeated names."""
|
||||
from webapi.imports.connectors.document import _files_from_sql
|
||||
|
||||
url = f"sqlite:///{tmp_path / 'r.db'}"
|
||||
with create_engine(url).begin() as conn:
|
||||
conn.execute(text("CREATE TABLE docs (row_id INTEGER, body TEXT)"))
|
||||
conn.execute(text("INSERT INTO docs VALUES (7, 'uno'), (7, 'dos')"))
|
||||
documents = _files_from_sql({"connection_string": url, "table": "docs", "column": "body", "key_column": "row_id"})
|
||||
assert [name for name, _ in documents.files] == ["7", "7#2"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"query,kept",
|
||||
[
|
||||
("SELECT a FROM t ORDER BY a", "SELECT a FROM t"),
|
||||
("SELECT TOP 5 a FROM t ORDER BY a", None),
|
||||
("SELECT a FROM t ORDER BY a OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY", None),
|
||||
("SELECT a, (SELECT TOP 1 b FROM u ORDER BY b) AS x FROM t", None),
|
||||
("SELECT 'ORDER BY' AS s FROM t ORDER BY s", "SELECT 'ORDER BY' AS s FROM t"),
|
||||
],
|
||||
)
|
||||
def test_an_unlimited_trailing_order_by_is_dropped_before_wrapping(query, kept):
|
||||
"""SQL Server refuses `ORDER BY` inside a derived table unless TOP or
|
||||
OFFSET goes with it, so one that only sorts is dropped; one that picks
|
||||
rows, or sits inside a subquery or a string, stays. Fails if
|
||||
`_without_trailing_order_by` drops an `ORDER BY` that chooses rows or
|
||||
keeps one that would make the wrapped query invalid."""
|
||||
assert _without_trailing_order_by(query, "mssql") == (kept or query)
|
||||
|
||||
|
||||
def test_a_named_instance_or_embedded_port_reaches_the_driver():
|
||||
"""`host\\instance` leaves the port unset for the server to resolve,
|
||||
and `host,port` or `host:port` fill it in. Fails if `server_url` stops
|
||||
parsing addresses or goes back to forcing the default port on a named
|
||||
instance."""
|
||||
named = SqlConnector.server_url({"engine": "mssql", "host": "db.example\\INST", "database": "d"})
|
||||
assert (named.host, named.port) == ("db.example\\INST", None)
|
||||
comma = SqlConnector.server_url({"engine": "mssql", "host": "db.example,1500", "database": "d"})
|
||||
assert (comma.host, comma.port) == ("db.example", 1500)
|
||||
colon = SqlConnector.server_url({"engine": "postgresql", "host": "db.example:6543", "database": "d"})
|
||||
assert (colon.host, colon.port) == ("db.example", 6543)
|
||||
@@ -1,174 +0,0 @@
|
||||
"""`DocumentConnector` reading its documents from a SQL source instead of
|
||||
uploaded files: one document per row, read from a column that may hold a
|
||||
PDF (a binary column) or already be plain text, both without a filesystem
|
||||
path in between. Fails if the bridge to `SqlConnector` breaks, or if a
|
||||
plain-text column stops reaching the same field extraction a PDF does.
|
||||
"""
|
||||
import base64
|
||||
|
||||
import pytest
|
||||
from sqlalchemy import create_engine, text
|
||||
|
||||
from extraction.testing import text_pdf
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def client(wire_domain):
|
||||
wire_domain("cacu")
|
||||
|
||||
from webapi import create_app
|
||||
|
||||
app = create_app()
|
||||
app.config.update(TESTING=True)
|
||||
with app.test_client() as test_client:
|
||||
yield test_client
|
||||
|
||||
|
||||
REPORT = text_pdf(
|
||||
[["Expediente: SQL-0001", "Fecha de nacimiento: 12/03/1981", "VPH alto riesgo: POSITIVO"]]
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sqlite_studies_table(tmp_path):
|
||||
"""A source table with one row per study, its
|
||||
report in a binary column, plus a plain-text variant of the same
|
||||
report in another row, both alongside the row's own key column."""
|
||||
db_path = tmp_path / "estudios.db"
|
||||
url = f"sqlite:///{db_path}"
|
||||
engine = create_engine(url)
|
||||
with engine.begin() as conn:
|
||||
conn.execute(text("CREATE TABLE estudios (estudio_id TEXT, reporte BLOB)"))
|
||||
conn.execute(
|
||||
text("INSERT INTO estudios (estudio_id, reporte) VALUES (:id, :reporte)"),
|
||||
{"id": "ROW-1", "reporte": REPORT},
|
||||
)
|
||||
conn.execute(
|
||||
text("INSERT INTO estudios (estudio_id, reporte) VALUES (:id, :reporte)"),
|
||||
{
|
||||
"id": "ROW-2",
|
||||
"reporte": "Expediente: SQL-0002\nFecha de nacimiento: 01/01/1990\nVPH alto riesgo: NEGATIVO",
|
||||
},
|
||||
)
|
||||
return url
|
||||
|
||||
|
||||
def _sql_payload(url: str, **overrides) -> dict:
|
||||
return {"connection_string": url, "table": "estudios", "column": "reporte", "key_column": "estudio_id", **overrides}
|
||||
|
||||
|
||||
def test_a_pdf_column_is_read_like_an_uploaded_pdf(client, sqlite_studies_table):
|
||||
body = client.post(
|
||||
"/imports/sources/document/extract",
|
||||
json={"sql": _sql_payload(sqlite_studies_table), "target": "cacu.CitologiaCervical"},
|
||||
).get_json()
|
||||
[first, second] = body["records"]
|
||||
assert first["key"] == "SQL-0001"
|
||||
assert first["fields"]["cit_vph_resultado"]["value"] == "POSITIVO"
|
||||
assert first["sources"] == [{"document": "ROW-1", "page_numbers": [1]}]
|
||||
|
||||
|
||||
def test_a_plain_text_column_reaches_the_same_field_extraction(client, sqlite_studies_table):
|
||||
"""Fails if a source whose bundle is a plain string (not binary at
|
||||
all) stops producing fields, since a source's column may not always
|
||||
be a PDF (`extraction.readers.TextReader`)."""
|
||||
body = client.post(
|
||||
"/imports/sources/document/extract",
|
||||
json={"sql": _sql_payload(sqlite_studies_table), "target": "cacu.CitologiaCervical"},
|
||||
).get_json()
|
||||
[_, second] = body["records"]
|
||||
assert second["key"] == "SQL-0002"
|
||||
assert second["fields"]["cit_vph_resultado"]["value"] == "NEGATIVO"
|
||||
assert second["sources"] == [{"document": "ROW-2", "page_numbers": [1]}]
|
||||
|
||||
|
||||
def test_sql_sourced_documents_commit_like_uploaded_ones(client, sqlite_studies_table):
|
||||
source = {
|
||||
"source_type": "document",
|
||||
"target": "cacu.CitologiaCervical",
|
||||
"column_mapping": {"pac_id_hospital": "pac_id_hospital", "cit_vph_resultado": "cit_vph_resultado"},
|
||||
"payload": {"sql": _sql_payload(sqlite_studies_table)},
|
||||
"label": "estudios",
|
||||
}
|
||||
result = client.post("/imports/commit", json={"sources": [source]}).get_json()["results"][0]
|
||||
assert result["created"] == 2, result
|
||||
|
||||
from persistance.cacu import citologia_cervical_repository
|
||||
|
||||
rows = {r.pac_id_hospital: r for r in citologia_cervical_repository.list(limit=100) if r.pac_id_hospital.startswith("SQL-")}
|
||||
assert rows["SQL-0001"].cit_vph_resultado == "POSITIVO"
|
||||
assert rows["SQL-0002"].cit_vph_resultado == "NEGATIVO"
|
||||
|
||||
|
||||
def test_column_and_key_column_must_differ(client, sqlite_studies_table):
|
||||
response = client.post(
|
||||
"/imports/sources/document/extract",
|
||||
json={"sql": _sql_payload(sqlite_studies_table, key_column="reporte"), "target": "cacu.CitologiaCervical"},
|
||||
)
|
||||
assert response.status_code == 400 and "key_column" in response.get_json()["error"]
|
||||
|
||||
|
||||
def test_a_missing_column_is_a_bad_request(client, sqlite_studies_table):
|
||||
payload = _sql_payload(sqlite_studies_table)
|
||||
del payload["column"]
|
||||
response = client.post(
|
||||
"/imports/sources/document/extract", json={"sql": payload, "target": "cacu.CitologiaCervical"}
|
||||
)
|
||||
assert response.status_code == 400 and "column" in response.get_json()["error"]
|
||||
|
||||
|
||||
def test_a_caption_outside_the_target_schema_is_committed_through_the_catalog(client, tmp_path, monkeypatch):
|
||||
"""Mixing sources: a field the import schema doesn't name (`Tipo de
|
||||
fijador`) but the project's catalog does still reaches the silver
|
||||
layer through the open-catalog path, alongside the recognized fields
|
||||
`commit_sources` writes as before, when the source asks for it with
|
||||
`catalog_fallback`. Fails if `/imports/commit` stops wiring that second
|
||||
path in, or runs it for a source that didn't ask.
|
||||
Its own table and patient (`SQL-EXTRA-1`), so it doesn't collide with
|
||||
the module's other tests sharing this `client`'s database."""
|
||||
from datetime import date
|
||||
|
||||
from sqlalchemy import create_engine, text as sa_text
|
||||
from sqlmodel import select
|
||||
|
||||
from webapi.orchestration.reference import catalogs as catalogos
|
||||
from core.cacu.paciente.model import Paciente
|
||||
from persistance.cacu import carga_repository, paciente_repository
|
||||
|
||||
monkeypatch.setattr(catalogos, "RAIZ_CATALOGOS", tmp_path)
|
||||
catalog = (
|
||||
'[citologia]\netiqueta = "Citología cervical"\n\n'
|
||||
'[citologia.resultados.tipo_de_fijador]\netiqueta = "Tipo de fijador"\ntipo_valor = "texto"\n'
|
||||
)
|
||||
(tmp_path / "cacu.toml").write_text(catalog, encoding="utf-8")
|
||||
paciente_repository.create(Paciente(pac_id_hospital="SQL-EXTRA-1", pac_fecha_nacimiento=date(1981, 3, 12)))
|
||||
|
||||
db_url = f"sqlite:///{tmp_path / 'estudios_extra.db'}"
|
||||
report = text_pdf([["Expediente: SQL-EXTRA-1", "VPH alto riesgo: POSITIVO", "Tipo de fijador: Formol"]])
|
||||
with create_engine(db_url).begin() as conn:
|
||||
conn.execute(sa_text("CREATE TABLE estudios (estudio_id TEXT, reporte BLOB)"))
|
||||
conn.execute(sa_text("INSERT INTO estudios (estudio_id, reporte) VALUES ('ROW-1', :r)"), {"r": report})
|
||||
|
||||
source = {
|
||||
"source_type": "document",
|
||||
"target": "cacu.CitologiaCervical",
|
||||
"column_mapping": {"pac_id_hospital": "pac_id_hospital", "cit_vph_resultado": "cit_vph_resultado"},
|
||||
"payload": {"sql": _sql_payload(db_url), "estudio_id": "citologia"},
|
||||
"label": "estudios_extra",
|
||||
}
|
||||
body = client.post("/imports/commit", json={"sources": [source]}).get_json()
|
||||
assert body["results"][0]["created"] == 1, body
|
||||
assert not [r for r in body.get("catalog_fallback", []) if r["label"] == "estudios_extra"]
|
||||
|
||||
body = client.post("/imports/commit", json={"sources": [{**source, "catalog_fallback": True}], "on_conflict": "upsert"}).get_json()
|
||||
[fallback] = [r for r in body["catalog_fallback"] if r["label"] == "estudios_extra"]
|
||||
assert (fallback["records_written"], fallback["fields_matched"], fallback["fields_minted"]) == (1, 1, 0)
|
||||
assert (tmp_path / "cacu.toml").read_text(encoding="utf-8") == catalog
|
||||
|
||||
with carga_repository.open_session() as sesion:
|
||||
[written] = list(
|
||||
sesion.exec(select(carga_repository.observacion).where(carga_repository.observacion.pac_id.in_(
|
||||
select(Paciente.pac_id).where(Paciente.pac_id_hospital == "SQL-EXTRA-1")
|
||||
)))
|
||||
)
|
||||
assert written.resultado_id == "citologia.tipo_de_fijador" and written.valor_texto == "Formol"
|
||||
@@ -1,178 +0,0 @@
|
||||
"""What this module covers: catalog results read from a staging row's text (`silver.extracted`). The catalog's
|
||||
`etiquetas_fuente` and `alias` checked when it's read; a report's text, a PDF's text layer and a note turned into
|
||||
codes, numbers and their sources; a spelling the catalog doesn't know kept as text and turned into a code by a
|
||||
catalog change alone; and CaMa's load putting them in silver and dbt's timeline.
|
||||
|
||||
Fixtures: `catalogo_en`, a copy of CaMa's catalog in `tmp_path` that the catalog functions read instead of Core's;
|
||||
`cargada`, the CaMa fixture database (`staging/cama.py`: H-003's texts and pathology PDF, H-101's unknown density)
|
||||
loaded, with dbt's views when `DBT_MANIFEST` is set.
|
||||
"""
|
||||
|
||||
import os
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
from sqlalchemy import text
|
||||
from staging.cama import INFORME_DE_PATOLOGIA, pdf_de
|
||||
from webapi.orchestration.reference import catalogs
|
||||
from webapi.orchestration.reference.catalogs import CatalogoInvalido, catalogo_desde_toml, ruta_de_catalogo
|
||||
from webapi.orchestration.silver import cama
|
||||
from webapi.orchestration.silver.extracted import DesdeTexto
|
||||
from webapi.orchestration.tables import tablas_de
|
||||
|
||||
DENSIDAD = """
|
||||
[mastografia]
|
||||
etiqueta = "Mastografía"
|
||||
|
||||
[mastografia.resultados.densidad]
|
||||
etiqueta = "Densidad"
|
||||
tipo_valor = "codigo"
|
||||
etiquetas_fuente = ["Densidad mamaria"]
|
||||
valores = [
|
||||
{ valor = "C", etiqueta = "Heterogéneamente densa", alias = ["Tipo C"] },
|
||||
{ valor = "D", etiqueta = "Extremadamente densa", alias = ["Tipo D"] },
|
||||
]
|
||||
"""
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def catalogo_en(tmp_path, monkeypatch):
|
||||
"""Writes a catalog for `cama` in `tmp_path` and points the catalog functions at it. Returns a writer."""
|
||||
ruta = tmp_path / "cama.toml"
|
||||
monkeypatch.setattr(catalogs, "ruta_de_catalogo", lambda proyecto: ruta)
|
||||
|
||||
def escribir(contenido: str):
|
||||
ruta.write_text(contenido, encoding="utf-8")
|
||||
return ruta
|
||||
|
||||
return escribir
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def proyecto():
|
||||
return "cama"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cargada(base):
|
||||
pasos = ("catalogs", "load", "event_models") if os.environ.get("DBT_MANIFEST") else ("catalogs", "load")
|
||||
base.run(*pasos)
|
||||
return base
|
||||
|
||||
|
||||
def observaciones(base, resultado_prefijo: str) -> dict[str, tuple]:
|
||||
"""`resultado_id` -> (valor_id, valor_numerico, valor_fuente) of the observations whose result starts so."""
|
||||
with base.motor.connect() as con:
|
||||
filas = con.execute(text(
|
||||
"SELECT resultado_id, valor_id, valor_numerico, valor_fuente FROM observacion_clinica "
|
||||
"WHERE resultado_id LIKE :p AND (valor_id IS NOT NULL OR valor_numerico IS NOT NULL OR valor_fuente IS NOT NULL)"
|
||||
), {"p": resultado_prefijo + "%"}).all()
|
||||
return {f.resultado_id: (f.valor_id, f.valor_numerico, f.valor_fuente) for f in filas}
|
||||
|
||||
|
||||
# --- the catalog ---
|
||||
|
||||
def test_the_catalog_lists_cama_s_extractable_results_as_provisional():
|
||||
"""Pins down: every CaMa result with captions is extractable and marked provisional, and the catalog still
|
||||
loads with them. Fails if `resultados_extraibles` drops a result or the new keys break `catalogo_desde_toml`."""
|
||||
extraibles = catalogs.resultados_extraibles("cama")
|
||||
assert set(extraibles) >= {"mastografia.densidad", "biopsia.her2", "nota_medica.estadio_clinico"}
|
||||
assert all(e.provisional for e in extraibles.values())
|
||||
catalogo = catalogo_desde_toml(ruta_de_catalogo("cama"), tablas=tablas_de("cama"))
|
||||
assert {r.resultado_id for r in catalogo.resultados} >= set(extraibles)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cambio, error", [
|
||||
(('alias = ["Tipo D"]', 'alias = ["Tipo C"]'), "se escribe igual"),
|
||||
(('etiquetas_fuente = ["Densidad mamaria"]', 'etiquetas_fuente = []'), "lista de textos"),
|
||||
(('etiquetas_fuente = ["Densidad mamaria"]\n', ''), "solo sirven con etiquetas_fuente"),
|
||||
])
|
||||
def test_an_ambiguous_or_incomplete_mapping_is_rejected(catalogo_en, cambio, error):
|
||||
"""Pins down: one spelling on two values, empty captions, or aliases without captions stop the catalog from
|
||||
loading. Fails if a check is dropped and an alias could turn into either of two codes."""
|
||||
ruta = catalogo_en(DENSIDAD.replace(*cambio))
|
||||
with pytest.raises(CatalogoInvalido, match=error):
|
||||
catalogo_desde_toml(ruta, tablas=tablas_de("cama"))
|
||||
|
||||
|
||||
# --- reading text ---
|
||||
|
||||
def test_a_report_s_text_gives_codes_with_their_spelling_and_numbers():
|
||||
"""Pins down: a caption followed by a known spelling gives its code and that spelling as source; a number
|
||||
after its caption gives the number. Fails if the catalog's aliases stop reaching Extraction's field specs."""
|
||||
leido = cama.DE_LA_INTERPRETACION.leer(SimpleNamespace(
|
||||
mast_interpretacion="Densidad mamaria: heterogéneamente densas (C).\nTamaño de la lesión: 14 mm."))
|
||||
assert leido == {"mastografia.densidad": ("C", "heterogéneamente densas"), "mastografia.tamano_lesion_mm": (14.0, None)}
|
||||
|
||||
|
||||
def test_an_unknown_spelling_is_kept_as_its_source_without_a_code():
|
||||
"""Pins down: what follows a caption that matches no alias is kept as source text, with no code. Fails if it's
|
||||
dropped (it couldn't be found and mapped later) or forced into a code."""
|
||||
leido = cama.DE_LA_INTERPRETACION.leer(SimpleNamespace(mast_interpretacion="Densidad mamaria: tipo E"))
|
||||
assert leido["mastografia.densidad"] == (None, "tipo E")
|
||||
|
||||
|
||||
def test_a_stage_is_found_in_a_note_without_a_caption():
|
||||
"""Pins down: a result marked `buscar_en_texto` is found as a mention in narrative text. Fails if the flag
|
||||
stops reaching `scan_free_text`."""
|
||||
leido = cama.DE_LA_NOTA.leer(SimpleNamespace(
|
||||
nm_diagnostico_texto="Carcinoma de mama izquierda, estadio clínico IIA (T2N0M0)", nm_pronostico=None))
|
||||
assert leido["nota_medica.estadio_clinico"] == ("EIIA", "estadio clínico IIA")
|
||||
|
||||
|
||||
def test_a_pathology_pdf_s_text_layer_gives_its_results():
|
||||
"""Pins down: a PDF's text layer is read without OCR and every result on it comes out. Fails if bytes stop
|
||||
going through the PDF reader, or a receptor's percentage stops sharing its captions with the receptor."""
|
||||
leido = cama.DEL_REPORTE_DE_PATOLOGIA.leer(SimpleNamespace(bx_pdf_blob=pdf_de(INFORME_DE_PATOLOGIA[1])))
|
||||
assert {r: v for r, (v, _) in leido.items()} == {
|
||||
"biopsia.tipo_histologico": "DUCTAL_INFILTRANTE", "biopsia.grado_nottingham": "G2",
|
||||
"biopsia.receptor_estrogeno": "POSITIVO", "biopsia.receptor_estrogeno_pct": 90.0,
|
||||
"biopsia.receptor_progesterona": "NEGATIVO", "biopsia.receptor_progesterona_pct": 0.0,
|
||||
"biopsia.her2": "H3", "biopsia.ki67_pct": 25.0,
|
||||
}
|
||||
|
||||
|
||||
def test_no_text_gives_no_values():
|
||||
"""Pins down: a row without text (or a PDF that can't be read) gives every result empty. Fails if an empty
|
||||
text or broken bytes raise during a load."""
|
||||
assert set(cama.DE_LA_NOTA.leer(SimpleNamespace(nm_diagnostico_texto=None, nm_pronostico=None)).values()) == {(None, None)}
|
||||
assert set(cama.DEL_REPORTE_DE_PATOLOGIA.leer(SimpleNamespace(bx_pdf_blob=b"not a pdf")).values()) == {(None, None)}
|
||||
|
||||
|
||||
def test_adding_an_alias_maps_the_same_text_on_the_next_read(catalogo_en):
|
||||
"""Pins down: an unknown spelling becomes a code by adding it to the catalog, with nothing else changed. Fails
|
||||
if the mapping is cached across catalog reads or lives anywhere but the catalog."""
|
||||
fila = SimpleNamespace(mast_interpretacion="Densidad mamaria: tipo E")
|
||||
catalogo_en(DENSIDAD)
|
||||
antes = DesdeTexto("cama", ("mastografia.densidad",), texto=lambda f: f.mast_interpretacion).leer(fila)
|
||||
catalogo_en(DENSIDAD.replace('alias = ["Tipo D"]', 'alias = ["Tipo D", "Tipo E"]'))
|
||||
despues = DesdeTexto("cama", ("mastografia.densidad",), texto=lambda f: f.mast_interpretacion).leer(fila)
|
||||
assert antes["mastografia.densidad"] == (None, "tipo E")
|
||||
assert despues["mastografia.densidad"] == ("D", "tipo E")
|
||||
|
||||
|
||||
# --- the load ---
|
||||
|
||||
def test_the_load_puts_the_extracted_results_in_silver(cargada):
|
||||
"""Pins down: CaMa's load writes the results read from the interpretation, the pathology PDF and the note, and
|
||||
an unknown spelling as an out-of-catalog source. Fails if `cama.DESDE_STAGING` stops wiring a `DesdeTexto`."""
|
||||
with cargada.motor.connect() as con:
|
||||
densidades = sorted(con.execute(text(
|
||||
"SELECT coalesce(valor_id, '?') || ':' || valor_fuente FROM observacion_clinica "
|
||||
"WHERE resultado_id = 'mastografia.densidad' AND valor_fuente IS NOT NULL")).scalars())
|
||||
assert densidades == ["?:tipo E", "C:heterogéneamente densas"]
|
||||
assert observaciones(cargada, "biopsia.her2") == {"biopsia.her2": ("H3", None, "3+")}
|
||||
assert observaciones(cargada, "biopsia.ki67_pct") == {"biopsia.ki67_pct": (None, 25.0, None)}
|
||||
assert observaciones(cargada, "nota_medica.estadio_clinico") == {
|
||||
"nota_medica.estadio_clinico": ("EIIA", None, "estadio clínico IIA")}
|
||||
|
||||
|
||||
def test_the_timeline_carries_the_extracted_results(cargada):
|
||||
"""Pins down: the timeline declares the new results, so H-003's stage, receptors and density are rows of it.
|
||||
Fails if a source line is missing from `cama_linea_de_tiempo.yml`."""
|
||||
if not os.environ.get("DBT_MANIFEST"):
|
||||
pytest.skip("DBT_MANIFEST isn't set: `dbt compile` in Transformation writes it")
|
||||
filas = cargada.ctx.repos.silver.timeline.read()
|
||||
valores = {(f["tipo"], f["valor_codigo"] or f["valor_numerico"]) for f in filas}
|
||||
assert {("estadio_clinico", "EIIA"), ("her2", "H3"), ("receptor_estrogeno_pct", 90.0),
|
||||
("densidad_mamaria", "C"), ("densidad_mamaria", "tipo E")} <= valores
|
||||
@@ -45,7 +45,7 @@ def test_every_measure_and_one_report_of_each_are_valid_fhir(domain_client):
|
||||
with strata included. Fails if the serialization of a scoring, a stratifier or a population breaks FHIR's shape."""
|
||||
domain, client = domain_client
|
||||
measures = valid(client.get(f"/{domain}/fhir/Measure").get_json())
|
||||
assert measures["total"] == {"cacu": 7, "cama": 8}[domain]
|
||||
assert measures["total"] == 7
|
||||
for item in measures["entry"]:
|
||||
response = client.get(f"/{domain}/fhir/Measure/{item['resource']['id']}/$evaluate-measure?periodo=2025-S1")
|
||||
assert response.status_code in (200, 409), response.get_json()
|
||||
|
||||
@@ -167,8 +167,9 @@ def test_the_follow_up_filters(client, query, n):
|
||||
|
||||
def test_includes_bring_the_patient_its_steps_and_its_study_eeg(client):
|
||||
"""Pins down: `_include` adds each child's Patient (birth date to the month), CarePlan with its steps, M-CHAT,
|
||||
confirmed diagnosis and study EEG as a DiagnosticReport with its quality observations; no metric observation while
|
||||
the alterations are hidden. Fails if an included resource drops out or the alterations leak."""
|
||||
ADOS-2 (the list shows its CSS and module), confirmed diagnosis and study EEG as a DiagnosticReport with its quality
|
||||
observations; no metric observation while the alterations are hidden. Fails if an included resource drops out or
|
||||
the alterations leak."""
|
||||
body = get(client, "/tea/fhir/EpisodeOfCare?date=le2025-12-31&status=finished&_include=*")
|
||||
included = resources(body, mode="include")
|
||||
kinds = {r["resourceType"] for r in included}
|
||||
@@ -177,6 +178,8 @@ def test_includes_bring_the_patient_its_steps_and_its_study_eeg(client):
|
||||
reports = [r for r in included if r["resourceType"] == "DiagnosticReport"]
|
||||
assert {r["conclusionCode"][0]["coding"][0]["code"] for r in reports} == {"BUENO"}
|
||||
assert all(len(r["result"]) == 5 for r in reports)
|
||||
ados2 = [r for r in included if r["resourceType"] == "Observation" and r["code"]["coding"][0]["code"] == "ados2"]
|
||||
assert ados2 and all(any(c["code"]["coding"][0]["code"] == "ados2.css" for c in r["component"]) for r in ados2)
|
||||
|
||||
|
||||
def test_the_alteration_filter_waits_for_the_validation(client, monkeypatch):
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
"""Endpoint tests for `/governance/*`: model versions and their promotion, downloading what a version's run stored,
|
||||
notebooks run on a cohort build, and the OCR review queue.
|
||||
|
||||
Fixtures: `client`, the app over a CaCu and a governance database with one patient and a SQLite-backed MLflow in a
|
||||
temporary folder (module scope); `notebooks`, a cohort build's file under a `COHORTS_DIR`, the Jupyter renderer and
|
||||
notebooks run in the request instead of in the background. `_trained` registers a version the way training does: a run
|
||||
that records each routine and saves its model.
|
||||
"""
|
||||
import io
|
||||
import json
|
||||
"""Endpoint tests for `/governance/*`."""
|
||||
import os
|
||||
import tempfile
|
||||
from datetime import date
|
||||
|
||||
import mlflow.pyfunc
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -91,70 +81,42 @@ def _register(client, tag: str, *, scenario: str = "tamizaje", **extra) -> dict:
|
||||
return response.get_json()
|
||||
|
||||
|
||||
class Echo(mlflow.pyfunc.PythonModel):
|
||||
def predict(self, context, model_input, params=None):
|
||||
return model_input
|
||||
|
||||
|
||||
def _trained(tag: str, scenario: str, **reports) -> str:
|
||||
"""A PROD version as training leaves it: every routine recorded and the model saved."""
|
||||
from models.io.registry import registry
|
||||
from models.io.tracking import ROUTINE_KINDS, TrainingRun
|
||||
|
||||
run = TrainingRun(domain="cacu", scenario=scenario, environment="PROD", cohorte_armado_id=_armado(tag))
|
||||
for kind in ROUTINE_KINDS:
|
||||
run.log_routine(kind, {"method": "prueba"})
|
||||
run.log_model(Echo())
|
||||
return registry.register_run(run.finish(metrics={"auc": 0.8}), **reports)
|
||||
|
||||
|
||||
REPORTS = {"technical_validation_report_uri": "docs/tecnica.pdf", "clinical_validation_report_uri": "docs/clinica.pdf",
|
||||
"interpretability_report_uri": "docs/interpretabilidad.html"}
|
||||
def _upload(client, domain: str, scenario: str, version: str, kind: str = "BALANCE_CLASES", name: str = "smote.json", data: bytes = b"{}"):
|
||||
files = {"file": (__import__("io").BytesIO(data), name), "kind": kind}
|
||||
return client.post(f"/governance/model-versions/{domain}/{scenario}/{version}/artifacts", data=files, content_type="multipart/form-data")
|
||||
|
||||
|
||||
def test_model_version_lifecycle_over_http(client):
|
||||
"""A version registered over HTTP carries no routine records or model, so it can't be promoted; trained ones can,
|
||||
and promoting the second retires the first. Fails if the ML-01a/ML-01b checks start trusting what's declared
|
||||
over the API, or promotion stops retiring the previous version."""
|
||||
declared = _register(client, "v0", scenario="lifecycle")
|
||||
checks = client.get(f"/governance/model-versions/cacu/lifecycle/{declared['version']}/checks").get_json()
|
||||
first = _register(client, "v1", scenario="lifecycle")
|
||||
assert first["status"] == "candidata"
|
||||
|
||||
checks = client.get(f"/governance/model-versions/cacu/lifecycle/{first['version']}/checks").get_json()
|
||||
assert checks["ready"] is False
|
||||
assert [c["code"] for c in checks["checks"] if not c["passed"]] == ["ML-01a", "ML-01b"]
|
||||
blocked = client.post(f"/governance/model-versions/cacu/lifecycle/{declared['version']}/promote")
|
||||
assert [c["code"] for c in checks["checks"] if not c["passed"]] == ["ML-01b"]
|
||||
blocked = client.post(f"/governance/model-versions/cacu/lifecycle/{first['version']}/promote")
|
||||
assert blocked.status_code == 409 and any(not c["passed"] for c in blocked.get_json()["checks"])
|
||||
|
||||
first = _trained("v1", "lifecycle", **REPORTS)
|
||||
assert client.post(f"/governance/model-versions/cacu/lifecycle/{first}/promote").get_json()["status"] == "produccion"
|
||||
second = _trained("v2", "lifecycle", **REPORTS)
|
||||
client.post(f"/governance/model-versions/cacu/lifecycle/{second}/promote")
|
||||
uploaded = _upload(client, "cacu", "lifecycle", first["version"])
|
||||
assert uploaded.status_code == 201
|
||||
assert client.post(f"/governance/model-versions/cacu/lifecycle/{first['version']}/promote").get_json()["status"] == "produccion"
|
||||
|
||||
second = _register(client, "v2", scenario="lifecycle", metrics={"auc": 0.86})
|
||||
_upload(client, "cacu", "lifecycle", second["version"])
|
||||
client.post(f"/governance/model-versions/cacu/lifecycle/{second['version']}/promote")
|
||||
listed = client.get("/governance/model-versions", query_string={"domain": "cacu", "scenario": "lifecycle"}).get_json()
|
||||
statuses = {v["version"]: v["status"] for v in listed["model_versions"]}
|
||||
assert statuses[first] == "retirada" and statuses[second] == "produccion"
|
||||
assert statuses[first["version"]] == "retirada" and statuses[second["version"]] == "produccion"
|
||||
|
||||
lineage = client.get(f"/governance/model-versions/cacu/lifecycle/{second}/lineage").get_json()
|
||||
lineage = client.get(f"/governance/model-versions/cacu/lifecycle/{second['version']}/lineage").get_json()
|
||||
assert lineage["cohorte_armado"]["huella"] == "huella-v2"
|
||||
assert lineage["cohorte_armado"]["datos_as_of"] == "2025-12-31"
|
||||
assert lineage["cohorte_exclusiones"] == [{"orden": 1, "paso": "candidatas", "n": 5}]
|
||||
assert lineage["routines"]["MUESTREO"] == {"method": "prueba"}
|
||||
assert lineage["artifacts"]
|
||||
|
||||
retired = client.post(f"/governance/model-versions/cacu/lifecycle/{second}/retire").get_json()
|
||||
retired = client.post(f"/governance/model-versions/cacu/lifecycle/{second['version']}/retire").get_json()
|
||||
assert retired["status"] == "retirada"
|
||||
|
||||
|
||||
def test_a_versions_files_download(client):
|
||||
"""ML-01b: a routine record downloads as itself, the model folder as a zip, and a path the run doesn't hold is 404.
|
||||
Fails if the endpoint stops going through `registry.artifact`."""
|
||||
version = _trained("v-desc", "descargas")
|
||||
base = f"/governance/model-versions/cacu/descargas/{version}/artifacts"
|
||||
record = client.get(f"{base}/rutinas/MUESTREO.json")
|
||||
assert record.status_code == 200 and record.get_json(force=True) == {"method": "prueba"}
|
||||
assert "attachment" in record.headers["Content-Disposition"]
|
||||
model = client.get(f"{base}/model")
|
||||
assert model.status_code == 200 and 'model.zip' in model.headers["Content-Disposition"]
|
||||
assert client.get(f"{base}/../../mlflow.db").status_code == 404
|
||||
assert client.get(f"{base}/rutinas/OTRO.json").status_code == 404
|
||||
|
||||
|
||||
def test_reports_can_be_attached_later(client):
|
||||
version = _register(client, "v3", scenario="reportes", clinical_validation_report_uri=None)
|
||||
response = client.patch(
|
||||
@@ -165,8 +127,11 @@ def test_reports_can_be_attached_later(client):
|
||||
assert client.patch(f"/governance/model-versions/cacu/reportes/{version['version']}/reports", json={"metrics": "{}"}).status_code == 400
|
||||
|
||||
|
||||
def test_bad_registrations_are_rejected(client):
|
||||
def test_bad_registrations_and_uploads_are_rejected(client):
|
||||
assert client.post("/governance/model-versions", json={"domain": "cacu"}).status_code == 400
|
||||
dev = client.post("/governance/model-versions", json={"domain": "cacu", "scenario": "malas-subidas", "environment": "DEV"}).get_json()
|
||||
assert _upload(client, "cacu", "malas-subidas", dev["version"], kind="NOPE").status_code == 400
|
||||
assert _upload(client, "cacu", "malas-subidas", dev["version"], kind="ONNX_CHECKPOINT", name="m.onnx", data=b"junk").status_code == 400
|
||||
|
||||
|
||||
def test_model_version_not_found(client):
|
||||
@@ -276,88 +241,3 @@ def test_ocr_correct_rejects_unknown_column(client):
|
||||
|
||||
def test_ocr_blob_not_found_for_unknown_row(client):
|
||||
assert client.get("/governance/ocr/cacu/citologia_cervical/999999/blob").status_code == 404
|
||||
|
||||
|
||||
def _notebook(*sources: str) -> bytes:
|
||||
cells = [{"cell_type": "code", "metadata": {}, "execution_count": None, "outputs": [], "source": s} for s in sources]
|
||||
return json.dumps({"cells": cells, "metadata": {}, "nbformat": 4, "nbformat_minor": 5}).encode()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def notebooks(tmp_path, monkeypatch):
|
||||
"""Build 4 of dbt's `cacu/cohorte_vigilancia` under `COHORTS_DIR`, the Jupyter renderer, and `submit` running the
|
||||
notebook before the request answers."""
|
||||
import pandas as pd
|
||||
import pyarrow as pa
|
||||
import pyarrow.parquet as pq
|
||||
from datetime import datetime, timezone
|
||||
from models.io.contracts import COHORT_SCHEMA
|
||||
from webapi.blueprints import governance
|
||||
|
||||
row = {"pac_id": 1, "fecha_indice": date(2025, 1, 1), "fecha": date(2025, 1, 1),
|
||||
"conocida_en": datetime(2026, 1, 1, tzinfo=timezone.utc), "clase": "procedimiento", "tipo": "citologia",
|
||||
"codigo": "citologia", "valor_codigo": None, "valor_numerico": None, "fuente_tabla": "citologiacervical",
|
||||
"fuente_id": "S1"}
|
||||
table = pa.Table.from_pandas(pd.DataFrame([row], columns=COHORT_SCHEMA.names), schema=COHORT_SCHEMA, preserve_index=False)
|
||||
path = tmp_path / "cohorts" / "cacu" / "cohorte_vigilancia" / "dbt" / "4.parquet"
|
||||
path.parent.mkdir(parents=True)
|
||||
metadata = {"url": "cacu/cohorte_vigilancia", "producer": "dbt", "build": "4", "datos_as_of": "2025-12-31",
|
||||
"n_members": "1"}
|
||||
pq.write_table(table.replace_schema_metadata(metadata), path)
|
||||
monkeypatch.setenv("COHORTS_DIR", str(tmp_path / "cohorts"))
|
||||
monkeypatch.setenv("NOTEBOOK_RENDERER", "jupyter")
|
||||
monkeypatch.setenv("MLFLOW_ARTIFACT_ROOT", str(tmp_path / "artefactos"))
|
||||
monkeypatch.setattr(governance, "submit", lambda job, *args: job(*args))
|
||||
|
||||
|
||||
def _run(client, notebook: bytes, *, scenario="exploracion", **fields):
|
||||
form = {"file": (io.BytesIO(notebook), "analisis.ipynb"), "domain": "cacu", "scenario": scenario,
|
||||
"url": "cacu/cohorte_vigilancia", "source": "dbt", "build": "4", **fields}
|
||||
return client.post("/governance/experiments", data=form, content_type="multipart/form-data")
|
||||
|
||||
|
||||
def test_the_builds_a_notebook_can_run_on_are_listed(client, notebooks):
|
||||
"""Fails if `/cohort-files` stops listing exported builds from their files."""
|
||||
builds = client.get("/governance/cohort-files", query_string={"domain": "cacu"}).get_json()["builds"]
|
||||
assert builds == [{"url": "cacu/cohorte_vigilancia", "source": "dbt", "build": 4, "datos_as_of": "2025-12-31",
|
||||
"n_members": "1"}]
|
||||
|
||||
|
||||
def test_an_uploaded_notebook_runs_on_the_build_and_its_page_is_sandboxed(client, notebooks):
|
||||
"""The upload answers 202 with the run; the notebook reads the build through `models.notebook`; its page is served
|
||||
with a sandbox policy and its files download. Fails if the endpoint stops handing the build to the run or serves
|
||||
the notebook's page as part of the app's origin."""
|
||||
started = _run(client, _notebook("from models.notebook import experiment\n"
|
||||
"print('miembros', experiment().cohort().pac_id.nunique())"))
|
||||
assert started.status_code == 202, started.get_json()
|
||||
run_id = started.get_json()["run_id"]
|
||||
run = client.get(f"/governance/experiments/{run_id}").get_json()
|
||||
assert run["status"] == "terminado" and run["cohort"]["build"] == "4" and run["notebook"] == "analisis"
|
||||
page = client.get(f"/governance/experiments/{run_id}/page")
|
||||
assert "miembros 1" in page.get_data(as_text=True) and "sandbox" in page.headers["Content-Security-Policy"]
|
||||
source = client.get(f"/governance/experiments/{run_id}/artifacts/notebook/analisis.ipynb")
|
||||
assert source.status_code == 200 and "attachment" in source.headers["Content-Disposition"]
|
||||
listed = client.get("/governance/experiments", query_string={"domain": "cacu", "scenario": "exploracion"}).get_json()
|
||||
assert run_id in [r["run_id"] for r in listed["experiments"]]
|
||||
|
||||
|
||||
def test_a_failing_notebook_reports_its_error(client, notebooks):
|
||||
"""Fails if a notebook whose cell raises is reported as finished or without its error."""
|
||||
run_id = _run(client, _notebook("raise ValueError('sin datos')")).get_json()["run_id"]
|
||||
run = client.get(f"/governance/experiments/{run_id}").get_json()
|
||||
assert run["status"] == "fallido" and "sin datos" in run["error"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("fields, notebook", [
|
||||
({"build": "99"}, None),
|
||||
({"url": "tea/otra"}, None),
|
||||
({"build": "x"}, None),
|
||||
({"version": "999"}, None),
|
||||
({}, b"no es json"),
|
||||
({}, b'{"cells": [], "nbformat": 3}'),
|
||||
])
|
||||
def test_bad_notebook_runs_are_refused(client, notebooks, fields, notebook):
|
||||
"""A build that isn't exported, a cohort of another domain, an unknown version, or a file that isn't a notebook is
|
||||
refused before anything runs. Fails if `/experiments` stops checking any of them."""
|
||||
response = _run(client, notebook or _notebook("1"), **fields)
|
||||
assert response.status_code in (400, 404)
|
||||
|
||||
@@ -1,284 +0,0 @@
|
||||
"""Derived fields and document columns inside an ordinary mapping: target
|
||||
fields computed from several source columns (joined, split, picked, read
|
||||
out of a longer text or translated), files kept in a column of a CSV or
|
||||
SQL source read for the fields the plain mapping left empty, and the
|
||||
captions nothing used, as the import report lists them.
|
||||
|
||||
Fixtures: `client` (the app wired to a fresh CaCu database). Sources are
|
||||
built inline: CSV text through `_csv`, SQLite tables under `tmp_path`.
|
||||
"""
|
||||
import base64
|
||||
|
||||
import pytest
|
||||
from sqlalchemy import create_engine, text
|
||||
|
||||
from extraction.testing import text_pdf
|
||||
from webapi.imports.connectors.errors import ConnectorError
|
||||
from webapi.imports.mapping.derived import build_derivation, parse_derived
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def client(wire_domain):
|
||||
wire_domain("cacu")
|
||||
|
||||
from webapi import create_app
|
||||
|
||||
app = create_app()
|
||||
app.config.update(TESTING=True)
|
||||
with app.test_client() as test_client:
|
||||
yield test_client
|
||||
|
||||
|
||||
def _b64(raw: bytes) -> str:
|
||||
return base64.b64encode(raw).decode()
|
||||
|
||||
|
||||
def _csv(content: str, **source) -> dict:
|
||||
return {"source_type": "csv", "target": "cacu.Paciente", "payload": {"file_base64": _b64(content.encode())}, **source}
|
||||
|
||||
|
||||
ROW = {"nombre": " ana maría ", "paterno": "Pérez", "materno": "", "completo": "Ana María Pérez López", "dir": "Calle 5, CP 64000"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"rule,expected",
|
||||
[
|
||||
({"op": "concat", "columns": ["nombre", "paterno", "materno"]}, "ana maría Pérez"),
|
||||
({"op": "concat", "columns": ["paterno", "nombre"], "separator": ", ", "case": "upper"}, "PÉREZ, ANA MARÍA"),
|
||||
({"op": "template", "template": "{paterno} {materno} / {nombre}"}, "Pérez / ana maría"),
|
||||
({"op": "split", "column": "completo", "start": 0, "stop": -2}, "Ana María"),
|
||||
({"op": "split", "column": "completo", "start": -2, "stop": -1}, "Pérez"),
|
||||
({"op": "coalesce", "columns": ["materno", "paterno"]}, "Pérez"),
|
||||
({"op": "extract", "column": "dir", "pattern": r"CP\s*(\d{5})", "group": 1}, "64000"),
|
||||
({"op": "map", "column": "paterno", "values": {"pérez": "P"}}, "P"),
|
||||
({"op": "map", "column": "nombre", "values": {"x": "y"}, "keep_unmatched": False}, None),
|
||||
({"op": "column", "column": "paterno"}, "Pérez"),
|
||||
],
|
||||
)
|
||||
def test_each_operation_computes_its_value(rule, expected):
|
||||
"""Pins what every registered operation returns for one row, blanks
|
||||
skipped and spaces collapsed. Fails if an operation's semantics change
|
||||
(`start`/`stop` counting, separators, `case`, unmatched values)."""
|
||||
assert build_derivation(rule).apply(ROW) == expected
|
||||
|
||||
|
||||
def test_rules_are_checked_before_any_row_is_read():
|
||||
"""Unknown operations, missing parameters, bad patterns and fields the
|
||||
target lacks are refused up front. Fails if `parse_derived` lets a
|
||||
malformed rule through to fail row by row."""
|
||||
for bad in ({"op": "nope"}, {"op": "concat"}, {"op": "extract", "column": "a", "pattern": "("}, {"op": "split", "column": "a", "case": "x"}):
|
||||
with pytest.raises(ConnectorError):
|
||||
build_derivation(bad)
|
||||
with pytest.raises(ConnectorError):
|
||||
parse_derived({"no_such_field": "a"}, {"pac_sexo"})
|
||||
|
||||
|
||||
def test_short_forms_name_a_column_or_join_several():
|
||||
"""A rule given as a column name reads it; a list of columns joins them.
|
||||
Fails if `rule_from` stops accepting the short forms."""
|
||||
rules = parse_derived({"a": "paterno", "b": ["nombre", "paterno"]}, {"a", "b"})
|
||||
assert rules["a"].apply(ROW) == "Pérez" and rules["b"].apply(ROW) == "ana maría Pérez"
|
||||
|
||||
|
||||
def test_derived_fields_reach_validation_and_the_mapped_preview(client):
|
||||
"""A source whose id is split over two columns and whose sex comes
|
||||
coded validates cleanly once `derived` joins and translates them, and
|
||||
`/imports/mapped-preview` shows the rows as they would be written.
|
||||
Fails if `ImportSource.rows` stops applying `derived`."""
|
||||
source = _csv(
|
||||
"serie,numero,sx,cp,nac\nA,001,1,64000,1980-01-02\nB,002,2,64100,1975-03-04\n",
|
||||
column_mapping={"cp": "pac_codigo_postal", "nac": "pac_fecha_nacimiento"},
|
||||
derived={
|
||||
"pac_id_hospital": {"op": "concat", "columns": ["serie", "numero"], "separator": "-"},
|
||||
"pac_sexo": {"op": "map", "column": "sx", "values": {"1": "F", "2": "M"}},
|
||||
},
|
||||
)
|
||||
rows = client.post("/imports/mapped-preview", json={"source": source}).get_json()["rows"]
|
||||
assert [(r["pac_id_hospital"], r["pac_sexo"]) for r in rows] == [("A-001", "F"), ("B-002", "M")]
|
||||
result = client.post("/imports/validate", json={"source": source}).get_json()
|
||||
assert result["error_count"] == 0, result["errors"]
|
||||
|
||||
|
||||
def test_a_field_cannot_be_both_mapped_and_derived(client):
|
||||
"""Fails if a field fed twice (mapping and `derived`) stops being refused."""
|
||||
source = _csv("a\n1\n", column_mapping={"a": "pac_id_hospital"}, derived={"pac_id_hospital": "a"})
|
||||
assert client.post("/imports/validate", json={"source": source}).status_code == 400
|
||||
|
||||
|
||||
def test_the_operations_are_listed_for_clients(client):
|
||||
"""`/imports/derivations` lists every operation with its parameters, so
|
||||
the import screen builds its forms from the server. Fails if an
|
||||
operation is registered without being described."""
|
||||
body = client.get("/imports/derivations").get_json()
|
||||
ops = {d["op"]: d for d in body["derivations"]}
|
||||
assert {"column", "concat", "template", "split", "coalesce", "extract", "map"} <= set(ops)
|
||||
assert [p["name"] for p in ops["split"]["params"]] == ["column", "separator", "start", "stop"]
|
||||
assert body["cases"] == ["upper", "lower", "title"]
|
||||
|
||||
|
||||
def _documents_table(tmp_path) -> str:
|
||||
"""Two rows of one order of patient P-7, one with its report as a PDF
|
||||
and one as base64 text, and a third row with no document."""
|
||||
url = f"sqlite:///{tmp_path / 'docs.db'}"
|
||||
report = text_pdf([["VPH alto riesgo: POSITIVO"]])
|
||||
with create_engine(url).begin() as conn:
|
||||
conn.execute(text("CREATE TABLE t (pid TEXT, orden INTEGER, archivo BLOB, texto TEXT)"))
|
||||
conn.execute(text("INSERT INTO t VALUES ('P-7', 5, :f, NULL)"), {"f": report})
|
||||
conn.execute(
|
||||
text("INSERT INTO t VALUES ('P-7', 5, NULL, :t)"), {"t": _b64(text_pdf([["Genotipo 16: DETECTADO"]]))}
|
||||
)
|
||||
conn.execute(text("INSERT INTO t VALUES ('P-8', 6, NULL, NULL)"))
|
||||
return url
|
||||
|
||||
|
||||
def _sql_source(url: str, **extra) -> dict:
|
||||
return {
|
||||
"source_type": "sql",
|
||||
"target": "cacu.CitologiaCervical",
|
||||
"payload": {"connection_string": url, "table": "t"},
|
||||
"column_mapping": {"pid": "pac_id_hospital", "orden": "ord_numero_hospital"},
|
||||
**extra,
|
||||
}
|
||||
|
||||
|
||||
def test_a_sql_preview_flags_the_columns_that_hold_documents(client, tmp_path):
|
||||
"""Binary files and files written as base64 text are both flagged;
|
||||
plain values aren't. Fails if `document_columns` stops reaching the
|
||||
preview."""
|
||||
url = _documents_table(tmp_path)
|
||||
body = client.post("/imports/sources/sql/preview", json={"connection_string": url, "table": "t"}).get_json()
|
||||
assert set(body["document_columns"]) == {"archivo", "texto"}
|
||||
|
||||
|
||||
def test_document_columns_fill_what_the_mapping_leaves_empty(client, tmp_path):
|
||||
"""The mapped id and order are kept; the documents of both rows of the
|
||||
order add the fields they print; a row without documents passes
|
||||
through mapped. Fails if `documents` stops reading cells of an
|
||||
ordinary mapping, or loses the rows that have none."""
|
||||
source = _sql_source(_documents_table(tmp_path), documents={"columns": ["archivo", "texto"], "group_by": "orden"})
|
||||
rows = client.post("/imports/mapped-preview", json={"source": source}).get_json()["rows"]
|
||||
by_patient = {row["pac_id_hospital"]: row for row in rows}
|
||||
assert by_patient["P-7"]["ord_numero_hospital"] == 5
|
||||
assert by_patient["P-7"]["cit_vph_resultado"] == "POSITIVO"
|
||||
assert by_patient["P-7"]["cit_vph_genotipo_16"] == 1
|
||||
assert by_patient["P-8"]["ord_numero_hospital"] == 6
|
||||
|
||||
|
||||
def test_documents_of_a_mapping_can_be_reviewed_and_committed(client, tmp_path):
|
||||
"""`/imports/sources/document/extract` with `{source}` reviews the same
|
||||
records the commit writes, with the record's pages in `file_field`.
|
||||
Fails if the review and the commit read document columns differently."""
|
||||
source = _sql_source(
|
||||
_documents_table(tmp_path),
|
||||
documents={"columns": "archivo", "group_by": "orden", "file_field": "cit_pdf_blob"},
|
||||
label="t",
|
||||
)
|
||||
report = client.post("/imports/sources/document/extract", json={"source": source}).get_json()
|
||||
[record] = report["records"]
|
||||
assert record["fields"]["pac_id_hospital"]["method"] == "columna_fuente"
|
||||
result = client.post("/imports/commit", json={"sources": [source]}).get_json()["results"][0]
|
||||
assert result["created"] == 2, result
|
||||
|
||||
from persistance.cacu import citologia_cervical_repository
|
||||
|
||||
stored = {r.pac_id_hospital: r for r in citologia_cervical_repository.list(limit=100)}
|
||||
assert stored["P-7"].cit_vph_resultado == "POSITIVO"
|
||||
assert stored["P-7"].cit_pdf_blob.startswith(b"%PDF")
|
||||
|
||||
|
||||
def test_a_csv_column_of_base64_documents_is_read_like_a_sql_one(client):
|
||||
"""Document columns are not tied to SQL: a CSV whose column carries
|
||||
base64 PDFs feeds the same extraction. Fails if `documents` only works
|
||||
for one kind of source."""
|
||||
report = _b64(text_pdf([["VPH alto riesgo: NEGATIVO"]]))
|
||||
source = _csv(
|
||||
f"exp,doc\nC-1,{report}\n",
|
||||
target="cacu.CitologiaCervical",
|
||||
column_mapping={"exp": "pac_id_hospital"},
|
||||
documents={"columns": "doc"},
|
||||
)
|
||||
[row] = client.post("/imports/mapped-preview", json={"source": source}).get_json()["rows"]
|
||||
assert row["pac_id_hospital"] == "C-1" and row["cit_vph_resultado"] == "NEGATIVO"
|
||||
|
||||
|
||||
def _id_and_file_table(tmp_path) -> str:
|
||||
"""Each row has only an id and a file; every other value is printed
|
||||
in the file under captions no target field knows."""
|
||||
url = f"sqlite:///{tmp_path / 'files.db'}"
|
||||
report = text_pdf([["Tipo de persona: Mujer", "Domicilio actual: Calle 5, C.P. 64000", "Nacida el: 02/01/1980"]])
|
||||
with create_engine(url).begin() as conn:
|
||||
conn.execute(text("CREATE TABLE t (pid TEXT, archivo BLOB)"))
|
||||
conn.execute(text("INSERT INTO t VALUES ('Q-1', :f)"), {"f": report})
|
||||
return url
|
||||
|
||||
|
||||
def _paciente_from_file(url: str, **extra) -> dict:
|
||||
return {
|
||||
"source_type": "sql",
|
||||
"target": "cacu.Paciente",
|
||||
"payload": {"connection_string": url, "table": "t"},
|
||||
"documents": {"columns": "archivo"},
|
||||
**extra,
|
||||
}
|
||||
|
||||
|
||||
def test_captions_printed_in_documents_are_offered_as_columns(client, tmp_path):
|
||||
"""`/imports/sources/document/columns` lists the source's own columns
|
||||
and every caption its documents print, with their values. Fails if
|
||||
discovered captions stop becoming columns of the source."""
|
||||
body = client.post(
|
||||
"/imports/sources/document/columns", json={"source": _paciente_from_file(_id_and_file_table(tmp_path))}
|
||||
).get_json()
|
||||
names = [column["name"] for column in body["columns"]]
|
||||
assert {"pid", "Tipo de persona", "Domicilio actual", "Nacida el"} <= set(names)
|
||||
[row] = body["sample_rows"]
|
||||
assert row["Tipo de persona"] == "Mujer"
|
||||
|
||||
|
||||
def test_mapping_and_rules_reach_what_the_documents_print(client, tmp_path):
|
||||
"""A caption maps onto a field like a column does, and derived rules
|
||||
translate or cut values read from the page. Fails if the mapping and
|
||||
`derived` stop running over the record's document values."""
|
||||
source = _paciente_from_file(
|
||||
_id_and_file_table(tmp_path),
|
||||
column_mapping={"pid": "pac_id_hospital", "Nacida el": "pac_fecha_nacimiento"},
|
||||
derived={
|
||||
"pac_sexo": {"op": "map", "column": "Tipo de persona", "values": {"mujer": "F", "hombre": "M"}},
|
||||
"pac_codigo_postal": {"op": "extract", "column": "Domicilio actual", "pattern": r"\d{5}"},
|
||||
},
|
||||
)
|
||||
[row] = client.post("/imports/mapped-preview", json={"source": source}).get_json()["rows"]
|
||||
assert (row["pac_id_hospital"], row["pac_sexo"], row["pac_codigo_postal"]) == ("Q-1", "F", "64000")
|
||||
assert row["pac_fecha_nacimiento"] == "02/01/1980"
|
||||
result = client.post("/imports/validate", json={"source": source}).get_json()
|
||||
assert result["error_count"] == 0, result["errors"]
|
||||
|
||||
|
||||
def _last_report() -> dict:
|
||||
from webapi.imports.audit import default_sink
|
||||
|
||||
return default_sink().read()[-1]
|
||||
|
||||
|
||||
def test_the_import_report_lists_unused_captions_never_their_values(client, tmp_path, monkeypatch):
|
||||
"""Captions the documents print that nothing in the import used are
|
||||
listed with how many records print them, and none of their values
|
||||
reaches the report. Below the minimum count they are only counted.
|
||||
Fails if `unused_captions` stops reaching the audit, lists a caption
|
||||
the mapping uses, or lets a value through."""
|
||||
import json
|
||||
|
||||
source = _paciente_from_file(
|
||||
_id_and_file_table(tmp_path), column_mapping={"pid": "pac_id_hospital", "Nacida el": "pac_fecha_nacimiento"}
|
||||
)
|
||||
monkeypatch.setenv("WEBAPI_REPORT_MIN_COUNT", "1")
|
||||
client.post("/imports/validate", json={"source": source})
|
||||
report = _last_report()["fuentes"][0]
|
||||
assert report["etiquetas_sin_usar"] == {"Tipo de persona": 1, "Domicilio actual": 1}
|
||||
text = json.dumps(_last_report(), ensure_ascii=False)
|
||||
assert "Mujer" not in text and "64000" not in text and "02/01/1980" not in text
|
||||
|
||||
monkeypatch.setenv("WEBAPI_REPORT_MIN_COUNT", "2")
|
||||
client.post("/imports/validate", json={"source": source})
|
||||
report = _last_report()["fuentes"][0]
|
||||
assert report["etiquetas_sin_usar"] == {} and report["etiquetas_sin_usar_poco_frecuentes"] == 2
|
||||
@@ -348,3 +348,41 @@ def test_embedded_image_in_the_report_maps_onto_the_target_dicom_column(client):
|
||||
[row] = mastografia_repository.list(pac_id_hospital="IMG-0001")
|
||||
assert "nódulo circunscrito" in row.mast_interpretacion
|
||||
assert row.mast_dicom_blob.startswith(b"\x89PNG")
|
||||
|
||||
|
||||
def test_a_tea_order_keeps_the_pdf_its_sql_source_carries(client, tmp_path):
|
||||
"""Pins down: `ord_pdf_blob` travels with the order from a SQL source into `ordenes_estudio`, byte for
|
||||
byte, and an order without a file stays without one. The source is a SQLite file in `tmp_path` holding a
|
||||
two-row `ordenes_estudio`. Fails if the import schema drops the field or the commit rewrites the bytes."""
|
||||
report = text_pdf([["EVALUACION PSICOLOGICA", "ADOS-2 Modulo 2"]])
|
||||
url = f"sqlite:///{tmp_path / 'hospital.db'}"
|
||||
table = sa.Table(
|
||||
"ordenes_estudio", sa.MetaData(),
|
||||
sa.Column("ord_id", sa.String(36), primary_key=True),
|
||||
sa.Column("ord_id_hospital", sa.String(64)),
|
||||
sa.Column("ord_tipo_estudio", sa.Text),
|
||||
sa.Column("ord_pdf_blob", sa.LargeBinary),
|
||||
)
|
||||
engine = sa.create_engine(url)
|
||||
table.create(engine)
|
||||
with engine.begin() as connection:
|
||||
connection.execute(sa.insert(table), [
|
||||
{"ord_id": "ord-pdf-1", "ord_id_hospital": "ORD-PDF-1", "ord_tipo_estudio": "ADOS2", "ord_pdf_blob": report},
|
||||
{"ord_id": "ord-pdf-2", "ord_id_hospital": "ORD-PDF-2", "ord_tipo_estudio": "EEG", "ord_pdf_blob": None},
|
||||
])
|
||||
engine.dispose()
|
||||
source = {
|
||||
"source_type": "sql",
|
||||
"target": "tea.OrdenesEstudio",
|
||||
"column_mapping": {column.name: column.name for column in table.columns},
|
||||
"payload": {"connection_string": url, "table": "ordenes_estudio"},
|
||||
}
|
||||
|
||||
result = client.post("/imports/commit", json={"sources": [source], "on_conflict": "upsert"}).get_json()["results"][0]
|
||||
|
||||
assert (result["created"], result["rejected"]) == (2, 0), result
|
||||
|
||||
from persistance.tea import ordenes_estudio_repository
|
||||
|
||||
assert ordenes_estudio_repository.get("ord-pdf-1").ord_pdf_blob == report
|
||||
assert ordenes_estudio_repository.get("ord-pdf-2").ord_pdf_blob is None
|
||||
|
||||
@@ -84,11 +84,11 @@ def test_las_definiciones_son_las_del_manifiesto_de_dbt(base):
|
||||
measure the manifest declares stops reaching `cat_estrato` and `cat_measure`, or a second run deletes rows."""
|
||||
resumen = base.run("definitions")["definitions"]
|
||||
|
||||
# CaCu: three strata and its seven measures; CaMa: the five strata of its invasive cancers and its eight measures;
|
||||
# TEA: the age group and its ten measures.
|
||||
assert resumen["definitions"] == {"cacu": 10, "cama": 13, "tea": 11}[base.proyecto]
|
||||
# CaCu: three strata and its seven measures; CaMa: its seven measures, without strata; TEA: the age group and its
|
||||
# ten measures.
|
||||
assert resumen["definitions"] == {"cacu": 10, "cama": 7, "tea": 11}[base.proyecto]
|
||||
# Y el catálogo de publicación de §6f (T-19b): un `cat_measure` por measure, sincronizado.
|
||||
assert base.dominio.cat_measure_repository.count() == {"cacu": 7, "cama": 8, "tea": 10}[base.proyecto]
|
||||
assert base.dominio.cat_measure_repository.count() == {"cacu": 7, "cama": 7, "tea": 10}[base.proyecto]
|
||||
assert base.run("definitions")["definitions"]["borradas"] == 0
|
||||
|
||||
|
||||
|
||||
@@ -75,9 +75,7 @@ def test_catalogos_deja_en_la_base_las_filas_del_toml(base):
|
||||
del_toml = {"estudios": len(catalogo.estudios), "resultados": len(catalogo.resultados),
|
||||
"valores": len(catalogo.valores)}
|
||||
|
||||
conteos = base.run("catalogs")["catalogs"]
|
||||
assert conteos.pop("mapeos_nuevos") > 0
|
||||
assert conteos == {**del_toml, "retirados": 0}
|
||||
assert base.run("catalogs")["catalogs"] == {**del_toml, "retirados": 0}
|
||||
assert filas_del_catalogo(base) == del_toml
|
||||
|
||||
|
||||
@@ -85,8 +83,7 @@ def test_volver_a_correr_catalogos_no_cambia_nada(base):
|
||||
base.run("catalogs")
|
||||
antes = filas_del_catalogo(base)
|
||||
|
||||
conteos = base.run("catalogs")["catalogs"]
|
||||
assert (conteos["retirados"], conteos["mapeos_nuevos"]) == (0, 0)
|
||||
assert base.run("catalogs")["catalogs"]["retirados"] == 0
|
||||
assert filas_del_catalogo(base) == antes
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
shape the WebApp's contract reads (`RiesgoPacienteCacu`), and its 404. The reads behind it are Persistance's, tested
|
||||
there.
|
||||
|
||||
Fixtures: `client`, the app without `DEV_REVISION` over the kit's CaCu demonstration database (`conftest.cliente_de`)
|
||||
plus `seeded`: a surveillance build with two of its patients, one of them with variables and a confirmed batch.
|
||||
Fixtures: `client`, a DEV client over the kit's CaCu demonstration database (`conftest.cliente_de`) plus `seeded`:
|
||||
a surveillance build with two of its patients, one of them with variables and a confirmed batch; `fuera_de_dev`, the
|
||||
same app without `DEV_REVISION`.
|
||||
"""
|
||||
|
||||
from datetime import date, datetime, timezone
|
||||
@@ -18,9 +19,8 @@ HORIZON_KEYS = {"horizonte_anios", "probabilidad", "ic_bajo", "ic_alto", "estado
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def client(tmp_path_factory):
|
||||
"""The app over the CaCu demonstration database, with no `DEV_REVISION` in the environment."""
|
||||
with pytest.MonkeyPatch.context() as mp:
|
||||
mp.delenv("DEV_REVISION", raising=False)
|
||||
mp.setenv("DEV_REVISION", "prueba")
|
||||
yield from cliente_de("cacu", tmp_path_factory)
|
||||
|
||||
|
||||
@@ -55,11 +55,17 @@ def seeded(client):
|
||||
return scored, unscored, outside
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def fuera_de_dev(tmp_path_factory):
|
||||
with pytest.MonkeyPatch.context() as mp:
|
||||
mp.delenv("DEV_REVISION", raising=False)
|
||||
yield from cliente_de("cacu", tmp_path_factory)
|
||||
|
||||
|
||||
def test_a_scored_member_has_the_contracts_shape(client, seeded):
|
||||
"""Pins down: without `DEV_REVISION` the route exists, and the body has `simulado`, `cohorte` and `riesgo` with
|
||||
exactly the contract's fields, the horizons in ascending order, probabilities in 0..1 and the date as ISO-8601 UTC.
|
||||
Fails if the route depends on an environment variable again, or if a field is renamed or dropped, which would break
|
||||
the WebApp's validation."""
|
||||
"""Pins down: the body has `simulado`, `cohorte` and `riesgo` with exactly the contract's fields, the horizons in
|
||||
ascending order, probabilities in 0..1 and the date as ISO-8601 UTC. Fails if a field is renamed or dropped, which
|
||||
would break the WebApp's validation."""
|
||||
response = client.get(f"/cacu/pacientes/{seeded[0]}/riesgo")
|
||||
|
||||
body = response.get_json()
|
||||
@@ -85,3 +91,9 @@ def test_a_member_without_a_confirmed_batch_and_a_non_member(client, seeded):
|
||||
def test_an_unknown_patient_is_404(client, seeded):
|
||||
"""Pins down: a `pac_id` not in `persona` is 404. Fails if it answers with an empty body as if she existed."""
|
||||
assert client.get("/cacu/pacientes/987654321/riesgo").status_code == 404
|
||||
|
||||
|
||||
def test_outside_dev_the_route_does_not_exist(fuera_de_dev):
|
||||
"""Pins down: without `DEV_REVISION` the route isn't registered. Fails if patient-level risks are served outside
|
||||
the simulated DEV deployment."""
|
||||
assert fuera_de_dev.get("/cacu/pacientes/1/riesgo").status_code == 404
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
"""Extraction's ranker in WebApi: the document review reports each field's
|
||||
alternatives, whether the record is about the target and which extraction
|
||||
version read it; an import whose records a person corrected teaches the
|
||||
domain's ranker once it is written (`webapi.imports.services.
|
||||
review_learning`); and `python -m webapi.nlp` scores and trains against an
|
||||
answer key.
|
||||
|
||||
Fixtures: `client` (the app over fresh CaCu, CaMa and TEA databases),
|
||||
`registry` (a SQLite MLflow per test with its files in `tmp_path`, the
|
||||
ranker and learning switched on, and learning run synchronously). Documents are made up inline with
|
||||
`text_pdf`.
|
||||
"""
|
||||
import argparse
|
||||
import base64
|
||||
import json
|
||||
from concurrent.futures import Future
|
||||
|
||||
import pytest
|
||||
from extraction.testing import text_pdf
|
||||
|
||||
from webapi import nlp
|
||||
from webapi.imports.services import review_learning
|
||||
|
||||
REPORT = text_pdf([["LABORATORIO DE CITOLOGÍA", "Expediente: RV-0001", "No. de orden: 9001", "Prueba de VPH por PCR: POSITIVO",
|
||||
"Observaciones: se sugiere colposcopía; en caso de VPH negativo repetir en un año."]])
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def client(wire_domain):
|
||||
wire_domain("cacu")
|
||||
wire_domain("cama")
|
||||
wire_domain("tea")
|
||||
from webapi import create_app
|
||||
|
||||
app = create_app()
|
||||
app.config.update(TESTING=True)
|
||||
with app.test_client() as test_client:
|
||||
yield test_client
|
||||
|
||||
|
||||
class _Now:
|
||||
"""An executor that runs each task as it is submitted."""
|
||||
|
||||
def submit(self, fn, *args):
|
||||
future = Future()
|
||||
future.set_result(fn(*args))
|
||||
return future
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def registry(tmp_path, monkeypatch):
|
||||
import mlflow
|
||||
|
||||
from models.io import extraction_ranker
|
||||
|
||||
uri = f"sqlite:///{tmp_path / 'mlflow.db'}"
|
||||
monkeypatch.setenv("MLFLOW_TRACKING_URI", uri)
|
||||
monkeypatch.setenv("MLFLOW_ARTIFACT_ROOT", str(tmp_path / "artefactos"))
|
||||
mlflow.set_tracking_uri(uri)
|
||||
monkeypatch.chdir(tmp_path)
|
||||
monkeypatch.setenv("EXTRACTION_RANKER", "auto")
|
||||
monkeypatch.setenv("EXTRACTION_LEARNING", "1")
|
||||
monkeypatch.setattr(extraction_ranker, "_cache", {})
|
||||
monkeypatch.setattr(review_learning, "_executor", _Now())
|
||||
from models.io.registry import registry as models_registry
|
||||
|
||||
yield models_registry
|
||||
|
||||
|
||||
def _source(**options) -> dict:
|
||||
return {
|
||||
"source_type": "document",
|
||||
"target": "cacu.CitologiaCervical",
|
||||
"column_mapping": {"pac_id_hospital": "pac_id_hospital", "ord_numero_hospital": "ord_numero_hospital",
|
||||
"cit_vph_resultado": "cit_vph_resultado"},
|
||||
"payload": {"files": [{"name": "r.pdf", "file_base64": base64.b64encode(REPORT).decode()}], **options},
|
||||
"label": "documentos",
|
||||
}
|
||||
|
||||
|
||||
def test_the_review_reports_alternatives_topic_and_version(client):
|
||||
"""Fails if the review loses the other readings a person can pick, the
|
||||
subject check, or the extraction version that will be stored."""
|
||||
body = client.post("/imports/sources/document/extract", json={"files": _source()["payload"]["files"], "target": "cacu.CitologiaCervical"}).get_json()
|
||||
[record] = body["records"]
|
||||
assert record["on_topic"] is True
|
||||
assert record["fields"]["cit_vph_resultado"]["value"] == "POSITIVO"
|
||||
assert record["fields"]["cit_vph_resultado"]["assertion"] == "afirmado"
|
||||
assert body["nlp_version"].startswith("extraction ")
|
||||
assert all(isinstance(options, list) for options in record["alternatives"].values())
|
||||
|
||||
|
||||
def test_a_corrected_import_teaches_the_ranker(client, registry):
|
||||
"""Committing a document source with a correction registers a new DEV
|
||||
version of the domain's ranker, learned from that record. Fails if
|
||||
`commit_sources` stops calling `learn_from_reviews` or the examples are
|
||||
lost on the way."""
|
||||
source = _source(overrides={"0": {"cit_vph_resultado": "NEGATIVO"}})
|
||||
result = client.post("/imports/commit", json={"sources": [source]}).get_json()
|
||||
assert result["ok"], result
|
||||
[version] = registry.versions("cacu", "extraccion")
|
||||
assert version["status"] == "desarrollo"
|
||||
from models.io.extraction_ranker import current
|
||||
|
||||
assert current("cacu").examples > 0
|
||||
|
||||
|
||||
def test_imports_without_corrections_or_with_learning_off_teach_nothing(client, registry, monkeypatch):
|
||||
"""Fails if an untouched import, or one made with
|
||||
`EXTRACTION_LEARNING=0`, creates ranker versions."""
|
||||
client.post("/imports/commit", json={"sources": [_source()]})
|
||||
monkeypatch.setenv("EXTRACTION_LEARNING", "0")
|
||||
client.post("/imports/commit", json={"sources": [_source(overrides={"0": {"cit_vph_resultado": "NEGATIVO"}})]})
|
||||
assert registry.versions("cacu", "extraccion") == []
|
||||
|
||||
|
||||
def test_the_command_scores_and_trains_against_an_answer_key(tmp_path, registry):
|
||||
"""`evaluate` scores per field and overall without printing values
|
||||
unless asked; `train` estimates on held-out documents, then registers
|
||||
a version. Fails if the command's key format or outputs change."""
|
||||
folder = tmp_path / "documentos"
|
||||
folder.mkdir()
|
||||
(folder / "a.pdf").write_bytes(REPORT)
|
||||
(folder / "b.pdf").write_bytes(text_pdf([["Biopsia cervical dirigida", "Diagnóstico:", "NIC I"]]))
|
||||
key = {
|
||||
"a.pdf": {"cacu.CitologiaCervical": {"cit_vph_resultado": "POSITIVO", "pac_id_hospital": "RV-0001"}},
|
||||
"b.pdf": {"cacu.CitologiaCervical": {"cit_vph_resultado": None}, "cacu.BiopsiaCervical": {"bx_cin_grado": "LIEBG"}},
|
||||
}
|
||||
(tmp_path / "clave.json").write_text(json.dumps(key))
|
||||
paths = {"documents": str(folder), "key": str(tmp_path / "clave.json")}
|
||||
evaluated = nlp.command_evaluate(argparse.Namespace(**paths, with_values=False, no_ranker=True))
|
||||
assert evaluated["global"]["f1"] == 1.0
|
||||
assert evaluated["errores"] == []
|
||||
trained = nlp.command_train(argparse.Namespace(**paths))
|
||||
assert set(trained) == {"sin_ranker", "estimacion_dejando_uno_fuera", "versiones"}
|
||||
assert trained["versiones"] == {"cacu": "1"}
|
||||
+12
-13
@@ -1,8 +1,7 @@
|
||||
"""La lista de seguimiento (T-24d): `GET /cacu/seguimiento`, siempre simulada.
|
||||
"""La lista de seguimiento (T-24d): `GET /cacu/seguimiento`, solo en DEV y siempre simulada.
|
||||
|
||||
Sobre la base de demostración del kit (`conftest.cliente_de`). La lista en sí se prueba en el kit
|
||||
(`tests/test_lista_seguimiento.py`); aquí, la ruta: que existe sin `DEV_REVISION`, la forma y los códigos
|
||||
de error. Fixtures: `client`, la app sin `DEV_REVISION` sobre la base de demostración de CaCu.
|
||||
(`tests/test_lista_seguimiento.py`); aquí, la ruta: cuándo existe, la forma y los códigos de error.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
@@ -15,15 +14,19 @@ LLAVES_DEL_ITEM = {"id_seudonimo", "grupo_edad", "estatus", "ultima_citologia",
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def client(tmp_path_factory):
|
||||
"""La app sobre la base de demostración de CaCu, sin `DEV_REVISION` en el entorno."""
|
||||
with pytest.MonkeyPatch.context() as mp:
|
||||
mp.setenv("DEV_REVISION", "prueba")
|
||||
yield from cliente_de("cacu", tmp_path_factory)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def fuera_de_dev(tmp_path_factory):
|
||||
with pytest.MonkeyPatch.context() as mp:
|
||||
mp.delenv("DEV_REVISION", raising=False)
|
||||
yield from cliente_de("cacu", tmp_path_factory)
|
||||
|
||||
|
||||
def test_la_lista_tiene_la_forma_del_contrato_y_es_simulada(client):
|
||||
"""Fija: sin `DEV_REVISION` la ruta existe, con la forma del contrato y `simulado: true`. Falla si la ruta
|
||||
vuelve a depender de una variable de entorno o cambia un campo."""
|
||||
def test_en_dev_la_lista_tiene_la_forma_del_contrato_y_es_simulada(client):
|
||||
response = client.get("/cacu/seguimiento?corte=2025-12-31")
|
||||
|
||||
assert response.status_code == 200 and response.mimetype == "application/json"
|
||||
@@ -60,9 +63,5 @@ def test_una_pagina_de_mas_da_404(client):
|
||||
assert "error" in response.get_json()
|
||||
|
||||
|
||||
def test_in_dev_esta_obsoleta():
|
||||
"""Fija: `in_dev()` avisa que está obsoleta. Falla si alguien vuelve a usarla como compuerta sin el aviso."""
|
||||
from webapi.follow_up.routes import in_dev
|
||||
|
||||
with pytest.warns(DeprecationWarning):
|
||||
in_dev()
|
||||
def test_fuera_de_dev_la_ruta_no_existe(fuera_de_dev):
|
||||
assert fuera_de_dev.get("/cacu/seguimiento").status_code == 404
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
"""What this module covers: source forms as a function into the catalog's codes (`reference.source_mapping`):
|
||||
many forms to one code, no code for an unknown form, the same form read per source system and per date, and two
|
||||
codes for one form rejected when they're in force together; every catalog's TOML passing that check; and, in each
|
||||
domain's database, the catalog step seeding `cat_mapeo` without touching a stored row and `register` refusing a
|
||||
mapping that breaks the function.
|
||||
|
||||
Fixtures: `base` (conftest), each domain's migrated fixture database; the other tests build their rows.
|
||||
"""
|
||||
|
||||
import tomllib
|
||||
from datetime import date
|
||||
|
||||
import pytest
|
||||
from webapi.orchestration.reference.catalogs import ruta_de_catalogo
|
||||
from webapi.orchestration.reference.source_mapping import (
|
||||
CATALOG, SourceForm, ambiguities, check_function, from_result, normalize, register, resolve,
|
||||
)
|
||||
|
||||
HER2 = "biopsia.her2"
|
||||
LAB_A = [SourceForm("lab_a", HER2, "3+", "H3", None, date(2026, 12, 31)),
|
||||
SourceForm("lab_a", HER2, "Positivo", "H3", None, date(2026, 12, 31))]
|
||||
LAB_B = [SourceForm("lab_b", HER2, "Positivo (score 3)", "H3", date(2027, 1, 1)),
|
||||
SourceForm("lab_b", HER2, "Positivo", "H2", date(2027, 1, 1))]
|
||||
|
||||
|
||||
def test_many_forms_give_one_code_and_an_unknown_form_none():
|
||||
"""Pins down: the mapping isn't injective and is partial: several spellings, compared without case, accents or
|
||||
extra spaces, give the same code; a spelling with no mapping gives None. Fails if `normalize` stops folding or
|
||||
`resolve` invents a code."""
|
||||
assert {resolve(LAB_A, "lab_a", HER2, f) for f in ("3+", " positivo ", "POSITIVO")} == {"H3"}
|
||||
assert resolve(LAB_A, "lab_a", HER2, "Equívoco") is None
|
||||
assert normalize(" Positívo (score 3) ") == "POSITIVO (SCORE 3)"
|
||||
|
||||
|
||||
def test_a_form_is_read_per_source_system_and_per_date():
|
||||
"""Pins down: "Positivo" is H3 at lab A and H2 at lab B, and a mapping applies only to documents dated within its
|
||||
validity. Fails if `resolve` ignores the system or the dates, letting one lab's spelling leak into another's."""
|
||||
rows = LAB_A + LAB_B
|
||||
assert resolve(rows, "lab_a", HER2, "Positivo", date(2026, 6, 1)) == "H3"
|
||||
assert resolve(rows, "lab_b", HER2, "Positivo", date(2027, 2, 1)) == "H2"
|
||||
assert resolve(rows, "lab_b", HER2, "Positivo", date(2026, 6, 1)) is None
|
||||
assert ambiguities(rows) == []
|
||||
|
||||
|
||||
def test_two_codes_for_one_form_in_force_together_are_rejected():
|
||||
"""Pins down: a form mapped to two codes with overlapping validity breaks the function: `check_function` names
|
||||
it and `resolve` gives None rather than either code. Two codes in validities that don't overlap, or the same
|
||||
code twice, are fine. Fails if the overlap test or the code comparison is dropped."""
|
||||
clash = SourceForm("lab_b", HER2, "positivo", "H3", date(2027, 6, 1))
|
||||
with pytest.raises(ValueError, match="se escribe igual para 'H2' y 'H3'"):
|
||||
check_function(LAB_B + [clash])
|
||||
assert resolve(LAB_B + [clash], "lab_b", HER2, "Positivo", date(2027, 7, 1)) is None
|
||||
corrected = [LAB_B[1]._replace(valid_to=date(2027, 5, 31)), clash]
|
||||
check_function(corrected)
|
||||
assert resolve(corrected, "lab_b", HER2, "Positivo", date(2027, 7, 1)) == "H3"
|
||||
check_function(LAB_B + [LAB_B[0]._replace(form="POSITIVO (SCORE 3)")])
|
||||
|
||||
|
||||
@pytest.mark.parametrize("proyecto", ["cacu", "cama", "tea"])
|
||||
def test_every_catalog_s_spellings_are_a_function(proyecto):
|
||||
"""Pins down: in each domain's TOML, every result's codes, labels and aliases map to one value each. Fails when
|
||||
an edit to a catalog gives one spelling two values."""
|
||||
estudios = tomllib.loads(ruta_de_catalogo(proyecto).read_text(encoding="utf-8"))
|
||||
rows = [row for estudio_id, estudio in estudios.items()
|
||||
for nombre, resultado in estudio.get("resultados", {}).items()
|
||||
for row in from_result(f"{estudio_id}.{nombre}", resultado)]
|
||||
check_function(rows)
|
||||
|
||||
|
||||
# --- the stored mappings, in each domain ---
|
||||
|
||||
|
||||
def a_coded_result(base) -> tuple[str, str, str]:
|
||||
"""A coded result of the domain's catalog with two values: (resultado_id, first valor_id, second valor_id)."""
|
||||
estudios = tomllib.loads(ruta_de_catalogo(base.proyecto).read_text(encoding="utf-8"))
|
||||
for estudio_id, estudio in estudios.items():
|
||||
for nombre, resultado in estudio.get("resultados", {}).items():
|
||||
valores = resultado.get("valores", ())
|
||||
if len(valores) >= 2:
|
||||
return f"{estudio_id}.{nombre}", valores[0]["valor"], valores[1]["valor"]
|
||||
raise AssertionError("el catálogo no tiene un resultado codificado con dos valores")
|
||||
|
||||
|
||||
def test_the_catalog_step_seeds_the_mappings_and_keeps_what_a_person_changed(base):
|
||||
"""Pins down: the catalog step adds the catalog's own mappings (each value's code among them) and, run again,
|
||||
adds nothing and leaves a person's row for a new form as it is. Fails if the step stops seeding or a deploy
|
||||
replaces stored rows."""
|
||||
base.run("catalogs")
|
||||
mappings = base.ctx.repos.silver.mappings
|
||||
resultado, primero, segundo = a_coded_result(base)
|
||||
sembradas = mappings.forms(sistema_fuente_id=CATALOG, resultado_id=resultado, clase="valor")
|
||||
assert {(m.forma, m.valor_id) for m in sembradas} >= {(primero, primero), (segundo, segundo)}
|
||||
register(mappings, sistema_fuente_id=CATALOG, clase="valor", forma=" forma del curador ", registrado_por="curador",
|
||||
vigente_desde=date(2026, 1, 1), resultado_id=resultado, valor_id=segundo)
|
||||
assert base.run("catalogs")["catalogs"]["mapeos_nuevos"] == 0
|
||||
[mia] = mappings.forms(forma_normalizada="FORMA DEL CURADOR")
|
||||
assert (mia.forma, mia.valor_id, mia.registrado_por) == ("forma del curador", segundo, "curador")
|
||||
|
||||
|
||||
def test_register_refuses_a_second_code_for_a_form_in_force(base):
|
||||
"""Pins down: `register` checks the new row against the stored ones: the catalog's own code of one value can't
|
||||
be mapped to another value, and a lab's form can, once the first row's validity ends before the second's starts.
|
||||
Fails if the write path stops running `check_function`."""
|
||||
base.run("catalogs")
|
||||
mappings = base.ctx.repos.silver.mappings
|
||||
resultado, primero, segundo = a_coded_result(base)
|
||||
with pytest.raises(ValueError, match="se escribe igual"):
|
||||
register(mappings, sistema_fuente_id=CATALOG, clase="valor", forma=primero, registrado_por="curador",
|
||||
vigente_desde=date(2026, 1, 1), resultado_id=resultado, valor_id=segundo)
|
||||
viejo = register(mappings, sistema_fuente_id=CATALOG, clase="valor", forma="Código de laboratorio",
|
||||
registrado_por="curador", vigente_desde=date(2026, 1, 1), resultado_id=resultado, valor_id=primero)
|
||||
mappings.close(viejo.mapeo_id, date(2026, 12, 31))
|
||||
nuevo = register(mappings, sistema_fuente_id=CATALOG, clase="valor", forma="codigo de LABORATORIO",
|
||||
registrado_por="curador", vigente_desde=date(2027, 1, 1), resultado_id=resultado, valor_id=segundo)
|
||||
filas = mappings.forms(forma_normalizada=normalize("Código de laboratorio"))
|
||||
assert [f.mapeo_id for f in filas] == [viejo.mapeo_id, nuevo.mapeo_id]
|
||||
@@ -1,5 +1,5 @@
|
||||
version = 1
|
||||
revision = 3
|
||||
revision = 5
|
||||
requires-python = ">=3.12"
|
||||
resolution-markers = [
|
||||
"python_full_version >= '3.14' and sys_platform == 'win32'",
|
||||
@@ -236,24 +236,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/fe/ec/c672e72dd66b633fb65e6011bc7c30c128e090364f8497660b7869e10123/apache_hamilton-1.90.0-py3-none-any.whl", hash = "sha256:95e356f7cb23e1a10d44fd0cf5efd3fb36a077b4ccb673950c92005bfdec2ff7", size = 475199, upload-time = "2026-04-25T18:45:17.514Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "appnope"
|
||||
version = "1.0.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/11/f7/a82489c2b6ebe32d3e2831895ae19c77861f0eadf3bb16034484d965dbb2/appnope-1.0.0.tar.gz", hash = "sha256:685db59cb6043c3c2e528adc0b3bce3a5f8d09bcf7492c6ea650d1b7421f3c49", size = 5454, upload-time = "2026-08-20T21:36:13.748Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/46/c7/6b687cb0f83d2a51017d47953f2ee430ffad6fec2a8ebc964e0718a33eb1/appnope-1.0.0-py3-none-any.whl", hash = "sha256:6fe0c04218aab65c54c4ff81638cdbf848d89f5653b74d68638a137f200dd16e", size = 4158, upload-time = "2026-08-20T21:36:12.444Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "asttokens"
|
||||
version = "3.0.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/25/1e/faf0f247f6f881b98fc4d6d07e14085cb89d13665084e6d6ac1dc2c03d0b/asttokens-3.0.2.tar.gz", hash = "sha256:3ecdbd8f2cc195f53ccada3a613538bb5f9ef6f6869129f13e03c30a677b8fe2", size = 63136, upload-time = "2026-07-12T03:31:49.084Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d4/2b/04b8a15f3a1c77bc79ddf5c73875327f34b4fa75982df2b76e45e402d364/asttokens-3.0.2-py3-none-any.whl", hash = "sha256:9da13157f5b28becde0bd374fc677dcd3c290614264eff096f167c469cd9f933", size = 28702, upload-time = "2026-07-12T03:31:47.542Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "attrs"
|
||||
version = "26.1.0"
|
||||
@@ -263,36 +245,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/64/b4/17d4b0b2a2dc85a6df63d1157e028ed19f90d4cd97c36717afef2bc2f395/attrs-26.1.0-py3-none-any.whl", hash = "sha256:c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309", size = 67548, upload-time = "2026-03-19T14:22:23.645Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "beautifulsoup4"
|
||||
version = "4.15.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "soupsieve" },
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/43/65/318323f98dbee45d42dff61d8f047181bc6f2268a9068cfad035a46be5af/beautifulsoup4-4.15.0.tar.gz", hash = "sha256:288e3ca7d54b06f2ac191970bc275c1939cb46d450b255bf6718b04aa37ab4f7", size = 632571, upload-time = "2026-06-07T16:44:20.453Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/88/c6/92fcd42f1ba33e1184263f25bfabf3d27c383410470f169e4b8163bf9c17/beautifulsoup4-4.15.0-py3-none-any.whl", hash = "sha256:d6f88de62e1d4e38ecb1077eb9724cd0eff29d2a08ca16a401e9b9e93f117cf9", size = 109924, upload-time = "2026-06-07T16:44:21.566Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bleach"
|
||||
version = "6.4.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "webencodings" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/48/3c/e12ac860709702bd5ebeb9b56a4fe334f1001246ee1b8f2b7ee28912df7d/bleach-6.4.0.tar.gz", hash = "sha256:4202482733d85cedd04e59fcb2f89f4e4c7c385a78d3c3c23c30446843a37452", size = 204857, upload-time = "2026-06-05T13:01:13.734Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/58/9d/40b6267367182187139a4000b82a3b287d84d745bccd808e75d916920e9d/bleach-6.4.0-py3-none-any.whl", hash = "sha256:4b6b6a54fff2e69a3dde9d21cc6301220bee3c3cb792187d11403fd795031081", size = 165109, upload-time = "2026-06-05T13:01:12.504Z" },
|
||||
]
|
||||
|
||||
[package.optional-dependencies]
|
||||
css = [
|
||||
{ name = "tinycss2" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "blinker"
|
||||
version = "1.9.0"
|
||||
@@ -563,15 +515,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "comm"
|
||||
version = "0.2.3"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/4c/13/7d740c5849255756bc17888787313b61fd38a0a8304fc4f073dfc46122aa/comm-0.2.3.tar.gz", hash = "sha256:2dc8048c10962d55d7ad693be1e7045d891b7ce8d999c97963a5e3e99c055971", size = 6319, upload-time = "2025-07-25T14:02:04.452Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/60/97/891a0971e1e4a8c5d2b20bbe0e524dc04548d2307fee33cdeba148fd4fc7/comm-0.2.3-py3-none-any.whl", hash = "sha256:c615d91d75f7f04f095b30d1c1711babd43bdc6419c1be9886a85f2f4e489417", size = 7294, upload-time = "2025-07-25T14:02:02.896Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "contourpy"
|
||||
version = "1.4.0"
|
||||
@@ -745,31 +688,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d2/c1/631160994379b7baa4605c2a4ffa6bca374b3ef73213e43b2dfcbd6c2bb9/databricks_sdk-0.156.0-py3-none-any.whl", hash = "sha256:1aa5e0cabfc5626a886c9fa42bc1ce14a6166e8167ef34026dcc41f3c99e2a5a", size = 1112276, upload-time = "2026-10-22T04:33:33.024Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "debugpy"
|
||||
version = "1.8.22"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/44/9d/3cb6693342acf96802dba89934a5b8da43c201d764ebd1f2c0514a3d42bd/debugpy-1.8.22.tar.gz", hash = "sha256:e489c7268e1c7b41e13b438d9c533d2a7af73fb59bf8cd30fead8286c1c39c4e", size = 1710877, upload-time = "2026-09-15T21:44:02.578Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/73/21/5c7f5c66eaeee57c9dadb0bbff22efddc8d99cdbd3d036c806175f1828cc/debugpy-1.8.22-cp312-cp312-macosx_15_0_universal2.whl", hash = "sha256:4ad076f4f66cb8acb79e4384d48b1ea60a0b1957aa0b1112d4887ea3a4df60e0", size = 2499375, upload-time = "2026-09-15T21:44:18.478Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7e/ec/7389798843643ea5bc6a08480ba1b855377c70e2ed90189c0a03594e401e/debugpy-1.8.22-cp312-cp312-manylinux_2_34_x86_64.whl", hash = "sha256:8a697acec45dbc70d17fb5d9f4f61989fc294d273c69de487fd10cb35fdd75eb", size = 4000941, upload-time = "2026-09-15T21:44:20.245Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/20/f4/64ce7a2499550929e08654360b270409eeda3e321b7c27027d9c919aa36b/debugpy-1.8.22-cp312-cp312-win32.whl", hash = "sha256:12bc7f368182b517cf26c76a2393fff65354e365fa1552b6241e66edff17997b", size = 5359040, upload-time = "2026-09-15T21:44:22.218Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4b/fe/e7d3b72874cdd327bda295d1995a01e426857ae9cbaaba74fd997bc3afbc/debugpy-1.8.22-cp312-cp312-win_amd64.whl", hash = "sha256:371a4ba4a5975eb958393903f3254cf983da7b1c7c178b3f987ee427f42515e3", size = 5398304, upload-time = "2026-09-15T21:44:24.119Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6b/f4/fee6d40f5865aa84e1100c9df1a0f2cf8991776b61f11f433ff277df4415/debugpy-1.8.22-cp313-cp313-macosx_15_0_universal2.whl", hash = "sha256:c21dd7e1ec22556bb41dc3bf6b86c603e440ec889c4acb27d7206354b2106c54", size = 2493531, upload-time = "2026-09-15T21:44:25.835Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bc/4f/8df91270afbf61fc5ab202951f28451194a7eb093704b26da11cb0ecd308/debugpy-1.8.22-cp313-cp313-manylinux_2_34_x86_64.whl", hash = "sha256:c1ffb9953708b648ecf6acd2e5ad2c002bf68785ed618197dd4463a2a7226f39", size = 3994351, upload-time = "2026-09-15T21:44:27.31Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4f/11/2e34a4f21d6155b0c58003fd6fca9819df7d6fe7d7acd83b146b648a57ee/debugpy-1.8.22-cp313-cp313-win32.whl", hash = "sha256:ba810a66b437e3c43ca0ce0892404f010338286263ca8e5108442d76a9485337", size = 5359071, upload-time = "2026-09-15T21:44:29.064Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d0/f5/c2b3e8260388d7b76bc4e5a3a29648a0ca47dca6a2721d6549ff2d944eee/debugpy-1.8.22-cp313-cp313-win_amd64.whl", hash = "sha256:f49b1d6cecf326b63c06d7f517e4a6642777f758c58cb799e7bc5a6dd74721c2", size = 5400362, upload-time = "2026-09-15T21:44:30.857Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ea/95/d97240bb68b86db8d0a07602be068aae9e50f17063d696a4c6f619975311/debugpy-1.8.22-cp314-cp314-macosx_15_0_universal2.whl", hash = "sha256:e6744ac1850c73c2ba7b29a126cf9ab74efd1831190720e8fee17ef5389c8f5d", size = 2493148, upload-time = "2026-09-15T21:44:32.518Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/70/9e/994fe1fb23dd4a5a8d059a0dc95da4b0821907200a61c2d5a4fdc21b6cf8/debugpy-1.8.22-cp314-cp314-manylinux_2_34_x86_64.whl", hash = "sha256:0c1104233340196e5cbf5514e7dfdbb98968e730cfd7fdd6f3d72a082be838a9", size = 3961025, upload-time = "2026-09-15T21:44:34.387Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/37/e0/66319918883cf6dd6dea3805210c3cafd9e65dfaa6f8b852482cff10a026/debugpy-1.8.22-cp314-cp314-win32.whl", hash = "sha256:feea785c7bbeb8cfd5b01a63f9061c899dc468c8be81671141a29305774fa294", size = 5359408, upload-time = "2026-09-15T21:44:36.128Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/94/53/5b4d91f7fffb9393ac907133201d1da0c070d57e463ee8e2ec1db3cb63b6/debugpy-1.8.22-cp314-cp314-win_amd64.whl", hash = "sha256:d593a330297332ec435f3965c448b6d500e03f33675cf2063178bc76377a788e", size = 5397429, upload-time = "2026-09-15T21:44:38.429Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/24/71/580df4aed96c9b23c9cbb049907d8ac1347050afdb8f450df20649d51578/debugpy-1.8.22-cp315-cp315-macosx_15_0_universal2.whl", hash = "sha256:a9eca6ab09a61534e923064400081e016f7e1d8430cc6e8b7a9cecd2f59e2b07", size = 2493380, upload-time = "2026-09-15T21:44:40.074Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b0/10/a323945b0966e560c40fe48470d2847bfc7692a8f550d7086e9a28f5b623/debugpy-1.8.22-cp315-cp315-manylinux_2_34_x86_64.whl", hash = "sha256:b7dbde1fb822d100802d505b2aed6d0813b1a0a2015d495cb8798b2215d5d1e5", size = 3975456, upload-time = "2026-09-15T21:44:41.623Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ef/f9/4383635281999c3eaa44bf327de523ba42240b35eb87c1130adac4a829c6/debugpy-1.8.22-cp315-cp315-win32.whl", hash = "sha256:225d063f81708c2546999e7edfac0198b2d5c2f144797dc64858f867948633e0", size = 5359469, upload-time = "2026-09-15T21:44:43.234Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7b/14/4fe9f46a9c825c8cbc6dc4aebc2a885b0bceb37ce2a37699c170482e7a40/debugpy-1.8.22-cp315-cp315-win_amd64.whl", hash = "sha256:b17a4896520f1c6da09ce76ec8215df0b85b0b6f3617526a4c65c2315340875a", size = 5397869, upload-time = "2026-09-15T21:44:44.783Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/56/3d/c7dc9f35bc9e22cdb53679f844bee40fd5cff871862f60595869a433400d/debugpy-1.8.22-py2.py3-none-any.whl", hash = "sha256:a9e9d3550e15ca479c59333e90845029190531f0cacfedab3b815a57bd913947", size = 5374857, upload-time = "2026-09-15T21:44:54.454Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "decorator"
|
||||
version = "5.3.1"
|
||||
@@ -779,15 +697,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/05/7f/798705f5296a58ca505d600456748d1be48078eac8a7050d8a98bc9edb89/decorator-5.3.1-py3-none-any.whl", hash = "sha256:f47fe6fdbd2edd623ecfe36875d37aba411624e2670dd395dddae1358689bb3c", size = 10365, upload-time = "2026-05-18T06:03:26.517Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "defusedxml"
|
||||
version = "0.7.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/0f/d5/c66da9b79e5bdb124974bfe172b4daf3c984ebd9c2a06e2b8a4dc7331c72/defusedxml-0.7.1.tar.gz", hash = "sha256:1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69", size = 75520, upload-time = "2021-03-08T10:59:26.269Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/07/6c/aa3f2f849e01cb6a001cd8554a88d4c77c5c1a31c95bdf1cf9301e6d9ef4/defusedxml-0.7.1-py2.py3-none-any.whl", hash = "sha256:a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61", size = 25604, upload-time = "2021-03-08T10:59:24.45Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "docker"
|
||||
version = "7.2.0"
|
||||
@@ -811,15 +720,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/c1/8b/5fe2cc11fee489817272089c4203e679c63b570a5aaeb18d852ae3cbba6a/et_xmlfile-2.0.0-py3-none-any.whl", hash = "sha256:7a91720bc756843502c3b7504c77b8fe44217c85c537d85037f0f536151b2caa", size = 18059, upload-time = "2024-10-25T17:25:39.051Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "executing"
|
||||
version = "2.3.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/52/92/8a611141e42930c0f194f7504063ab87dfe970cf1a5af28e7703df448734/executing-2.3.0.tar.gz", hash = "sha256:15919cb5d667e5cb4e099511971d00d659573fff2dd5c4e6cd8b71636c7858d2", size = 1338003, upload-time = "2026-10-10T14:06:04.64Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/4d/dd/8bc67e7d5ffc1d88aa5af511189dfb76dc4e1e5b808fab186146ef2663e5/executing-2.3.0-py3-none-any.whl", hash = "sha256:736e859c9f8701f11fcf516856f26f562e04776387824b43a35a1dfe21c84122", size = 29393, upload-time = "2026-10-10T14:06:02.777Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "extraction"
|
||||
version = "0.1.0"
|
||||
@@ -868,15 +768,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/45/2a/101012d82931d9de3855384e1667e49c0e07a0048e3868f9fec1697293a9/fastapi-0.161.1-py3-none-any.whl", hash = "sha256:a1363080cf9aeedecd99f4e1a23669d7e77542227f6536f4d7bbd59f07ecaa94", size = 149049, upload-time = "2026-10-22T22:22:06.139Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastjsonschema"
|
||||
version = "2.22.3"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/1c/80/cc3c531dd70c8ffa1045aecf33c97c5581cc8fd0e824b3ecb2c1881550c1/fastjsonschema-2.22.3.tar.gz", hash = "sha256:8330c91b027dcf941efcb7b1f0998515ff95d177ea15bbabdfe8671965620901", size = 388854, upload-time = "2026-11-01T21:11:34.389Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d7/0d/6caab33488dc9d26440c24221fa610c7c8b83c30715ab45d31f0e004308e/fastjsonschema-2.22.3-py3-none-any.whl", hash = "sha256:f670b443830b75aca3f00b75949efa20f4b2a80302ec7a21505c28dd54cffd43", size = 28442, upload-time = "2026-11-01T21:11:29.306Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fhir-core"
|
||||
version = "1.1.12"
|
||||
@@ -1262,62 +1153,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/iniconfig-2.3.0-py3-none-any.whl", hash = "sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12", size = 7484, upload-time = "2025-10-18T21:55:41.639Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipykernel"
|
||||
version = "7.4.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "appnope", marker = "sys_platform == 'darwin'" },
|
||||
{ name = "comm" },
|
||||
{ name = "debugpy" },
|
||||
{ name = "ipython" },
|
||||
{ name = "jupyter-client" },
|
||||
{ name = "jupyter-core" },
|
||||
{ name = "matplotlib-inline" },
|
||||
{ name = "nest-asyncio2" },
|
||||
{ name = "packaging" },
|
||||
{ name = "pyzmq" },
|
||||
{ name = "tornado" },
|
||||
{ name = "traitlets" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/7a/05/e5499c8b762387d83926bf0389e8fff888c9bf6e7af30566a8527bc12f4a/ipykernel-7.4.0.tar.gz", hash = "sha256:4330114d22b9b33575b2c7c68753fc8faabbbcfbc60b0cdff9f14dd4ce63742f", size = 192731, upload-time = "2026-09-29T16:33:11.468Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/a5/f8/8b5c10c7f36ab5a3b5c4703669e5b14e44e98782b58e535dd30670e8799a/ipykernel-7.4.0-py3-none-any.whl", hash = "sha256:a6757f790ddc5a6006b813d82da1a9dbb65b3a00f2b6607df776418c6566ec1c", size = 123184, upload-time = "2026-09-29T16:33:09.612Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipython"
|
||||
version = "9.18.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
||||
{ name = "ipython-pygments-lexers" },
|
||||
{ name = "jedi" },
|
||||
{ name = "matplotlib-inline" },
|
||||
{ name = "pexpect", marker = "sys_platform != 'emscripten' and sys_platform != 'win32'" },
|
||||
{ name = "prompt-toolkit" },
|
||||
{ name = "psutil", marker = "sys_platform != 'android' and sys_platform != 'cygwin' and sys_platform != 'emscripten'" },
|
||||
{ name = "pygments" },
|
||||
{ name = "stack-data" },
|
||||
{ name = "traitlets" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/38/04/0d945c72d5b77527273ecb4c66aa2436de7a3b3bbe3da345bf053232b886/ipython-9.18.1.tar.gz", hash = "sha256:6319c0f5372c196397899479e6db1783dd7937abae06815d1317e8d5d51aaaaf", size = 4437314, upload-time = "2026-11-02T09:19:55.55Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/bb/1c/91da4a1c541b75e97eb99d09c6a9b0534de55bb4a466669d1170e39b915c/ipython-9.18.1-py3-none-any.whl", hash = "sha256:997ce9140d374531a61069c70c0f9ef299d6dd3559ea0f94b8af589726e3c1d5", size = 649819, upload-time = "2026-11-02T09:19:53.32Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipython-pygments-lexers"
|
||||
version = "1.1.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "pygments" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/ef/4c/5dd1d8af08107f88c7f741ead7a40854b8ac24ddf9ae850afbcf698aa552/ipython_pygments_lexers-1.1.1.tar.gz", hash = "sha256:09c0138009e56b6854f9535736f4171d855c8c08a563a0dcd8022f78355c7e81", size = 8393, upload-time = "2025-01-17T11:24:34.505Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d9/33/1f075bf72b0b747cb3288d011319aaf64083cf2efef8354174e3ed4540e2/ipython_pygments_lexers-1.1.1-py3-none-any.whl", hash = "sha256:a9462224a505ade19a605f71f8fa63c2048833ce50abc86768a0d81d876dc81c", size = 8074, upload-time = "2025-01-17T11:24:33.271Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itsdangerous"
|
||||
version = "2.2.0"
|
||||
@@ -1327,18 +1162,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/04/96/92447566d16df59b2a776c0fb82dbc4d9e07cd95062562af01e408583fc4/itsdangerous-2.2.0-py3-none-any.whl", hash = "sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef", size = 16234, upload-time = "2024-04-16T21:28:14.499Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jedi"
|
||||
version = "0.20.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "parso" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a3/a4/4692ecd7fa700ac1066b1c1f6cadef60aa2e01e5e364710235137d823e0a/jedi-0.20.1.tar.gz", hash = "sha256:2f71208c3f9c1bca057c0e90d3f272aba44ace88fc4067d7587e9e069331b7e5", size = 3121738, upload-time = "2026-10-12T17:42:24.361Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/be/c7/71eb0d51cdcbb63b857c931aa4e9218b078b5d9f8ecd383b234f28fe7b0f/jedi-0.20.1-py2.py3-none-any.whl", hash = "sha256:0fb16d86c4a4c73c37ba518c77419975e30fcc620658a8d14fbb5720cdd34142", size = 4885980, upload-time = "2026-10-12T17:42:21.585Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jinja2"
|
||||
version = "3.1.6"
|
||||
@@ -1363,72 +1186,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/18/53/84099323c2ec4be98d935f63c033ac4151ee83836ca1050ede3b3aadf155/joblib-1.6.0-py3-none-any.whl", hash = "sha256:3dbbf9f6e4b592a2357b854608e980fe6390d131d7a82f011a377ef2ebef7aba", size = 306115, upload-time = "2026-08-31T09:39:02.298Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonschema"
|
||||
version = "4.26.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "attrs" },
|
||||
{ name = "jsonschema-specifications" },
|
||||
{ name = "referencing" },
|
||||
{ name = "rpds-py" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/b3/fc/e067678238fa451312d4c62bf6e6cf5ec56375422aee02f9cb5f909b3047/jsonschema-4.26.0.tar.gz", hash = "sha256:0c26707e2efad8aa1bfc5b7ce170f3fccc2e4918ff85989ba9ffa9facb2be326", size = 366583, upload-time = "2026-01-07T13:41:07.246Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/69/90/f63fb5873511e014207a475e2bb4e8b2e570d655b00ac19a9a0ca0a385ee/jsonschema-4.26.0-py3-none-any.whl", hash = "sha256:d489f15263b8d200f8387e64b4c3a75f06629559fb73deb8fdfb525f2dab50ce", size = 90630, upload-time = "2026-01-07T13:41:05.306Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonschema-specifications"
|
||||
version = "2025.9.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "referencing" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/19/74/a633ee74eb36c44aa6d1095e7cc5569bebf04342ee146178e2d36600708b/jsonschema_specifications-2025.9.1.tar.gz", hash = "sha256:b540987f239e745613c7a9176f3edb72b832a4ac465cf02712288397832b5e8d", size = 32855, upload-time = "2025-09-08T01:34:59.186Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/41/45/1a4ed80516f02155c51f51e8cedb3c1902296743db0bbc66608a0db2814f/jsonschema_specifications-2025.9.1-py3-none-any.whl", hash = "sha256:98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe", size = 18437, upload-time = "2025-09-08T01:34:57.871Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jupyter-client"
|
||||
version = "8.10.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "jupyter-core" },
|
||||
{ name = "python-dateutil" },
|
||||
{ name = "pyzmq" },
|
||||
{ name = "tornado" },
|
||||
{ name = "traitlets" },
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/c5/2a/906772148a06e48885039e0250c340b770a55bbf37b08d6ee0449df369c3/jupyter_client-8.10.0.tar.gz", hash = "sha256:9f7116294dca55f1785be880057d44544db9b1567718d92cb33c58886afb9497", size = 360653, upload-time = "2026-08-28T12:17:10.854Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/0f/88/7c548de1f6c2ade7c931a3282da73f9274fa6a1531091be682f89c85efb9/jupyter_client-8.10.0-py3-none-any.whl", hash = "sha256:5f73f24f22fa25192cfff6b23c051932a2473a797b05734aff495b392103e14e", size = 110184, upload-time = "2026-08-28T12:17:09.028Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jupyter-core"
|
||||
version = "5.9.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "platformdirs" },
|
||||
{ name = "traitlets" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/02/49/9d1284d0dc65e2c757b74c6687b6d319b02f822ad039e5c512df9194d9dd/jupyter_core-5.9.1.tar.gz", hash = "sha256:4d09aaff303b9566c3ce657f580bd089ff5c91f5f89cf7d8846c3cdf465b5508", size = 89814, upload-time = "2025-10-16T19:19:18.444Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/e7/e7/80988e32bf6f73919a113473a604f5a8f09094de312b9d52b79c2df7612b/jupyter_core-5.9.1-py3-none-any.whl", hash = "sha256:ebf87fdc6073d142e114c72c9e29a9d7ca03fad818c5d300ce2adc1fb0743407", size = 29032, upload-time = "2025-10-16T19:19:16.783Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jupyterlab-pygments"
|
||||
version = "0.3.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/90/51/9187be60d989df97f5f0aba133fa54e7300f17616e065d1ada7d7646b6d6/jupyterlab_pygments-0.3.0.tar.gz", hash = "sha256:721aca4d9029252b11cfa9d185e5b5af4d54772bb8072f9b7036f4170054d35d", size = 512900, upload-time = "2023-11-23T09:26:37.44Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/b1/dd/ead9d8ea85bf202d90cc513b533f9c363121c7792674f78e0d8a854b63b4/jupyterlab_pygments-0.3.0-py3-none-any.whl", hash = "sha256:841a89020971da1d8693f1a99997aefc5dc424bb1b251fd6322462a1b8842780", size = 15884, upload-time = "2023-11-23T09:26:34.325Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kiwisolver"
|
||||
version = "1.5.1"
|
||||
@@ -1688,24 +1445,44 @@ wheels = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matplotlib-inline"
|
||||
version = "0.2.2"
|
||||
name = "ml-dtypes"
|
||||
version = "0.6.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "traitlets" },
|
||||
{ name = "numpy" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/bd/c0/9f7c9a46090390368a4d7bcb76bb87a4a36c421e4c0792cdb53486ffac7a/matplotlib_inline-0.2.2.tar.gz", hash = "sha256:72f3fe8fce36b70d4a5b612f899090cd0401deddc4ea90e1572b9f4bfb058c79", size = 8150, upload-time = "2026-05-08T17:33:33.49Z" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/12/72/307d7c4bd0600601c7133fba5cb78af7db968152951c1cd473abb1cda782/ml_dtypes-0.6.0.tar.gz", hash = "sha256:5e60251d32ced5598972e4d5e06a2f044341f9291402551a3f6f0ec44f9299b0", size = 3032327, upload-time = "2026-08-13T14:14:40.215Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/41/09/5b161152e2d90f7b87f781c2e1267494aef9c32498df793f73ad0a0a494a/matplotlib_inline-0.2.2-py3-none-any.whl", hash = "sha256:3c821cf1c209f59fb2d2d64abbf5b23b67bcb2210d663f9918dd851c6da1fcf6", size = 9534, upload-time = "2026-05-08T17:33:32.055Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mistune"
|
||||
version = "3.4.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/96/eb/749a4e69bf7396e751ae37444abe997eff2254e695a8095b84d1c89c1181/mistune-3.4.0.tar.gz", hash = "sha256:2eaf7952af928ca8d33b779762effc1da517b62c6ad85ec8ca957e3b07b9782a", size = 136772, upload-time = "2026-10-19T10:44:28.172Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/2c/f7/021d590d52c1ac28e3290311776854c6a1c927fa3fb4b25ce74caf937a3d/mistune-3.4.0-py3-none-any.whl", hash = "sha256:d03cec4c8620f21517a996d82d14f3b59c30d79bda2cc6c56bd32b839f18ce6b", size = 70398, upload-time = "2026-10-19T10:44:26.751Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/84/6a/441eb053b078954f7fea284dfb288701884d0a1404d39babb858e1649023/ml_dtypes-0.6.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:5359c588cc62de6f78d7430f06b65853d884955494d86d6ad90b6dd64a3f3a08", size = 565447, upload-time = "2026-08-13T14:14:01.737Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ed/cf/87e8a6c57eed63a91782a0d229856ddf73e138ce004dd71e2799a9dcdb33/ml_dtypes-0.6.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:37da32aa97749251025666d62372775019594577b9c9e9cfda83bed48d778fdb", size = 360227, upload-time = "2026-08-13T14:14:02.938Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c7/f9/7d76c1eae866f5d4636401b31b6d6dd90e4b4ced1fa7cfdfcca9c60e4bd3/ml_dtypes-0.6.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3b4a480aa8fd54a1805b8ac10f3f91763926a74f73c0c364c10f9231854f4170", size = 409890, upload-time = "2026-08-13T14:14:04.248Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ba/db/9c61ec2760b5cbfb1c6558d5c991a6d8fd3271053c32db20506a9a90272b/ml_dtypes-0.6.0-cp312-cp312-win_amd64.whl", hash = "sha256:2a3e9d53925597fbffafd2a37048dadeddd0bdaba58058f6ae0869ed709a184d", size = 439333, upload-time = "2026-08-13T14:14:05.501Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6a/57/780ca3e5ab135b9fbdd8e5441abf5f801b30398371b691291e05ab9834c0/ml_dtypes-0.6.0-cp312-cp312-win_arm64.whl", hash = "sha256:6eaed129a4afe90694b8685e2f9b6294849f5eda4af9a15be83a4326eeebd775", size = 552268, upload-time = "2026-08-13T14:14:06.866Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/50/51/fd1582b8f5ed8a9e7be0e161a6ea0dff70cb280479a12178df0b3a72700e/ml_dtypes-0.6.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:084dfe51a7ad58b171f05115f8226ed4233a454a1611371947e806e76f0c638d", size = 565468, upload-time = "2026-08-13T14:14:08.5Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d2/22/20fd70ca6ed12446cb92d5b2a7745bd185f9d8b8cdeeadad976574398e6b/ml_dtypes-0.6.0-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:28d676428b104bb9717b0928bc5c5129f2d6b51b6727587cc4289e7bf8713cb5", size = 360232, upload-time = "2026-08-13T14:14:09.873Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/89/a5/da8ae6c6f1babe4b68e3e55d43d39b529e29774f10e0910671a6b8c86eb8/ml_dtypes-0.6.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:26b1f1fa4f0435a2946859823f6e2bf06796f1e9f10f5a05b08a5e3c8f46ff69", size = 410169, upload-time = "2026-08-13T14:14:11.036Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e2/55/4561acefa00fa4bcbfb82ca6a48578b41f372cd7dd7cdd6eb4720abc2e5f/ml_dtypes-0.6.0-cp313-cp313-win_amd64.whl", hash = "sha256:fb87f46b4f7ad7b5d3ad8f4b452b024bd4229d44c8ff934798c1fe656210387a", size = 439357, upload-time = "2026-08-13T14:14:12.172Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b1/5d/6a01538e507ef0ed5e879985b13a92467bf8960696fb1131f8b8cadc60ff/ml_dtypes-0.6.0-cp313-cp313-win_arm64.whl", hash = "sha256:57ed0d6b4ac5e7868361303a9c57fbcf63b768236ee14456f585dfcf260d0292", size = 552278, upload-time = "2026-08-13T14:14:13.539Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d9/7a/97dc35667b7c9db33c5344c673cd27f87e34771875ea7100138726132ac9/ml_dtypes-0.6.0-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:84fa136b8602c8c39e3b6cb24918960cd6f36cade7a70376f56770729cd56510", size = 562551, upload-time = "2026-08-13T14:14:14.774Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/db/48/77f0ede10558d0d935da2e3276ed7e9c8cc2bad3463b9a0b66b03fc60be2/ml_dtypes-0.6.0-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:317be9967fb84b0ce4e80e6b1bf71213d21971621cf6f1e501a63602a95297bf", size = 360334, upload-time = "2026-08-13T14:14:16.079Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1c/b1/1831dd8c9b06c013085d31a2ac4f03392d43bd36bfc6ff591a08bcedc1cf/ml_dtypes-0.6.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8f490c003369ce60e514a0c3b12374f05274c101fee1bead6740ec8a564032b0", size = 409966, upload-time = "2026-08-13T14:14:17.477Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ff/ad/9c32c53f823dda3742df19a79c10bc198365937873ea125ba65747440c23/ml_dtypes-0.6.0-cp314-cp314-win_amd64.whl", hash = "sha256:d574c2b28921dc72e869df248f1a278f6eee176a1f237c8642e1a71eb15f3977", size = 457224, upload-time = "2026-08-13T14:14:18.608Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/41/3d/dd98205418a13353d41c52bf5326d8cbec515aace46174e23c6ea01c2978/ml_dtypes-0.6.0-cp314-cp314-win_arm64.whl", hash = "sha256:f4adb4af61516510d786cf8c01851a66f6d3ddfa79e1144deaa5b40d8507231e", size = 568378, upload-time = "2026-08-13T14:14:19.843Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/65/36/32e7beef3281fed74883451477ad976364323206dbfaa95e948ba788dac7/ml_dtypes-0.6.0-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:3e169214e0d80ff1c038e1b3017e33c23e43bdf948d42d31de8283111c7e2fa3", size = 590177, upload-time = "2026-08-13T14:14:20.971Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d7/a2/99b3d9b3c984b3bd1e81d8244f1fa2f812e44060d853205b2df6271aa17c/ml_dtypes-0.6.0-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:573b11f3c327e17ef3826d266e676cf1149a1f3016f822a05f2306c55d8246bf", size = 363142, upload-time = "2026-08-13T14:14:22.463Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0c/fb/8091c0aee7f2712de99c7fd4b1642382644dec6a4962effe4f5b9d16a973/ml_dtypes-0.6.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b76fa1d3f92967d58289ac47ab7458ede66e6f3527fff3e59142aee57d9307cd", size = 430645, upload-time = "2026-08-13T14:14:23.737Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c4/6f/962d2c589513b5930d05b6eae5fbd22ad8bbcf26bb763449f3d8f912360f/ml_dtypes-0.6.0-cp314-cp314t-win_amd64.whl", hash = "sha256:3be9911d953f97cddded4b9961d7b650473b7e55806d20f6176f8356dfe7b38e", size = 465667, upload-time = "2026-08-13T14:14:25.04Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/aa/ca/bcb25e246edd19af5fa1cf6267040bd9977a7afca846e6cfd4a52078b44f/ml_dtypes-0.6.0-cp314-cp314t-win_arm64.whl", hash = "sha256:e74266ca8e97874a937b7646378c178025650a236584f7474d10d8086a6edea3", size = 572706, upload-time = "2026-08-13T14:14:26.296Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/12/42/46cb442648e3c774d8cb25f2e1e41d496cdcc91fbe9c2a6f75c0b8df7af6/ml_dtypes-0.6.0-cp315-cp315-macosx_10_15_universal2.whl", hash = "sha256:b1b503864fada3f74fabf8d9fee7b4c1cbe956301e6fdece975d5f77c2fce958", size = 562550, upload-time = "2026-08-13T14:14:27.542Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/07/56/844eff5af7a2d1a09d75df12c70225c3a6b6a771f95876b2bf5f7d10ad44/ml_dtypes-0.6.0-cp315-cp315-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9c6ad60af4102789a5c09824004beade2f7f28cd1cd581ee5c170d9dc2fbb00e", size = 360332, upload-time = "2026-08-13T14:14:28.767Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b6/29/b7165a3a76364a5baa6aa4ee82a0adf73a3c014b8cd126120b62cc087992/ml_dtypes-0.6.0-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d4f1b9329a251e4affe3bb58f4d3e2db22a714396fd7ffb40d0b5db423c24d17", size = 409964, upload-time = "2026-08-13T14:14:30.023Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c8/2e/f61c54a0544b6a170ac1bb89bcf406af53fb2deffc5476b6d2d3df5ba13e/ml_dtypes-0.6.0-cp315-cp315-win_amd64.whl", hash = "sha256:488c99ab181a2f59d9ec3b12c5fa11ec904e92be2c4ba18cded54dd7501208fe", size = 457249, upload-time = "2026-08-13T14:14:31.213Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/63/00/bee1bc9faa02a46e7a851019fd23f47ca1f906609edbec8b6ba5decc3cc3/ml_dtypes-0.6.0-cp315-cp315-win_arm64.whl", hash = "sha256:de9d14748dbf3968951436ef514a29c9d1fe438aa680d110134ee2f7a9f9df18", size = 568381, upload-time = "2026-08-13T14:14:32.548Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/72/f7/9a5edede28f73185fd51d75030ef7f11d76997bab3a92427d986e54fe2eb/ml_dtypes-0.6.0-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:e25bb3b0ad1217b60626e4ed45b10ca170c41d99fbe44a12bebc1e07ec4aad55", size = 589877, upload-time = "2026-08-13T14:14:33.695Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fd/81/d5924a141b850b606eb027493c9c3ca3c665cca5163af3f5b6e5e3345503/ml_dtypes-0.6.0-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:31f1ce979d31a357e95aa81812f20412c8c954fa43c44ee3ead1e1c8a78575ef", size = 362788, upload-time = "2026-08-13T14:14:34.996Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/59/8f/3298e3f334832bc28dd144af6b99cdc93502a8687e71922ea68b0a319929/ml_dtypes-0.6.0-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e2d6149f3a57f405bcad5fb41e03218b8373936253f23e1ca84c0108abbc3392", size = 430823, upload-time = "2026-08-13T14:14:36.44Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/93/d2/f2dbf118f42ce4c325a139c9236737f436b7f8e00cd18701c99ef2405e6f/ml_dtypes-0.6.0-cp315-cp315t-win_amd64.whl", hash = "sha256:ce7563e0b1a4482cbc1b4a6272145e54e4489e54fe7428f94908c3d87103abfa", size = 465119, upload-time = "2026-08-13T14:14:37.776Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5a/ff/bda40387b5c5c64254595f4d81a12351770856acc5de4e6d43606a31f161/ml_dtypes-0.6.0-cp315-cp315t-win_arm64.whl", hash = "sha256:f6cb525101b6b903779188c1e9e9490c343b455ab822883e02cf01e5547338d2", size = 572666, upload-time = "2026-08-13T14:14:38.993Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1826,33 +1603,27 @@ dependencies = [
|
||||
]
|
||||
|
||||
[package.optional-dependencies]
|
||||
notebooks = [
|
||||
{ name = "ipykernel" },
|
||||
{ name = "nbclient" },
|
||||
{ name = "nbconvert" },
|
||||
export = [
|
||||
{ name = "onnx" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "apache-hamilton", specifier = ">=1.90" },
|
||||
{ name = "extraction", editable = "../Extraction" },
|
||||
{ name = "ipykernel", marker = "extra == 'notebooks'", specifier = ">=6.29" },
|
||||
{ name = "mlflow", specifier = ">=2.9" },
|
||||
{ name = "nbclient", marker = "extra == 'notebooks'", specifier = ">=0.10" },
|
||||
{ name = "nbconvert", marker = "extra == 'notebooks'", specifier = ">=7.16" },
|
||||
{ name = "onnx", marker = "extra == 'export'", specifier = ">=1.15" },
|
||||
{ name = "pandas", specifier = ">=2.0" },
|
||||
{ name = "pandera", specifier = ">=0.20" },
|
||||
{ name = "persistance", editable = "../Persistance" },
|
||||
{ name = "pyarrow", specifier = ">=15" },
|
||||
{ name = "scikit-learn", specifier = ">=1.4" },
|
||||
]
|
||||
provides-extras = ["notebooks"]
|
||||
provides-extras = ["export"]
|
||||
|
||||
[package.metadata.requires-dev]
|
||||
dev = [
|
||||
{ name = "ipykernel", specifier = ">=6.29" },
|
||||
{ name = "nbclient", specifier = ">=0.10" },
|
||||
{ name = "nbconvert", specifier = ">=7.16" },
|
||||
{ name = "onnx", specifier = ">=1.15" },
|
||||
{ name = "pytest", specifier = ">=8.0.0" },
|
||||
{ name = "reportlab", specifier = ">=4.0" },
|
||||
]
|
||||
@@ -2013,70 +1784,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/89/5d4c86da1130d9059681e5b6cd7645df5c10279a6a079c5c37dcb2cc6f3f/narwhals-2.27.1-py3-none-any.whl", hash = "sha256:d057df13f5852b8e157596e82eb5e955fad267425df5e420e0ee9863da483b31", size = 483211, upload-time = "2026-10-10T06:52:16.32Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nbclient"
|
||||
version = "0.11.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "jupyter-client" },
|
||||
{ name = "jupyter-core" },
|
||||
{ name = "nbformat" },
|
||||
{ name = "traitlets" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/28/a5/b3bae4b590c0cbcada2c63a34f7580024e834a8ba213e949a2f906705787/nbclient-0.11.0.tar.gz", hash = "sha256:04a134a5b087f2c5887f228aca155db50169b8cd9334dee6942c8e927e56081a", size = 62535, upload-time = "2026-06-05T07:52:41.746Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/36/c9/94d73e5a01c5b926c3fa2496e97d7a8dc28ed5a77c0b2ed712f1a62e6694/nbclient-0.11.0-py3-none-any.whl", hash = "sha256:ef7fa0d59d6e1d41103933d8a445a18d5de860ca6b613b87b8574accdb3c2895", size = 25288, upload-time = "2026-06-05T07:52:40.115Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nbconvert"
|
||||
version = "7.17.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "beautifulsoup4" },
|
||||
{ name = "bleach", extra = ["css"] },
|
||||
{ name = "defusedxml" },
|
||||
{ name = "jinja2" },
|
||||
{ name = "jupyter-core" },
|
||||
{ name = "jupyterlab-pygments" },
|
||||
{ name = "markupsafe" },
|
||||
{ name = "mistune" },
|
||||
{ name = "nbclient" },
|
||||
{ name = "nbformat" },
|
||||
{ name = "packaging" },
|
||||
{ name = "pandocfilters" },
|
||||
{ name = "pygments" },
|
||||
{ name = "traitlets" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/53/6a/252c7620305a9661205aed7a2a4b3592f5207bfca56ad11b7dea2c5ec2f6/nbconvert-7.17.2.tar.gz", hash = "sha256:344a218e8595117ce37396ed025d994f146d076226ebac59255a2fa085ab24d8", size = 865989, upload-time = "2026-10-12T09:11:19.583Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/81/fd/a8d457af68848a8e5c12dd1d84ff35c415db471af78280e0703db4efbb12/nbconvert-7.17.2-py3-none-any.whl", hash = "sha256:6a143c11c00bf831604da4b1be4347d36ea52367057eb920135d69bc2862fed2", size = 262094, upload-time = "2026-10-12T09:11:17.215Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nbformat"
|
||||
version = "5.11.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "fastjsonschema" },
|
||||
{ name = "jsonschema" },
|
||||
{ name = "jupyter-core" },
|
||||
{ name = "traitlets" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/31/72/b3446efab8756e7df4b8ec587f8e611cb5a7249e4323db480802f1d3be04/nbformat-5.11.1.tar.gz", hash = "sha256:32d4521c68c6e7d5b29c76defaeed9f42ea733142b9b19f88277ce10390b9c4d", size = 147775, upload-time = "2026-08-17T08:10:51.942Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/1a/69/ee613f74085ca7103f79cd08d579c4f3177d1d26e5d3d9528d2d6536a707/nbformat-5.11.1-py3-none-any.whl", hash = "sha256:cc6698fa75f4fab8755ead786317815f13a6fee3b53311c0abb1a8b51d52f7ec", size = 79849, upload-time = "2026-08-17T08:10:50.18Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nest-asyncio2"
|
||||
version = "1.7.4"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/32/2c/70e3b6bb2189cfd260280b7e1042bd622949a258663f95e887fada4ac1e6/nest_asyncio2-1.7.4.tar.gz", hash = "sha256:995b1409d926ec55e0876ea39a69bffdd8852cf1db3652c177e8c8ffdbcaf3cc", size = 16891, upload-time = "2026-10-07T22:31:50.507Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/09/ed/559d2915dce85794bc0c36064043da170da50cd98746dcbddd85d5932017/nest_asyncio2-1.7.4-py3-none-any.whl", hash = "sha256:86e77b52c3d1496b294af3c944b44213b9b82a12a5ee590c0acc4ca4692ef6c7", size = 8543, upload-time = "2026-10-07T22:31:49.245Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "numpy"
|
||||
version = "2.5.3"
|
||||
@@ -2150,6 +1857,32 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/fb/0b/b12a2df5d1b774bd9007a6fdff9381145b6223d37f11afc9c37ab0efd9a1/numpy-2.5.3-cp315-cp315t-win_arm64.whl", hash = "sha256:befa1ae5bd6030b3f512b43ff3fa5290bbed6b84411a44244b14adf835f5b89d", size = 10850807, upload-time = "2026-09-06T16:27:43.868Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "onnx"
|
||||
version = "1.23.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "ml-dtypes" },
|
||||
{ name = "numpy" },
|
||||
{ name = "protobuf" },
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/3f/62/bc2dfadb63ecf04cb2d65a6b17751863039d36c65de51d6a3128ab35f1e7/onnx-1.23.2.tar.gz", hash = "sha256:008cb0467b2bbee41448acc7da8b6f4e704624cb0d327a2d5adafc7ce19bc5b8", size = 6023090, upload-time = "2026-10-06T04:25:58.681Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d7/d9/967d6f6838ad60964de912a5e7d01915282899b254460705d952f5d14c1a/onnx-1.23.2-cp312-abi3-macosx_13_0_universal2.whl", hash = "sha256:1b8680ce1e6a9a4736374a9dce4de14ea8ee05e0dccf0784a78a6e5646bdc1f6", size = 9725612, upload-time = "2026-10-06T04:25:34.299Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f9/50/2e156ef2cae1c9f4ff01a41dffa43fc1eb7b969755055436bf6df1805d54/onnx-1.23.2-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a203efdbaabbbe8f25e854e2b2921382d6fcf4c67895656f939044b0632974e8", size = 8640515, upload-time = "2026-10-06T04:25:36.727Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/87/56/21509a657f9a73ab0ca307d325043f49ca6c4ff6bf79edeb9e159190d44d/onnx-1.23.2-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7abf381d278f31ac62487fddedc9dd42da842dce94d5d43536836ee3efdf4a2b", size = 8881633, upload-time = "2026-10-06T04:25:38.868Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ec/ef/0a69093ffa0b999747b373c75d07182a812722a0e595d21f763a8d406260/onnx-1.23.2-cp312-abi3-pyemscripten_2026_0_wasm32.whl", hash = "sha256:e79e35e152d3095c6910ae81013bbc68679e32bfc0ca76f840968d4b6fdfb864", size = 7314844, upload-time = "2026-10-06T04:25:41.088Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/97/a3/e4d4aedd0cc6820de416bb99623fc12b9a22a387d00596bb98505de9a805/onnx-1.23.2-cp312-abi3-win32.whl", hash = "sha256:b0b8dae0d33dd8606370bc264b0b1d6e64cfdf8b83d7c676fab8eff6b88ca409", size = 7736405, upload-time = "2026-10-06T04:25:42.893Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/38/ce/102fd4a0b2a6d111a9c86745e084c4c68c0ee020eaa359a03a8d43e4646f/onnx-1.23.2-cp312-abi3-win_amd64.whl", hash = "sha256:9b382ba898a7c142a0801d03cf04ecabced96c1543c7b643a86f0928143802de", size = 7872489, upload-time = "2026-10-06T04:25:44.802Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bd/1d/37f2c7f821f79ceed3c976bd087d16abdd2b0bba6c19475322e7a31bae59/onnx-1.23.2-cp312-abi3-win_arm64.whl", hash = "sha256:80cef0fad59524d02c21ec93f4fbccdcc6223f1c33339d597519a2d27cac19a7", size = 8047076, upload-time = "2026-10-06T04:25:46.93Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5c/26/7a1319a7dd0556180525e573c674fc962ce37bd30dcb54ff9a8a43e8a26f/onnx-1.23.2-cp314-cp314t-macosx_13_0_universal2.whl", hash = "sha256:b2c07abb24f1c2c50ff5996c567eb9757470827f6d55b7f0af9d62c8e658bd7f", size = 9731174, upload-time = "2026-10-06T04:25:48.796Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ed/38/cbc9c5a72dbbc9d20f17e6855c643a2105053f756784cb167f69915c486d/onnx-1.23.2-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:32fd9c92244c2aea2b2c9e0e7b18fedcf6000434124ab6fc8796e22baa602d30", size = 8647447, upload-time = "2026-10-06T04:25:50.901Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2f/24/36c505c2f8079186ac7c2d858a7fda3c5591418ae92d134e2bf56f6eee1f/onnx-1.23.2-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:77674dc4fda2bde9a13aee67fb9ff658080159eb516d3a5b3fb2418d44dc70be", size = 8886676, upload-time = "2026-10-06T04:25:52.852Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/db/1f/d30025c6ef40c0e42977c933aceba59ca2f5e3ab8b72673136f99c70268e/onnx-1.23.2-cp314-cp314t-win_amd64.whl", hash = "sha256:16ef247e51dbf42e32bd92f47ad772d17dda77f64c4017e0ded9725ff9ab3922", size = 7910684, upload-time = "2026-10-06T04:25:55.135Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/69/84/7bbd40fc36f701968351b4f4c14de5bde61ba8f75b88f93b23d013f32f3d/onnx-1.23.2-cp314-cp314t-win_arm64.whl", hash = "sha256:1e6cbca3d808f811141ed0a0939e71b3a6c9fdefb2435f4a862ec776336718fe", size = 8089708, upload-time = "2026-10-06T04:25:56.893Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openpyxl"
|
||||
version = "3.1.5"
|
||||
@@ -2300,24 +2033,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d2/84/107a480f7aa34a6878fb4fb85cda66f37e8aaee769c5917e3eaa2d55222e/pandera-0.33.1-py3-none-any.whl", hash = "sha256:8283bc12f7c85f0b429107d71b55150205f7e5ca59d68117aff971273a3bd2d8", size = 501976, upload-time = "2026-09-01T15:56:05.944Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pandocfilters"
|
||||
version = "1.5.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/70/6f/3dd4940bbe001c06a65f88e36bad298bc7a0de5036115639926b0c5c0458/pandocfilters-1.5.1.tar.gz", hash = "sha256:002b4a555ee4ebc03f8b66307e287fa492e4a77b4ea14d3f934328297bb4939e", size = 8454, upload-time = "2024-01-18T20:08:13.726Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/ef/af/4fbc8cab944db5d21b7e2a5b8e9211a03a79852b1157e2c102fcc61ac440/pandocfilters-1.5.1-py2.py3-none-any.whl", hash = "sha256:93be382804a9cdb0a7267585f157e5d1731bbe5545a85b268d6f5fe6232de2bc", size = 8663, upload-time = "2024-01-18T20:08:11.28Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parso"
|
||||
version = "0.8.7"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/30/4b/90c937815137d43ce71ba043cd3566221e9df6b9c805f24b5d138c9d40a7/parso-0.8.7.tar.gz", hash = "sha256:eaaac4c9fdd5e9e8852dc778d2d7405897ec510f2a298071453e5e3a07914bb1", size = 401824, upload-time = "2026-05-01T23:13:02.138Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/99/5d/8268b644392ee874ee82a635cd0df1773de230bde356c38de28e298392cc/parso-0.8.7-py2.py3-none-any.whl", hash = "sha256:a8926eb2a1b915486941fdbd31e86a4baf88fe8c210f25f2f35ecec5b574ca1c", size = 107025, upload-time = "2026-05-01T23:12:58.867Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pdfminer-six"
|
||||
version = "20260107"
|
||||
@@ -2374,18 +2089,6 @@ dev = [
|
||||
{ name = "pytest", specifier = ">=8.0.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pexpect"
|
||||
version = "4.9.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "ptyprocess" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/42/92/cc564bf6381ff43ce1f4d06852fc19a2f11d180f23dc32d9588bee2f149d/pexpect-4.9.0.tar.gz", hash = "sha256:ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f", size = 166450, upload-time = "2023-11-25T09:07:26.339Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/9e/c3/059298687310d527a58bb01f3b1965787ee3b40dce76752eda8b44e9a2c5/pexpect-4.9.0-py2.py3-none-any.whl", hash = "sha256:7236d1e080e4936be2dc3e326cec0af72acf9212a7e1d060210e70a47e253523", size = 63772, upload-time = "2023-11-25T06:56:14.81Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pillow"
|
||||
version = "12.3.0"
|
||||
@@ -2501,18 +2204,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/fe/be/2e6798ace5cc036f5d05d36b7b2fd85346f1a708c87060890b070d0ec607/prettytable-3.18.0-py3-none-any.whl", hash = "sha256:b3346e0e6f79180833aebaac088ae926340586cf6d7d991b9eb125b65f72313a", size = 37357, upload-time = "2026-06-22T16:07:48.595Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prompt-toolkit"
|
||||
version = "3.0.53"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "wcwidth" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/7d/ea/39b988c938f75cb75d7045b5c69f8bfed47ee2152c8837fb403de29d6fb8/prompt_toolkit-3.0.53.tar.gz", hash = "sha256:9ec8a0ad96d5c56148b3f914aa79c1564c3fde5d2e6b876e7bc327e353cf8fa6", size = 435492, upload-time = "2026-07-26T20:56:14.758Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/54/6f/84908cad2d6aa5144abcf7b42709fe4fdb459bc640ec7ac5786e7693dabc/prompt_toolkit-3.0.53-py3-none-any.whl", hash = "sha256:01c0891d7f9237d5e339f7d3e42cdae80b7534abb1c7c0e3352efba6231492f2", size = 392288, upload-time = "2026-07-26T20:56:12.512Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "propcache"
|
||||
version = "0.5.4"
|
||||
@@ -2639,34 +2330,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/e4/04/d52c7016b04b6c5108f26691f9d33ec82a9b65d041f1a9c771137693d618/protobuf-7.36.2-py3-none-any.whl", hash = "sha256:bdb3a345d48db958e6ce1f18e508beb0cc981d64f24088427549c866cd039f1e", size = 179806, upload-time = "2026-09-17T20:07:58.211Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "psutil"
|
||||
version = "7.2.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/aa/c6/d1ddf4abb55e93cebc4f2ed8b5d6dbad109ecb8d63748dd2b20ab5e57ebe/psutil-7.2.2.tar.gz", hash = "sha256:0746f5f8d406af344fd547f1c8daa5f5c33dbc293bb8d6a16d80b4bb88f59372", size = 493740, upload-time = "2026-01-28T18:14:54.428Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/51/08/510cbdb69c25a96f4ae523f733cdc963ae654904e8db864c07585ef99875/psutil-7.2.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:2edccc433cbfa046b980b0df0171cd25bcaeb3a68fe9022db0979e7aa74a826b", size = 130595, upload-time = "2026-01-28T18:14:57.293Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d6/f5/97baea3fe7a5a9af7436301f85490905379b1c6f2dd51fe3ecf24b4c5fbf/psutil-7.2.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:e78c8603dcd9a04c7364f1a3e670cea95d51ee865e4efb3556a3a63adef958ea", size = 131082, upload-time = "2026-01-28T18:14:59.732Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/37/d6/246513fbf9fa174af531f28412297dd05241d97a75911ac8febefa1a53c6/psutil-7.2.2-cp313-cp313t-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1a571f2330c966c62aeda00dd24620425d4b0cc86881c89861fbc04549e5dc63", size = 181476, upload-time = "2026-01-28T18:15:01.884Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b8/b5/9182c9af3836cca61696dabe4fd1304e17bc56cb62f17439e1154f225dd3/psutil-7.2.2-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:917e891983ca3c1887b4ef36447b1e0873e70c933afc831c6b6da078ba474312", size = 184062, upload-time = "2026-01-28T18:15:04.436Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/16/ba/0756dca669f5a9300d0cbcbfae9a4c30e446dfc7440ffe43ded5724bfd93/psutil-7.2.2-cp313-cp313t-win_amd64.whl", hash = "sha256:ab486563df44c17f5173621c7b198955bd6b613fb87c71c161f827d3fb149a9b", size = 139893, upload-time = "2026-01-28T18:15:06.378Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1c/61/8fa0e26f33623b49949346de05ec1ddaad02ed8ba64af45f40a147dbfa97/psutil-7.2.2-cp313-cp313t-win_arm64.whl", hash = "sha256:ae0aefdd8796a7737eccea863f80f81e468a1e4cf14d926bd9b6f5f2d5f90ca9", size = 135589, upload-time = "2026-01-28T18:15:08.03Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/81/69/ef179ab5ca24f32acc1dac0c247fd6a13b501fd5534dbae0e05a1c48b66d/psutil-7.2.2-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:eed63d3b4d62449571547b60578c5b2c4bcccc5387148db46e0c2313dad0ee00", size = 130664, upload-time = "2026-01-28T18:15:09.469Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7b/64/665248b557a236d3fa9efc378d60d95ef56dd0a490c2cd37dafc7660d4a9/psutil-7.2.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:7b6d09433a10592ce39b13d7be5a54fbac1d1228ed29abc880fb23df7cb694c9", size = 131087, upload-time = "2026-01-28T18:15:11.724Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d5/2e/e6782744700d6759ebce3043dcfa661fb61e2fb752b91cdeae9af12c2178/psutil-7.2.2-cp314-cp314t-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1fa4ecf83bcdf6e6c8f4449aff98eefb5d0604bf88cb883d7da3d8d2d909546a", size = 182383, upload-time = "2026-01-28T18:15:13.445Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/57/49/0a41cefd10cb7505cdc04dab3eacf24c0c2cb158a998b8c7b1d27ee2c1f5/psutil-7.2.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e452c464a02e7dc7822a05d25db4cde564444a67e58539a00f929c51eddda0cf", size = 185210, upload-time = "2026-01-28T18:15:16.002Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/dd/2c/ff9bfb544f283ba5f83ba725a3c5fec6d6b10b8f27ac1dc641c473dc390d/psutil-7.2.2-cp314-cp314t-win_amd64.whl", hash = "sha256:c7663d4e37f13e884d13994247449e9f8f574bc4655d509c3b95e9ec9e2b9dc1", size = 141228, upload-time = "2026-01-28T18:15:18.385Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f2/fc/f8d9c31db14fcec13748d373e668bc3bed94d9077dbc17fb0eebc073233c/psutil-7.2.2-cp314-cp314t-win_arm64.whl", hash = "sha256:11fe5a4f613759764e79c65cf11ebdf26e33d6dd34336f8a337aa2996d71c841", size = 136284, upload-time = "2026-01-28T18:15:19.912Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e7/36/5ee6e05c9bd427237b11b3937ad82bb8ad2752d72c6969314590dd0c2f6e/psutil-7.2.2-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:ed0cace939114f62738d808fdcecd4c869222507e266e574799e9c0faa17d486", size = 129090, upload-time = "2026-01-28T18:15:22.168Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/80/c4/f5af4c1ca8c1eeb2e92ccca14ce8effdeec651d5ab6053c589b074eda6e1/psutil-7.2.2-cp36-abi3-macosx_11_0_arm64.whl", hash = "sha256:1a7b04c10f32cc88ab39cbf606e117fd74721c831c98a27dc04578deb0c16979", size = 129859, upload-time = "2026-01-28T18:15:23.795Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b5/70/5d8df3b09e25bce090399cf48e452d25c935ab72dad19406c77f4e828045/psutil-7.2.2-cp36-abi3-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:076a2d2f923fd4821644f5ba89f059523da90dc9014e85f8e45a5774ca5bc6f9", size = 155560, upload-time = "2026-01-28T18:15:25.976Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/63/65/37648c0c158dc222aba51c089eb3bdfa238e621674dc42d48706e639204f/psutil-7.2.2-cp36-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b0726cecd84f9474419d67252add4ac0cd9811b04d61123054b9fb6f57df6e9e", size = 156997, upload-time = "2026-01-28T18:15:27.794Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8e/13/125093eadae863ce03c6ffdbae9929430d116a246ef69866dad94da3bfbc/psutil-7.2.2-cp36-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:fd04ef36b4a6d599bbdb225dd1d3f51e00105f6d48a28f006da7f9822f2606d8", size = 148972, upload-time = "2026-01-28T18:15:29.342Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/04/78/0acd37ca84ce3ddffaa92ef0f571e073faa6d8ff1f0559ab1272188ea2be/psutil-7.2.2-cp36-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:b58fabe35e80b264a4e3bb23e6b96f9e45a3df7fb7eed419ac0e5947c61e47cc", size = 148266, upload-time = "2026-01-28T18:15:31.597Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b4/90/e2159492b5426be0c1fef7acba807a03511f97c5f86b3caeda6ad92351a7/psutil-7.2.2-cp37-abi3-win_amd64.whl", hash = "sha256:eb7e81434c8d223ec4a219b5fc1c47d0417b12be7ea866e24fb5ad6e84b3d988", size = 137737, upload-time = "2026-01-28T18:15:33.849Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8c/c7/7bb2e321574b10df20cbde462a94e2b71d05f9bbda251ef27d104668306a/psutil-7.2.2-cp37-abi3-win_arm64.whl", hash = "sha256:8c233660f575a5a89e6d4cb65d9f938126312bca76d8fe087b947b3a1aaac9ee", size = 134617, upload-time = "2026-01-28T18:15:36.514Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "psycopg2-binary"
|
||||
version = "2.9.13"
|
||||
@@ -2719,24 +2382,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/e8/30/3991c9fdcca90a5a1e55435292f4d74d176da2be15f3998f6858da3658cc/psycopg2_binary-2.9.13-cp315-cp315-win_amd64.whl", hash = "sha256:1752b9821f1377404d65ac43af03d59a1eccc57fb2c1eb8305f9a3fe8eb7a8ba", size = 2867246, upload-time = "2026-09-09T23:56:20.501Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ptyprocess"
|
||||
version = "0.7.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/20/e5/16ff212c1e452235a90aeb09066144d0c5a6a8c0834397e03f5224495c4e/ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220", size = 70762, upload-time = "2020-12-28T15:15:30.155Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/22/a6/858897256d0deac81a172289110f31629fc4cee19b6f01283303e18c8db3/ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35", size = 13993, upload-time = "2020-12-28T15:15:28.35Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pure-eval"
|
||||
version = "0.2.4"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/da/9f/abfd2959e9261dd5217ca8551d4de211ca6ab26fe9b72cf44731ff6c4442/pure_eval-0.2.4.tar.gz", hash = "sha256:260c2774686e651b79f8b8e7fc9d80b3599ea6a66334b47d5f4abb69fc2c0ea1", size = 20563, upload-time = "2026-09-10T21:41:22.836Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/6d/18/83376915176eb058cb86470eb7396388a13350b09a8f233a79303bbcbc5b/pure_eval-0.2.4-py3-none-any.whl", hash = "sha256:96cae060a313cfaad51bb761278bfb0e62dc0248d9315a81173752dc546cd37a", size = 11893, upload-time = "2026-09-10T21:41:21.532Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyarrow"
|
||||
version = "25.0.1"
|
||||
@@ -3128,60 +2773,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/f1/12/de94a39c2ef588c7e6455cfbe7343d3b2dc9d6b6b2f40c4c6565744c873d/pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b", size = 149341, upload-time = "2025-09-25T21:32:56.828Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyzmq"
|
||||
version = "27.3.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "cffi", marker = "implementation_name == 'pypy'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/e2/e1/ea46ab0d707219c098065a37d2add5b53d3b124241aa19429bcd0863e5b4/pyzmq-27.3.0.tar.gz", hash = "sha256:bbedb3d1d99babc625f1dd9d7438acefd442b36b75073fd6bc1ef7c0a4b96d56", size = 293249, upload-time = "2026-11-04T00:31:33.068Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/b5/9e/6663ccc8c1af4e7db85de65921560a8058ad4ad4c40ebc49af4b1164f01a/pyzmq-27.3.0-cp312-abi3-macosx_10_15_universal2.whl", hash = "sha256:15155fd8f308d3bd47f67a8f6cc809f9db90abbf63c514c384a17622e2cf080f", size = 1232964, upload-time = "2026-11-04T00:29:09.922Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b4/90/4fc65d7a48077f535705ac957c29a3c07fa54a1f8d2595ca2f5f1489b21c/pyzmq-27.3.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ad8b828407caee77ff3ab0bdb2984ee8d48922328b226e8fda7c84a71a55dbb4", size = 770405, upload-time = "2026-11-04T00:29:11.487Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2c/62/e4721d8b8b9de685323717489a408521067a786cabc2b73ccd91aa9b9077/pyzmq-27.3.0-cp312-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:858fe25231e0fd8612da142efde019faa5ef63fa150a821a27870e791b38c798", size = 855178, upload-time = "2026-11-04T00:29:13.042Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/39/5f/8190ff273beb195d9c9b62a36d0d87bad79019e76ff4407cabe463bc650d/pyzmq-27.3.0-cp312-abi3-manylinux_2_28_i686.whl", hash = "sha256:8b174298b57d5c2397c74fbefd656101d477357035916881970ed5f53b7b904c", size = 919158, upload-time = "2026-11-04T00:29:14.854Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8f/66/ab116baad852235c82be3d8d83af7098a7165c48995a03f2b6e8d50297dc/pyzmq-27.3.0-cp312-abi3-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:cffd75359342ef88c86c287c99b16b2b100795dab467fd5398bcedd87d49bce7", size = 813613, upload-time = "2026-11-04T00:29:17.239Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b3/55/5075ef84055eca159435e65f8d67591bfe06c562cf310792cd50a6aeb0c9/pyzmq-27.3.0-cp312-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:220095b4c11b0542ae5c0d67411331d3819753ee9ec0468e63a4ca6fd4ccf50f", size = 1762126, upload-time = "2026-11-04T00:29:18.994Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/28/6f/e75d5e5aeda920dbcaaedcc413605379287b817578d00e47bfa89a8ea671/pyzmq-27.3.0-cp312-abi3-musllinux_1_2_i686.whl", hash = "sha256:e9e12fe784529e12177937aee8c714b7aed8913a2429ee2567400c904d4d55b5", size = 2067522, upload-time = "2026-11-04T00:29:20.762Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9c/b4/0d91b1e5ea8d659c1014ef39acfda279f4768fc4043120e98b764a59f1c9/pyzmq-27.3.0-cp312-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:d317685b83663fbd03ca8b5c34add7463e9bed094e3e1a69d2a895130b64ffaf", size = 1893864, upload-time = "2026-11-04T00:29:22.451Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2a/23/ed213d9dc6e48913a1f77090d1aed85bc4b1e5567ef74a86fd8fd473f423/pyzmq-27.3.0-cp312-abi3-win32.whl", hash = "sha256:07dd778d7cf242a1e131bfad6244f64df59441dda7ea639d037d0fdb22112b6c", size = 567172, upload-time = "2026-11-04T00:29:24.09Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fa/6d/23a02024011a494fb52bcfb179f10a3b230cff7b6fe0d5b8a3c775ce3b82/pyzmq-27.3.0-cp312-abi3-win_amd64.whl", hash = "sha256:3ea8e8fa5c097e68fef91d70b150fda96f307758103868018fc4deeb9c214122", size = 642389, upload-time = "2026-11-04T00:29:25.739Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e2/1b/410fc7ec4fc114b46da17ed0df3b88606f0624fbe172e184658d361b1dc1/pyzmq-27.3.0-cp312-abi3-win_arm64.whl", hash = "sha256:2187a5ca80691a5edb30690f02d9fb714e2c32d3dfdeb652e159ff5da2dd4283", size = 570810, upload-time = "2026-11-04T00:29:27.709Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/0f/81652a1066e994000cfec501f16137fa231e921675b63ee54c8cf4e30362/pyzmq-27.3.0-cp313-cp313-android_24_arm64_v8a.whl", hash = "sha256:a418d35be0a0a2693bf1990d831a744ee2f012b8268b3e0c6cb28b06c2769d76", size = 1136520, upload-time = "2026-11-04T00:29:29.58Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ce/0e/a2e5cb7db327ce85f3c2d11f25be55aba1639f55dad8ea77e03458ec5dbf/pyzmq-27.3.0-cp313-cp313-android_24_x86_64.whl", hash = "sha256:e9012762d869d620dad3c83fb5ff8f4900490decddd98caf6ff80847176c4be0", size = 1181427, upload-time = "2026-11-04T00:29:31.178Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/88/b8/8a80749971b1a42fc415c720a52deedd33d0ae72792544331fc76f306ded/pyzmq-27.3.0-cp314-cp314-android_24_arm64_v8a.whl", hash = "sha256:fca5c2352c499e8355b581ddecfe52538984131b7efc052a30e2d32426baf637", size = 1143753, upload-time = "2026-11-04T00:29:32.923Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/59/2d/196f50920da3137fd54b1636c36aba97b95d18d467bf097edca5f6ef5be8/pyzmq-27.3.0-cp314-cp314-android_24_x86_64.whl", hash = "sha256:91ac316f440aca4e6eaf3786f54b80f4ab433e5cc4e5e9b82eb44a27c5c987cd", size = 1182341, upload-time = "2026-11-04T00:29:35.073Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c7/3f/bf2a67da7cfac3c1f85c0130b8bd1fc48e96c1e66e8a50c71faea83979b3/pyzmq-27.3.0-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:d292cedc7250db240e9f41994cf3eefe2c7606c702ef5c56aab8d4f03870108c", size = 1271939, upload-time = "2026-11-04T00:29:36.803Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f6/43/2bfa60b57b3febd892d5760c811012b6850306962e3dd6a2f91b96cd5398/pyzmq-27.3.0-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:924f870055c05926887157485efe903c8f9668d0f3f19d56df7612bcb3d662cb", size = 779903, upload-time = "2026-11-04T00:29:38.52Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e3/72/4f88cd0d1da0e5db9a26a899e37f8b46d925f328f9bae590f86fc995074b/pyzmq-27.3.0-cp314-cp314t-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6dac496cd8aacf185a634e5cc8930331db1627dd214a58ee4c27948ce4ae79af", size = 864708, upload-time = "2026-11-04T00:29:50.209Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/79/5e/fce842845aad4135a2e1936f3cd1a418b4f49e2d45cd7b5576d6f836d95b/pyzmq-27.3.0-cp314-cp314t-manylinux_2_28_i686.whl", hash = "sha256:665b1a3d35a4ffe6cfa626191a5439108159d51d17bd9d44f1beb1690114adfc", size = 927234, upload-time = "2026-11-04T00:29:52.003Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e1/28/945736083a00750e101c4259312b5303aead36ef08539a0f0ad93a1cb899/pyzmq-27.3.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:0fedab58520a5091ffa62547eb507bea44882ce72d49929fa9626061ae1b9a2c", size = 1771921, upload-time = "2026-11-04T00:29:53.677Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3d/30/2a584e845a51c0e5d6e13889fe659aa90912004fbb5bc4750491f558528c/pyzmq-27.3.0-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:1b9b9d11e2e775a81d0e8b5c6cb76a395ddaa7c6b6373f3b0d2c8f8146d95f4a", size = 2075396, upload-time = "2026-11-04T00:29:55.772Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4e/6b/93066f121c31b825c56c74dca01ea5c00847f8b44645ad990f92bd04d29c/pyzmq-27.3.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:169a522c4d166c3bc7b67ed827d3beda549a8e65c4015c9410687757fb39852f", size = 1903986, upload-time = "2026-11-04T00:29:57.741Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/85/ae/ecc7c77cd6ea18ff7b2b07a2fd0db5c31c2204ecf9a774e80bd1250dc9d9/pyzmq-27.3.0-cp314-cp314t-win32.whl", hash = "sha256:0228fe121f05a8b638ef218dde7508477a8c46200a588f71ce7143d85987cdd7", size = 597206, upload-time = "2026-11-04T00:29:59.35Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7a/1d/0bee73e1e8ab1c26eecba13a4725dfbe0405b53f451a91671dd515effe00/pyzmq-27.3.0-cp314-cp314t-win_amd64.whl", hash = "sha256:8a3d02fc710302a23c9a67b287bc13f2992067d398c3192b50eb0e30d44ed885", size = 685132, upload-time = "2026-11-04T00:30:01.144Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cd/23/13a768f9a8e66a999250abd216e50e1961a1cd4a8708749f656f5c0c2aea/pyzmq-27.3.0-cp314-cp314t-win_arm64.whl", hash = "sha256:2b9f08778b608fe4f6250e2d132f41b4f99fa8d03051cf2809b1c0420def81b4", size = 595549, upload-time = "2026-11-04T00:30:02.693Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/91/ac/674d5c512c196c3ff2c37b27ce87764e9e69c7591902ef48330ff0ebfc07/pyzmq-27.3.0-cp315-cp315-android_24_arm64_v8a.whl", hash = "sha256:81fcd4e798f384a158b1790171a63541e66ccdee5a139a4dd0848a6e88dc7b9e", size = 1143291, upload-time = "2026-11-04T00:30:04.411Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c1/eb/6bf15cb88fb5d9f8fe6ee6b57185c110f862b6bc1ad02772767571bd3c5c/pyzmq-27.3.0-cp315-cp315-android_24_x86_64.whl", hash = "sha256:e9b87a6f40b62c7cd47691fc2ba4fdc28bef58f5fccf48eaf39940d183d2a16c", size = 1181899, upload-time = "2026-11-04T00:30:05.993Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2c/bc/e00cf032d751a709e12d71c3e2e265957bfb0097d8d071fae4f6a45e2d4c/pyzmq-27.3.0-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:23ddfe5d4d0c6ea529614c8999065d609a113f343c7e60dda9746d7dcb00d766", size = 1270101, upload-time = "2026-11-04T00:30:07.977Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/20/aa/87ebb4664bb27fa53382d45f21f9f49d6194c0eb6737d7c2c5d5e921f1ee/pyzmq-27.3.0-cp315-cp315t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b437cf437fe737e17082625f470258f12e4bf5d56edfb88cb21d3aa4089fcef9", size = 779378, upload-time = "2026-11-04T00:30:10.504Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c1/85/e998ff27a29aca9b0f8529e32b0913420e75f8f990a54ad9434faa3d4c5e/pyzmq-27.3.0-cp315-cp315t-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bc2cc98f37a14a3c9baccc18173a9fca9c6d18ffb233bca7079e58b2e47ee7f8", size = 864317, upload-time = "2026-11-04T00:30:12.259Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d6/7a/6535a0b2fbde9554291caeb3c41b6452207ed7afeb910af830f48e6731f5/pyzmq-27.3.0-cp315-cp315t-manylinux_2_28_i686.whl", hash = "sha256:1a1e092726596141e8ad2cc7f542fd366ddd692b8a9e254d2972ac47b399b982", size = 926240, upload-time = "2026-11-04T00:30:13.862Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/51/6f/0c3b1b621f17ebd3eaa2c974b11507dc88cef529ebdc72b42935d00e4a90/pyzmq-27.3.0-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:0c9c332883373eb85b72f4d912a9a4402ba7702709fa783d3c76ff2bd703a491", size = 1771499, upload-time = "2026-11-04T00:30:15.471Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e1/a5/b753eb9acc131fbb4da67c4c68037965f12f8782d1fd5e461e803e0a1dc1/pyzmq-27.3.0-cp315-cp315t-musllinux_1_2_i686.whl", hash = "sha256:1f724caa222b1ae3c48f7d25147c816c8bde56fb109c164a650f0502b9005ab6", size = 2074632, upload-time = "2026-11-04T00:30:17.149Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/ad/8bce8d0ff0f0cc0958bdfeebbde9ee319cbd025c949607ab2864df657ce6/pyzmq-27.3.0-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:129ca693e543940527e105144dcacdf9e0ec01d41421098e08893de8227aca58", size = 1903559, upload-time = "2026-11-04T00:30:19.142Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fd/25/e5b3e6a066b59840cdc0ea6de8244b1a50b5f237edc7b7adc0e085973708/pyzmq-27.3.0-cp315-cp315t-win32.whl", hash = "sha256:39b9ff1fbab854ccbc53da0e79cb6b78b61b470fb7c191b89aa034825ea9a883", size = 596443, upload-time = "2026-11-04T00:30:20.811Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3f/c8/20ecc504500aeaab0440a4c8487a3c1cd32f4ac38f3e92482f1671fcaeca/pyzmq-27.3.0-cp315-cp315t-win_amd64.whl", hash = "sha256:3b850eaa955ae7edb926fe266600e57da818255d1f6ee9c3d8049967aa4a22cc", size = 684767, upload-time = "2026-11-04T00:30:22.784Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e8/5d/33c528d9b7ee074d0807e3af1a23a3e50bfdbe28cbc178e99f0466c13648/pyzmq-27.3.0-cp315-cp315t-win_arm64.whl", hash = "sha256:f0b9d192b285a9d38e390e762011f2672432742a301859b6c8cb4fab5f10f687", size = 594143, upload-time = "2026-11-04T00:30:24.33Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/53/53/6ea90b8bb4c77bcc4babd15ef6a63ed243cfd47920cb270da5f29438d11f/pyzmq-27.3.0-pp312-pypy312_pp80-macosx_10_15_x86_64.whl", hash = "sha256:cff2031014f79b213818b6773253cbf330119c93de33ee1a635596f407da5c35", size = 689536, upload-time = "2026-11-04T00:31:12.423Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a1/9e/699898cdd86e4cd4bc20547b9f1bce24c58900f51e6a9d5fad03c2890407/pyzmq-27.3.0-pp312-pypy312_pp80-macosx_11_0_arm64.whl", hash = "sha256:18da98ce26045ef503b42a3f98fc2a2af0cdb2af87dc0594852fa5cea3795427", size = 632027, upload-time = "2026-11-04T00:31:14.338Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a6/59/5d6ccce5456cafbdf84c98141d3ddf6c073716eb7b958254349e047fad84/pyzmq-27.3.0-pp312-pypy312_pp80-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:13c7336a4112d3e09c5d78d17e17af1cd01da858ec1c5e3755b2d06339aa7d4f", size = 684300, upload-time = "2026-11-04T00:31:15.891Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b4/37/c4cf124d820495c5549b3f606b1292949c9e2053467309a7e1baaf0c3784/pyzmq-27.3.0-pp312-pypy312_pp80-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:51e1358fabf41920d69cab170495b6e263680797ac5b80ace1b5cf1eb2d89642", size = 761485, upload-time = "2026-11-04T00:31:17.817Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a7/cf/caa0bd5f7a1b139b9240faf3b34586867656f682774364101572e8e84f80/pyzmq-27.3.0-pp312-pypy312_pp80-manylinux_2_28_i686.whl", hash = "sha256:cdb5efd4c23465573e928fb8429e40996ac0e1a4809365efe19e2753112b6ee1", size = 821382, upload-time = "2026-11-04T00:31:19.451Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8e/34/81fa1d9701024eb4f48949ba5f93da3a063ab997e0e0c9787ff37f11ecda/pyzmq-27.3.0-pp312-pypy312_pp80-win_amd64.whl", hash = "sha256:1b7ab96158dd50d7e6e430e6e4f744aaccee1df2e9d167ace9e7d2f3e3051712", size = 564187, upload-time = "2026-11-04T00:31:21.486Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rapidfuzz"
|
||||
version = "3.14.6"
|
||||
@@ -3272,20 +2863,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/fb/04/a0b0e6324b6384d1ab40feb4d16400af3b3101d38cbd15957edd9d17cbe0/rapidfuzz-3.14.6-cp315-cp315t-win_arm64.whl", hash = "sha256:07c7aa0b1e4b9999a54f9e73317d6743ff85442c8ef7b7fbbe6b190fd37d9e75", size = 1243815, upload-time = "2026-08-30T21:45:31.187Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "referencing"
|
||||
version = "0.37.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "attrs" },
|
||||
{ name = "rpds-py" },
|
||||
{ name = "typing-extensions", marker = "python_full_version < '3.13'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/22/f5/df4e9027acead3ecc63e50fe1e36aca1523e1719559c499951bb4b53188f/referencing-0.37.0.tar.gz", hash = "sha256:44aefc3142c5b842538163acb373e24cce6632bd54bdb01b21ad5863489f50d8", size = 78036, upload-time = "2025-10-13T15:30:48.871Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/2c/58/ca301544e1fa93ed4f80d724bf5b194f6e4b945841c5bfd555878eea9fcb/referencing-0.37.0-py3-none-any.whl", hash = "sha256:381329a9f99628c9069361716891d34ad94af76e461dcb0335825aecc7692231", size = 26766, upload-time = "2025-10-13T15:30:47.625Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reportlab"
|
||||
version = "5.0.1"
|
||||
@@ -3314,114 +2891,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/a0/f4/c67b0b3f1b9245e8d266f0f112c500d50e5b4e83cb6f3b71b6528104182a/requests-2.34.2-py3-none-any.whl", hash = "sha256:2a0d60c172f83ac6ab31e4554906c0f3b3588d37b5cb939b1c061f4907e278e0", size = 73075, upload-time = "2026-05-14T19:25:26.443Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rpds-py"
|
||||
version = "2026.9.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/42/68/3bd46b8a5e01d3c2ebdf9c5e9497912e3fe0cde02bac21a7130ca866e403/rpds_py-2026.9.1.tar.gz", hash = "sha256:4793ef7f78268b124b73fa933440f01d258bbae01de9fa53e9080c9ab0425a12", size = 63948, upload-time = "2026-10-04T16:32:36.469Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/5d/34/a828586ea3329fbb50895b50e9cf98ca3d924a9f41a0b26d443bff1b3794/rpds_py-2026.9.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:50906f5aea24b5a865cbd0a589698288631d9f3a54c3a937c83aefa95a0d14af", size = 346822, upload-time = "2026-10-04T16:29:16.258Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/90/81/ac6a0d064982251856ce009c9e1dd51a34110b3c055aa7d1aad18b4899a3/rpds_py-2026.9.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:e21c1429e205828ea886a2293a4a2c8e01f4c25d9893ca330e97a6cf73f52e7b", size = 341380, upload-time = "2026-10-04T16:29:17.706Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/42/ff/bf7d54f362748fd6a49277b9d6531c394074110fedf50ad791ec59133fbb/rpds_py-2026.9.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2693b2728bbcc48d09a981a356954b0c47c53ff25b545856f28a889ea619f69a", size = 373053, upload-time = "2026-10-04T16:29:19.063Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/60/de/74b0ccdbbd28687b9b5fdb34c1cabed88352182facaced9d6f5486b8b9ed/rpds_py-2026.9.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8601470267d938bcb7f3ab1a336100af51a4fd5b6ed030ef52461bb3ef5e7e07", size = 377742, upload-time = "2026-10-04T16:29:20.543Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c2/6d/b979775a3057b2a5c26d75ecbff60a20a24ef081db6dd76836fca3f20247/rpds_py-2026.9.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3890a6aa36e6baa53d5258a2a25d3ef8b37ad165a6ab27a892d7c3e3a432cd69", size = 487289, upload-time = "2026-10-04T16:29:21.958Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1d/5d/7c34734ce3ece943d9d6ee0122a74a21bbc75b47acb5b7053c83f6efb1ed/rpds_py-2026.9.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6b5b393eda5ea42cca1c1a6665f2a4882b4fd5d1777e41ce0545a107fb008c9d", size = 390710, upload-time = "2026-10-04T16:29:23.378Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1d/6d/b26eb1e75395925b3a142ed351cbed2ec8212f5c9d937aee3df32c701baa/rpds_py-2026.9.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:addeda51556dac7c1a2f14cda62db8b621cd12afba3091d03a96c72932387eab", size = 371261, upload-time = "2026-10-04T16:29:25.1Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7c/98/b2fdfe10301a9e27af21e634337fbba7baac0bc17fe44619a17c26bba2cb/rpds_py-2026.9.1-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:d9edf30457d74eebfd76b045535e36f1cd89062566a128a0db2145ca042d787e", size = 376075, upload-time = "2026-10-04T16:29:26.748Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c5/b1/c4b8d954e49c3c69cf8063c0c9e0919c99f3d2cecc46311606a1cbe835dc/rpds_py-2026.9.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:815d26356930846a40c7bc1366e7b1b0320ab8a063e66c11298a208bed0fd237", size = 399358, upload-time = "2026-10-04T16:29:28.282Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b3/59/9559a7293c97dff0cbb293efffbd36644103883ecc27741af8ef90c84ca8/rpds_py-2026.9.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:3b5a6f40f0a1486b4b36c888123afc67acdbd9f33235927acf5ff295429a0ba3", size = 550267, upload-time = "2026-10-04T16:29:29.851Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6c/9d/6dc60e49511de4c8b00e74f9c1d43aed4d27f712cdb1ade92f2c199cbf64/rpds_py-2026.9.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:b5b8b0753718d258fd454283fbd57e14545d3b40583fa672e27cb4f987626bcc", size = 614018, upload-time = "2026-10-04T16:29:31.54Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fb/bc/92a4ecf27301b886232a413360f6b348a81d55ffef654f2ebda5970ebc3d/rpds_py-2026.9.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:46d80bc76b51a6c24f9944368c28d38b8bcbcea1da4f2f8d3ebc31a67e8c6ec6", size = 578509, upload-time = "2026-10-04T16:29:33.01Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/08/53/efb97f2e6589b7ab8394385a73870e0b2ab2a195281c117b21fd6d7d4855/rpds_py-2026.9.1-cp312-cp312-win32.whl", hash = "sha256:befc2d6a953e563f8a7bfd87a42c22ebf8a3e980dcb7b6a4d17b70b0e914e8a3", size = 205401, upload-time = "2026-10-04T16:29:34.451Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1c/84/1700cc748d0eaa747486e4e82882d2575224e6e9a3148df583058850c629/rpds_py-2026.9.1-cp312-cp312-win_amd64.whl", hash = "sha256:5ce8943f79c2210f7abcc28e86367b03b28d95027fd01c46d2472373ae70c86f", size = 222923, upload-time = "2026-10-04T16:29:35.709Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c3/89/0302215373c2f8b4408b0fdfee955368cc378a98ff59508d47a7e0dc2dbf/rpds_py-2026.9.1-cp312-cp312-win_arm64.whl", hash = "sha256:501909f2e4a1e2dee528ef766fe3c469060ebc17e54a8383d404ba07a81a6f02", size = 218415, upload-time = "2026-10-04T16:29:37.263Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/83/ea/ee88fd9e756ff93fb6b1182a47ec09504a242620e33ce1d20679efefe841/rpds_py-2026.9.1-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:a36b70596407634ca82d4b989a3729074a008537a0522e4c8046a67c729103e9", size = 346229, upload-time = "2026-10-04T16:29:38.82Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/57/71/a097d6552f837500fc36e6b23d09cfb9890c3cc47531f9ca64e149799615/rpds_py-2026.9.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:eba5d173f7d5708b22a93815017a4611873ed54db9f268077c0dd1ed99cfc858", size = 340514, upload-time = "2026-10-04T16:29:40.405Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bd/b7/497e85768bf4e0d8ddbaa096a4cac31d1509251dee2728a8490aa367e0b5/rpds_py-2026.9.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:457866b85daf5034296666168b84a69e0b2e89dc4f1af102b46f6448a60b9063", size = 372611, upload-time = "2026-10-04T16:29:41.778Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/52/4b/74ab4108916250b6e198e0d3af05bc6835eb046315f22f7a0ceb49667c5a/rpds_py-2026.9.1-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:a3a52a3ba86436ab3aef510fbe21512abc2ddd1993005dfe50514bd2284ef025", size = 377712, upload-time = "2026-10-04T16:29:43.242Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0c/8e/067e77d9d7b3cc793c9d909b7e97e7aadbbb1fb094093b6876902cc96d38/rpds_py-2026.9.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d7841166b7fa64c9c56404617ae4341448847482d45933b13135d26c130519e5", size = 488106, upload-time = "2026-10-04T16:29:44.692Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3c/b4/c5aae6c2dde269bf955f6b7d35065c655a57e47750d9668052ad67e74dda/rpds_py-2026.9.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:926bdd3e3b5998ddf70cc64bc8cf57209571f9044542913afb673799fec77dd0", size = 390795, upload-time = "2026-10-04T16:29:46.129Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a0/36/76fab39973ee11e7f9f357c55138197bb01c86f6502cb76487e3b4f42db0/rpds_py-2026.9.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7868b85224291c6cb6759f9b5adb9745f486d226f62b16a614dd5a2a5ab2b35b", size = 370794, upload-time = "2026-10-04T16:29:47.603Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3d/fe/cd2a80e6d7b871937a60e935c5d507aa390d143f4ff3636f640b9733d5df/rpds_py-2026.9.1-cp313-cp313-manylinux_2_31_riscv64.whl", hash = "sha256:3cd182d7291d29b92c521a0069d9c01ba6193628a9a105531d11b40a6d731a33", size = 375673, upload-time = "2026-10-04T16:29:49.223Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6c/18/7464a9953724e55a3b3206062fa0ffdeaa519584c6aabf65d3956d94f131/rpds_py-2026.9.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e6ea1cda8d8c688278430e4268a42f5e5da3bdd74578dfadc0820c3f1766ce83", size = 398758, upload-time = "2026-10-04T16:29:50.601Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c0/86/1534b436700fd49ff411063b7c4d7e938adfabf90895b6cf1622d5a7d1f6/rpds_py-2026.9.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:5943980471829f6de242a20b109de3111ba6b77e3af0ffc587028ac854b05e6c", size = 550370, upload-time = "2026-10-04T16:29:52.002Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/57/1c/e1fa82a8a01e3c5820f3ba98a8b2673f642128eb368fa88871b01dd2c909/rpds_py-2026.9.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:76d3af9732d2dab69f28179b40ba2d87e2f1d5824b4a694780aa787d685e8f36", size = 613106, upload-time = "2026-10-04T16:29:53.655Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/29/55/b20b8c4c3dde8755bfcd5b08492a02d0cd2e26929aedf6199ca2a377d42a/rpds_py-2026.9.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:78326f4cb4427a56ba4996c0762b63be45f06b85f086526420d2b3a66e40f84d", size = 578235, upload-time = "2026-10-04T16:29:55.157Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/55/42/df3f7bbc3f7ab37a8a9db8d6c2ff2c985422899f1f7926afbf7ec3c0b8b4/rpds_py-2026.9.1-cp313-cp313-win32.whl", hash = "sha256:172e47169583f46ce118cbec68e6795d0da0f4606b488b6434f8276bca0a058c", size = 205293, upload-time = "2026-10-04T16:29:56.669Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/31/9c/ba5a9569d719bfdd6ce863df4133ac6a1658cf1b07cc3534c31db729fbbc/rpds_py-2026.9.1-cp313-cp313-win_amd64.whl", hash = "sha256:3e93b2cd69a9830be33e03945cd7cda940a0a8bfcfbff41d6144f0cb0d3d8bd9", size = 222409, upload-time = "2026-10-04T16:29:58.049Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/35/72/f28ca566f6c23c35bbf7445f65eb0364577b25a026305995e24f78b83d94/rpds_py-2026.9.1-cp313-cp313-win_arm64.whl", hash = "sha256:d151e148117294133bf8af7eeace085e7e87432db15ab6adf640330298a47f6f", size = 217681, upload-time = "2026-10-04T16:29:59.449Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8a/f2/67b94be1532767803415c1c5a1fd88ea487643d74a673cec1ba140af77bb/rpds_py-2026.9.1-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:c9d1aca01f49170fdcf5c92761b1fafe97f554b721ca4570c5949fff778f0d4b", size = 347178, upload-time = "2026-10-04T16:30:00.865Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/04/37/b751de2b59b0197a1d92a5dd491de88e8a5e928c2e6562581974f1e85263/rpds_py-2026.9.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:3f0e9ac28fc067d4d34b88ae43c48e9489455c97fee9633d851f7eeed5a05d35", size = 341878, upload-time = "2026-10-04T16:30:02.564Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/72/e2/5873bc4643c250db9e05d48dc0c93763d4aa68bc3b81164cb1af3b45b284/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:07deecbfce94c78473018bc7d10b337cc651d12df87a1eb2cb3e4024bc9c33d0", size = 373963, upload-time = "2026-10-04T16:30:04.026Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/51/03/5acf7632158247f3f6386ff0af3a1ee48167d575037e8d0920594b76d92b/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:821b2755db9194409254012f429c56643416fb96ef9be090be82ec8826b7f477", size = 377975, upload-time = "2026-10-04T16:30:05.555Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e6/00/63fda451b8bffa5808fc8bb311ee7c073b340974b09f273c7b2a145d3d62/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c91c210ae7645626c608400e3519b4a642f837cce09ca830db3beb2e9f274d4", size = 490347, upload-time = "2026-10-04T16:30:07.156Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a1/ae/c093ffd070ba0fb02f76c565d06fecc65ad6e4afdbae78f7031076d3cdac/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:54ac2158a6f96cfbabff0b2eedaf94b90c5ec7ca8317fcadc61e1c2b2e0ff6ef", size = 392962, upload-time = "2026-10-04T16:30:08.77Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/22/9d/d08a1128ab199b2f0cf25bfeb0639bd05119fff4b7c47bec24ef9a8ec23f/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eac2f5dbafd585dfe31f86a23ebf0d3ba480a9d49ebc87947267b5608d4ea0cd", size = 371623, upload-time = "2026-10-04T16:30:10.501Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/53/c7/4758ddcbb75609414bbccfcb11d612436f9b3ee821bd2f33f0f1604ee648/rpds_py-2026.9.1-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:8aa5dda18d39b6143eb24809d158f9252c88f402749b6f1b62a506cc7d96cc35", size = 376997, upload-time = "2026-10-04T16:30:12.124Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/87/e4/947bd7f608ff60faf46dc9d389c3dffd0e3d767d78a0be19978448ef0ce7/rpds_py-2026.9.1-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:5c90e7fa02e8f5de0d10c17595c568ada48c5302e749462c0ea1a4c362111a86", size = 400169, upload-time = "2026-10-04T16:30:13.804Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4b/35/fe93e020a0543b5670472c18d7e6af3197c08da571240ce1965c84f85c0f/rpds_py-2026.9.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:e6d198bad4e49dd6732fbd636e2fc5c082f45c8cad0b4acb756b00c82c76072e", size = 551615, upload-time = "2026-10-04T16:30:15.332Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0d/4f/5d2a0136bb03b2a56a39dc6ff92d58a6e3e53a2e17079238b86228882f16/rpds_py-2026.9.1-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:96beca19ec79de272e8668585380ff9092c47077c1d7a1e098e00bbd921f4785", size = 614655, upload-time = "2026-10-04T16:30:16.92Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/09/1c/3f1025aaf70d9bf7272cc41f8b64ee76b48bf01726248138430e16f23b38/rpds_py-2026.9.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:a5cf77eb04f20b720be95265a3e00eb2a14814074255cc27069c551b2db53118", size = 579602, upload-time = "2026-10-04T16:30:18.555Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/53/0d/5c72e6204f76610608706da32b6b7e11ef7e10317558a7bb15a122e008dc/rpds_py-2026.9.1-cp314-cp314-win32.whl", hash = "sha256:a03d57b86d2a51d0a66c92177e2be154ad015f357791d306e714569999cdb4cc", size = 206315, upload-time = "2026-10-04T16:30:20.05Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a4/0b/489d48abbcc7d70cf3fbf662d9d22abf1f4650761c0a9ae05260800800d3/rpds_py-2026.9.1-cp314-cp314-win_amd64.whl", hash = "sha256:837c6b305e26fe0f75b15c92cf3b2ba29e0ae19dc40b1c557b026cb426347d0c", size = 222852, upload-time = "2026-10-04T16:30:21.604Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/91/16/bbb05a7e6a10cf79ba639be7f799d770ee15f64175cc61d081b218dd402a/rpds_py-2026.9.1-cp314-cp314-win_arm64.whl", hash = "sha256:fce4b85234a0cbad67bf8e6e1201ee815d172c9aebad75f25645bc4d834f8e31", size = 218709, upload-time = "2026-10-04T16:30:23.036Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/22/ac/ac507a0a4ec478ca470440a09583db4be5259ba7670aeba0620822f1e57a/rpds_py-2026.9.1-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:3a72c11530d71abfb66c8d7696a2f86c43e63fca8b948f1a784ac490f4ec688e", size = 349596, upload-time = "2026-10-04T16:30:24.558Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e9/f2/817a46b658d5070f477f722c298ee9a24525b0e4017347964146ef5fdd0e/rpds_py-2026.9.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:068c37bba854ec2fe42f7365c640af11dd9895890ccbf2df5070d0c059bd7f96", size = 343114, upload-time = "2026-10-04T16:30:26.048Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6c/42/6ade976b13ac1b4cb3bf2eb603f1be2fe74df19a29988d4c2b386be59d6f/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d7fca4eb6df565e2a928f1c7dad92d27db8f9df0f449e76423ed5d7e713ed445", size = 374197, upload-time = "2026-10-04T16:30:27.699Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d9/70/77cdf1d3f1a07faabe936016ae623aec7981f73108a8fe7a203ed2e21998/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c933c6678c6f116ff8af47a4c6db0868b8ace74af0343016c0ef00f00272ea69", size = 378025, upload-time = "2026-10-04T16:30:29.451Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3f/6b/18a44a3beaa9b7931acb04af7bd9539836477c630a794452d4826d6185d4/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:028ad274ea951dac64491b5d1e65712a4aeabfdbdb9fccf797b57bd899b0c495", size = 491969, upload-time = "2026-10-04T16:30:30.995Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/73/27/fb39cfd6bddaf741b024f813890374578ff8ac1f1adc473659c048b03b05/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:740d0a99cf9de0b17a3943388e9294a59becf75e7c43421f387bd3c7a9901f7c", size = 393905, upload-time = "2026-10-04T16:30:32.628Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ed/71/0fa7bb77b57af0d710273964180d11b503f62b8a5c358eb2d8c3f62feff6/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0da298fb372dc192610a4b9ecbc68a0cd8b675bbbd1fc519d01b41cfd658333e", size = 374569, upload-time = "2026-10-04T16:30:34.257Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/54/22/f41cfac269af3b449513ef1bc3d7f32fde52abbbd2d01c7e76b47743acd9/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:eb61be926bb81567c1f48bdc8aa22b9855048dc2efd53871f9f7e6e9a5632346", size = 377482, upload-time = "2026-10-04T16:30:35.997Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b4/fc/312b49006e7f8f9ca5f96647577b8aa6f3df30519c46bd448f5c425af0b2/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:42e75466f83cd43f6026c81eab74246efb2bdadafb307b85700632d06c68f299", size = 400040, upload-time = "2026-10-04T16:30:37.76Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cf/a6/18cca7a878dc7fa95165a83343fd4d7b65643fd22e54e47340a451121d5c/rpds_py-2026.9.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:617f59cde379b4f648a09797b7f683d04b90a46344cddab85639da5aff0f5531", size = 551849, upload-time = "2026-10-04T16:30:39.443Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e4/6d/1f5685e20f39604691bdc3c05aaa6b8bd2f954e9e996477adf2376768e33/rpds_py-2026.9.1-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:3edae8c5ddfdb6985d49ae9d150516e5076888879022f91a26c2de9276ce0bdb", size = 614842, upload-time = "2026-10-04T16:30:41.231Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c6/25/98652109fd9f7e10268dd4571aa52b81987001b806f37ef1a18260de714a/rpds_py-2026.9.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:0f045bb053c9057720d72c56dffe30dffdc05997b2897a827b9325f0ab6623fa", size = 582606, upload-time = "2026-10-04T16:30:43.345Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/19/03/11ca09099bab5f53373a80a334c424ec917c13d050760a59499d2af5171e/rpds_py-2026.9.1-cp314-cp314t-win32.whl", hash = "sha256:bf35d0568abda97233239ce32896d3ad53fccc537832c104e30c94aa5fb93569", size = 203341, upload-time = "2026-10-04T16:30:44.954Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6f/8a/88909e3ffd9f47f5b58211473875d8c3c09079f0058c46fb72c55a702a26/rpds_py-2026.9.1-cp314-cp314t-win_amd64.whl", hash = "sha256:1e8d4d79d828299bf44a55db22a9388ab967b49d17132c88eab0f4360b48da8e", size = 222843, upload-time = "2026-10-04T16:30:46.486Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f6/b7/a662f367d4896dd0a10cef2fc91f10b7f08af1c10858e287e019563f338d/rpds_py-2026.9.1-cp315-cp315-macosx_10_12_x86_64.whl", hash = "sha256:1d77b649e6f7cdf12ca5c2a98dad0ad37f9ea9b6f960408a92f0cb12bb3d04d9", size = 347463, upload-time = "2026-10-04T16:30:48.203Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ae/3f/ad45d03df4f84ebae5439577ee81f3999d182711e82235c8037b6528890e/rpds_py-2026.9.1-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:00ba2d8c7dd4ee537978ddf4b3fbd712bef2d8751603f7f3146b3f4287768e25", size = 342051, upload-time = "2026-10-04T16:30:49.872Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7e/31/3dcd68c13d4bcc59c1f7eb33ac8e80698f06f3eb0d8a1e06419836071c20/rpds_py-2026.9.1-cp315-cp315-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ec450527cbf485e13c8d3602a54f428ab0432fdade0ede75efd74b735421c871", size = 374143, upload-time = "2026-10-04T16:30:51.508Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cf/0d/68c1f058a250fbd1380ebda9fc227cbf50117adf8ffe8161ef383ea79f68/rpds_py-2026.9.1-cp315-cp315-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:306ee1850d8105b5baf977e78d45fcadd12c1a54678d614c9baf217708446e91", size = 378604, upload-time = "2026-10-04T16:30:53.206Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d7/d6/2d4c59b85397cb4800594fadf692688ccf5ce556adc930e7a5bf21061a5e/rpds_py-2026.9.1-cp315-cp315-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ef6b65b03247c54692ad4fd9ee97cb772781927db72e3cb05e70b3db6d1ff14f", size = 490790, upload-time = "2026-10-04T16:30:54.925Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/da/04/7e05dc3aebaf52f4e026766bd668fdd09a9d0e23f64a14686b36b3501892/rpds_py-2026.9.1-cp315-cp315-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a575404ebc9cf2e91edd32eaf570ec1430eb900d4f56724ba7dd4bc1fc9c176d", size = 393146, upload-time = "2026-10-04T16:30:56.625Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/57/ca/e2e9a0a46a74ed51a0498ba1fe10f4ea6b2d9a155f372a2f91e51f18cf10/rpds_py-2026.9.1-cp315-cp315-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2c16ab111bc27c646ba8aa005d0527754edc538ebb636f0b1bf8e244b48d1945", size = 372022, upload-time = "2026-10-04T16:30:58.295Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ba/cb/8f8774df5134e23424372838bcc5c7ed4127d723e1ff52f7bebd4dcb2563/rpds_py-2026.9.1-cp315-cp315-manylinux_2_31_riscv64.whl", hash = "sha256:7664419f27db41d4f1c43a78dccda7dd6e8ef2428df3ee01d0c2a07a6b071297", size = 377092, upload-time = "2026-10-04T16:30:59.984Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/90/02/8d7095d73bf9114219be40230baa5df00611e0a82ed9517779ff9c19f82b/rpds_py-2026.9.1-cp315-cp315-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4b26b03d9d2658ee2fa234f8f4f19f38a09773fe5261028025032e26d4d35af0", size = 400830, upload-time = "2026-10-04T16:31:01.721Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ec/02/8206856f8f363cd042a8315dc86b3912f5dcb6d3c66bbb24b69c2bfb0775/rpds_py-2026.9.1-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:be3e47e2d91aa3942ff9bf4077a505226005abfc39b6f7554a91c1b9393986b9", size = 551478, upload-time = "2026-10-04T16:31:03.472Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/41/6b/36211f1bb1f0b0313f496d92f5905b74ea107f27cb16fa3355a82f04575e/rpds_py-2026.9.1-cp315-cp315-musllinux_1_2_i686.whl", hash = "sha256:6307a0da524939decb8ca4a3933b8ab62525794411d6984fca6726e732804af6", size = 615173, upload-time = "2026-10-04T16:31:05.281Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/35/77/cda0c4a6f055446b692f0ed5692f73707cafd3dff82672ede31b1a9b59de/rpds_py-2026.9.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:159a7aab5c5e8b112c8830f54717ce56da1252ebdbb526f5be2df2309280b9e7", size = 579653, upload-time = "2026-10-04T16:31:07.065Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/74/ec/d8385f446240aed643b9e92a5055cff3015cc04a13c61f73b2883c478ed5/rpds_py-2026.9.1-cp315-cp315-win32.whl", hash = "sha256:dbc2673f9223d420c91145599b3ba45a8a50c207d1976908e5fb5ddb0c9b9429", size = 206498, upload-time = "2026-10-04T16:31:08.989Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6d/a5/71b5cd00e0521e3b6b81828baea368c62b6b700ebdd9554cd7d41ddf12fa/rpds_py-2026.9.1-cp315-cp315-win_amd64.whl", hash = "sha256:75c38c50ab9aca840225d9a9a3810bf11d04bd5c1f186cabbb8aee56db3e9b15", size = 223121, upload-time = "2026-10-04T16:31:10.84Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/33/58/dba857c3bc8221b31b62eb170a3080f4f191de79f047200389b7ed1b06a7/rpds_py-2026.9.1-cp315-cp315-win_arm64.whl", hash = "sha256:a431156bb41865fc14cd5d79bb9d7bbed83110b0159e34e62ae30951f96c0009", size = 218741, upload-time = "2026-10-04T16:31:12.592Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5b/d0/320ab28ccc1415eeb509d68682b0014fb74690cd49f1c2d29a232475af50/rpds_py-2026.9.1-cp315-cp315t-macosx_10_12_x86_64.whl", hash = "sha256:ef0d8c843e2827d6c120ab4687e9423fb1d893db1df27b7c1506615bcb9734a0", size = 349719, upload-time = "2026-10-04T16:31:14.48Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/56/88/f5b12f1358f443c08b7ce3cc8391d82d335f4872580e2e097847fd36087a/rpds_py-2026.9.1-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:45bc6bccf78b20fd834237d18db64965d7ee68ba7f60440a26c7ab71e7b8d51a", size = 343267, upload-time = "2026-10-04T16:31:16.827Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f7/0c/c765b0059d532acb3b9c45d781ccc22f15a96dbe443d00903f643ba9df10/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1d55198263bb51f557550c6ed2e6d1cb6a6fed6eb5c9120b741c5926bef8a45d", size = 374555, upload-time = "2026-10-04T16:31:18.931Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6b/8a/cafddfda77564a10cd21184640c3bffda6a2b8d20972fb5dedd5e0166328/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:a8763f20692da7df39b0afdd1ba3042b004c50a45994f76c2d9a25641f7673db", size = 378346, upload-time = "2026-10-04T16:31:20.75Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b9/01/5e626016eff72c183bf6c96539240cace15d402468647a453ec08415b2fc/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e43d4a1f673e8a1cbd8533e809e02b4bf9d4f2280269bb640436556312121250", size = 492373, upload-time = "2026-10-04T16:31:22.614Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3b/9c/15a2469e9389242f46896b3f0a01d68caea8a5a35c011fcb05ef333aae73/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ea394a937f17a54c51239348bdbe2e3518124c8d4a8951ba04a311d3095bd18f", size = 394371, upload-time = "2026-10-04T16:31:24.768Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/63/f5/c100ff77e1e6366e947c75969c258fdfc4b7bc5bbfe7351e62ffbf2a1228/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cdeaa99ce822dca76cfb1b993e9120c5ea212f2eb66d48950ad63c349668a018", size = 375132, upload-time = "2026-10-04T16:31:26.588Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/dd/f4/fe0269c9de253e99c81cabc12b8971a5feaa083debdaff1221e06264d9e3/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_31_riscv64.whl", hash = "sha256:b4f062343e7ad3fa94f2c66e5ae667dee47ee74dd41a9057c4fbe163236a123d", size = 377642, upload-time = "2026-10-04T16:31:28.677Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/05/65/b34a7b257baccff8f4a24a722933166d4941d5ebdc9c3f4bc4ffcd5ce4f4/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:22ffd29a63d71fb1b81552c21f2c2b734949b7ac751a9be70675a939a900839b", size = 400855, upload-time = "2026-10-04T16:31:30.802Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/98/32/844e54176b6071b90b38a564e6940bc6eb8f97b2890dc709c19db9dec0f4/rpds_py-2026.9.1-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:08dae4a4095150a7c4545a1fb40b98e1ab1744fbc2770d92c977b9dadaa49ab6", size = 552573, upload-time = "2026-10-04T16:31:32.709Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/17/73/6041d20729dffbfdf155c02d65be58bc225a1c1fb548fd87c23ef306138f/rpds_py-2026.9.1-cp315-cp315t-musllinux_1_2_i686.whl", hash = "sha256:9a0460d43603d1fd9ef59c30278531e15d78581721ddb538fa560aa7817ea4ad", size = 615840, upload-time = "2026-10-04T16:31:34.565Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/af/9e/418094adaee6b056ce199051b255448ed872829051e341b2294c80da0977/rpds_py-2026.9.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:1c2d1f6da5128eabf34e963d7163a818846075a52568250d006c4c953b40f903", size = 582764, upload-time = "2026-10-04T16:31:36.665Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3d/9b/1698ebf6b840ddfe8b472198abbed6ace35c6e398faeecd6c47dae742a4e/rpds_py-2026.9.1-cp315-cp315t-win32.whl", hash = "sha256:5c6ee90dee3e85e055ddfd502d611643d9b0fd94c818220bda84ec3dacd9b27b", size = 203795, upload-time = "2026-10-04T16:31:38.53Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8a/e2/91f70d804c61f8eac39a417e82aa1024f655ab9e8bdd7393b196242bc41b/rpds_py-2026.9.1-cp315-cp315t-win_amd64.whl", hash = "sha256:fe5ad0664ec772b02c45859041aa17655709cced7a31005817fbbbd988c25567", size = 223037, upload-time = "2026-10-04T16:31:40.468Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a3/90/a9ba81408369d34c1aca73319c15adc91ed45c1d21e9e8ee4832ffb7fe0b/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6cdc537c8633d7fd92a82e2e0d2ab74320a3f63d5e59fb9cf08711e08fe151c4", size = 381109, upload-time = "2026-10-04T16:32:08.994Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b3/44/5192a0bed94cec86bd2a5e1cc5a1bb8f7eec3aec907eacd2deb13e87e326/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:10e208f2425d973938afcd56e28a7c4be32e27b6a60b5d381f49fb9d8acf9759", size = 388222, upload-time = "2026-10-04T16:32:11.321Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/92/cd/5356549711448f18b52f7a11ffbe90f1228774996fbf3c6cd1b18d22abaf/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6c0dbbcc19735fe5f8b0a54c07659d154a9e69f47e15d0a6ab7299215daf62cb", size = 500384, upload-time = "2026-10-04T16:32:13.478Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7a/88/ddda9d28adfe33119c75b2e733d4ba7e326f41d7e1b1093951771768ca48/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:684fd492fff4fead00587544e059be2bbcb6f93454f21fa2a91b66fc7508be82", size = 401661, upload-time = "2026-10-04T16:32:15.653Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/32/c3/bb59ba16a6b4a57995d15b8c04c00f28df3b938c4dcdde48fbe0f73edb0c/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d1028417bb44037eb3069c1009bd7b7277212876cda22fbe565b0bca9fab6d2c", size = 380748, upload-time = "2026-10-04T16:32:17.727Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f5/b8/0580faa1c5a32ddc160130dd7ae54d2d007272a89a40a6b5db3e50f9f585/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_31_riscv64.whl", hash = "sha256:492e5e428cbe126221611f47e068f01660352feec4ad18bc0f5ea9b2ae88fb14", size = 385731, upload-time = "2026-10-04T16:32:19.855Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bf/70/f73564642bbe3322c7eeef2c2f258cf040b71c41a430b532e59d04a1b838/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:88b5268892fde430d5531f95bc560b6efbbd67c929662c586afd729a96e7461c", size = 412131, upload-time = "2026-10-04T16:32:22.285Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8c/5d/17fff2e1f8f68721a2afb5cb48f7e442c751bb6b4883157c5abaf618cd08/rpds_py-2026.9.1-pp312-pypy312_pp73-musllinux_1_2_aarch64.whl", hash = "sha256:01445c8d194aa032a08e944f16567672da1c62dbdbefd8b6d0693032e290cf68", size = 558193, upload-time = "2026-10-04T16:32:24.4Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2a/d0/869ab6fb08531f97aae4a780b4d61b4190d8aef48fe054ee28bcf7114466/rpds_py-2026.9.1-pp312-pypy312_pp73-musllinux_1_2_i686.whl", hash = "sha256:eef6a03b0b6d08d0835ccfa8ec8d1bc70525e3801387567137b50c557695e6da", size = 622448, upload-time = "2026-10-04T16:32:26.844Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ba/a5/9672e532fe02cd3b92c78cfd8743abca939d96853006c63835009a1ecb6f/rpds_py-2026.9.1-pp312-pypy312_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:6b9bf3135b4ad5981df9a73d71a35272d650a2985ae9c2746357b24d59de2448", size = 591126, upload-time = "2026-10-04T16:32:29.274Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/80/ef/3a9f8e4279c7920af561deed4cb7ebebed2794a8f608cf404d5eef14a105/rpds_py-2026.9.1-pp312-pypy312_pp80-macosx_10_12_x86_64.whl", hash = "sha256:56c6952a9b15047466d0c2347c446a761d4527f89976156341e68f0ce5cc08b0", size = 357108, upload-time = "2026-10-04T16:32:31.641Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b7/55/4b2fa381a583760aea5c92841e4e928a358e1c6511b129219e9c2826a226/rpds_py-2026.9.1-pp312-pypy312_pp80-macosx_11_0_arm64.whl", hash = "sha256:b242c27c8f836305a4a72df9cdd564386ac57b807bd252a063223331c9316b37", size = 346877, upload-time = "2026-10-04T16:32:34.061Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scikit-learn"
|
||||
version = "1.9.1"
|
||||
@@ -3578,15 +3047,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/c1/d4/59e74daffcb57a07668852eeeb6035af9f32cbfd7a1d2511f17d2fe6a738/smmap-5.0.3-py3-none-any.whl", hash = "sha256:c106e05d5a61449cf6ba9a1e650227ecfb141590d2a98412103ff35d89fc7b2f", size = 24390, upload-time = "2026-03-09T03:43:24.361Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "soupsieve"
|
||||
version = "4.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/95/48/21a393ff731b8f928fa4f8176f9a7ceba2252ee60a5149f25b45c292aa5c/soupsieve-4.1.tar.gz", hash = "sha256:ca9abf7126667010d8f6e9b39bfc1bc3b23c8aed9bcb0f54a754dde969bb8aab", size = 161955, upload-time = "2026-11-10T01:59:50.399Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/88/73/6a2087c72975cfc07394623bca8d17654342ea4055ae368deafe5a81a542/soupsieve-4.1-py3-none-any.whl", hash = "sha256:e4d667b3974ce6e038e7390486b8093369854a1d345ffdd4c121dfc4a782e809", size = 52302, upload-time = "2026-11-10T01:59:48.571Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlalchemy"
|
||||
version = "2.0.54"
|
||||
@@ -3660,20 +3120,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d9/50/f00935da0ec7cbf325f8dc4f772ae46fbc7b672dd62876e73f0a94adda57/sqlparse-0.6.0-py3-none-any.whl", hash = "sha256:b861c0288ce2fa56209a9a6412d2e066ac664b3873b89c26c9d8415e8e32996f", size = 50070, upload-time = "2026-08-13T19:16:04.062Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stack-data"
|
||||
version = "0.6.3"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "asttokens" },
|
||||
{ name = "executing" },
|
||||
{ name = "pure-eval" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/28/e3/55dcc2cfbc3ca9c29519eb6884dd1415ecb53b0e934862d3559ddcb7e20b/stack_data-0.6.3.tar.gz", hash = "sha256:836a778de4fec4dcd1dcd89ed8abff8a221f58308462e1c4aa2a3cf30148f0b9", size = 44707, upload-time = "2023-09-30T13:58:05.479Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/f1/7b/ce1eafaf1a76852e2ec9b22edecf1daa58175c090266e9f6c64afcd81d91/stack_data-0.6.3-py3-none-any.whl", hash = "sha256:d5558e0c25a4cb0853cddad3d77da9891a08cb85dd9f9f91b9f8cd66e511e695", size = 24521, upload-time = "2023-09-30T13:58:03.53Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "starlette"
|
||||
version = "1.9.0"
|
||||
@@ -3696,68 +3142,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/43/3f/f88a53f60a472b46f4023f56d204dd7de33d34c5d2acbfa0d70a674e639e/threadpoolctl-3.7.0-py3-none-any.whl", hash = "sha256:cd8b60b5641b45c67bbf73c64c843235fc2d8a480c87389f52f5dbee893b86be", size = 26362, upload-time = "2026-09-15T15:46:19.168Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinycss2"
|
||||
version = "1.5.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "webencodings" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a3/ae/2ca4913e5c0f09781d75482874c3a95db9105462a92ddd303c7d285d3df2/tinycss2-1.5.1.tar.gz", hash = "sha256:d339d2b616ba90ccce58da8495a78f46e55d4d25f9fd71dfd526f07e7d53f957", size = 88195, upload-time = "2025-11-23T10:29:10.082Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/60/45/c7b5c3168458db837e8ceab06dc77824e18202679d0463f0e8f002143a97/tinycss2-1.5.1-py3-none-any.whl", hash = "sha256:3415ba0f5839c062696996998176c4a3751d18b7edaaeeb658c9ce21ec150661", size = 28404, upload-time = "2025-11-23T10:29:08.676Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tornado"
|
||||
version = "6.6.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/64/2b/8ff2b41620cbba0eeb0862fed21dcaa5a2ad36c6dd9bb465f9ff7a147be2/tornado-6.6.1.tar.gz", hash = "sha256:28e6311402af59c8b02e3fa0f5e7d8eb465b25081381803b127d97e6a4395d5a", size = 623388, upload-time = "2026-11-09T21:09:22.71Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/77/d3/ef3a4d38d1a72c52ad07483ed760dbb93027d28f19c3a2d98148abdd63e1/tornado-6.6.1-cp311-abi3-macosx_10_9_universal2.whl", hash = "sha256:a8d3e6acde5a80d13b13b5e4c7c226ca682f31d0a62b6c33cea038714bc2de1b", size = 533249, upload-time = "2026-11-09T21:08:22.475Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/38/4d/c65ea949a3cdc185f1afac8c337074d4f2d029b48293d2db4d2c3dea4849/tornado-6.6.1-cp311-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:1b6ff57cc69b339f8feb9e7b567b0e0eacb16bfaf234159496623ef7a67ba640", size = 534470, upload-time = "2026-11-09T21:08:24.27Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/03/ff/20911f85dd399b56761496e8138810e8608ea25f0912377f4205d52af853/tornado-6.6.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:da6ce2da215810d56539fa6cac77d9e27f4d8139c6868c53436b2fe933f43c79", size = 535446, upload-time = "2026-11-09T21:08:25.625Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/be/70/a4a159dd4f1fef39ff8eadae655b133a85722b39087a89e21ce463af9832/tornado-6.6.1-cp311-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:8cd28b2cacbe63d53e28a38546a3492b488417eeb3f7ecf10954476fc2508882", size = 535664, upload-time = "2026-11-09T21:08:27.191Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ed/d5/db70d5d23d3b4eaea0b26b710f28d2ca387bb44e68ccfede60ba3bbc2096/tornado-6.6.1-cp311-abi3-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:25b2619274bca77d0eb7b4d96dcf2d1142bb9bf172ad6a7491a1e1f82e6e48fa", size = 534660, upload-time = "2026-11-09T21:08:28.78Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f7/f6/0528ee039266902e707edd9996ee3ce7364dc1baf08bed585d8e6fb3ccd0/tornado-6.6.1-cp311-abi3-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:77dd6e0c659fdc45824e0746988ac5c060c2a9fee9b8cbbcdb999b3f29d3cd10", size = 532834, upload-time = "2026-11-09T21:08:30.432Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a6/bb/b733df2d487a78283080663bd6d96955121b58b6d445d9cb832607da9786/tornado-6.6.1-cp311-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:b62fded687e55acaf9e36c1230b006066a35b3f6df093ba1fd3b2ff592070e1d", size = 535289, upload-time = "2026-11-09T21:08:31.692Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a7/7c/c81cb83f2bbb5740fcba1eb83d794b6d6fab2063b16a475cc9039266091e/tornado-6.6.1-cp311-abi3-musllinux_1_2_ppc64le.whl", hash = "sha256:ecef88054d8a77878f61061ff67dfc5e1c17d1f7334890ab508b310e8e68ee46", size = 535382, upload-time = "2026-11-09T21:08:33.282Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8a/ae/c499da4cc8be1c1f31a5d8df2328f2aae091de2db13302ad5c20ed704ec4/tornado-6.6.1-cp311-abi3-musllinux_1_2_riscv64.whl", hash = "sha256:ca95e762df1ca761f330e3f2a034c15ac144569844b52527a5a9eca9f524c0f1", size = 534534, upload-time = "2026-11-09T21:08:34.57Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/61/7c/6b163c9e58ca9df0c941bda9ba2dcabbd87ecb81c5fa546f54eeac689232/tornado-6.6.1-cp311-abi3-musllinux_1_2_s390x.whl", hash = "sha256:8cae3d8f2585be01670da9fd5010c61724c51b61ecd4c06820e95874739daf7c", size = 534728, upload-time = "2026-11-09T21:08:35.828Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/18/11/b5107ac6a278387635d73d283e7ab5a5c76fb8ccf402efa57006ea25852f/tornado-6.6.1-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:6596f3e939962f13099ce8d1a96b83226e908ca369b193370a6efa84585a1601", size = 534676, upload-time = "2026-11-09T21:08:37.209Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/65/df/0574c4479c565d9233def796afc9179fa840f41f8c240f740609f746da67/tornado-6.6.1-cp311-abi3-win32.whl", hash = "sha256:0f0f596a0dab6826aa21d103c7bc242e3fb7cfc99c5c3d44a35ba8c83abbdca4", size = 535565, upload-time = "2026-11-09T21:08:38.518Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/36/57/35439a779582e3b19c98e799b6a41519fb3bdaa3a21b7a94ce4dd7b3b732/tornado-6.6.1-cp311-abi3-win_amd64.whl", hash = "sha256:5cb82ca38596e1350fceaf994f287847f82f7b8436380d36ba0937a03107d0ee", size = 535806, upload-time = "2026-11-09T21:08:39.892Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/89/b8/2cb42845af01ea7e70ac23e6f6fe2f26b9b158bce186c6991c057c9abe1d/tornado-6.6.1-cp311-abi3-win_arm64.whl", hash = "sha256:58d2f47e7b54fded3407dbbbe4e59d29ca627f85bf6c0f21f0b151c6c7fc9c53", size = 535825, upload-time = "2026-11-09T21:08:41.339Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/10/de/cfeae9e75c144ca22018ee3b858e343c1658d6edd2184f35d810ec1ef789/tornado-6.6.1-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:ed0bc5a1a9f6346e7bdadc106fa2d4c6e79d71d8b2df4366260ab3baf36a8399", size = 533356, upload-time = "2026-11-09T21:08:42.603Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3d/d8/7812a729c797fb8c15748c9a69faeaaa13630075cf9b76ba9f7fbcfb7f42/tornado-6.6.1-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:54c80f9bed0bf1533ecf5a90dc59651645622d62b0bcffa2692d108a1f794917", size = 537511, upload-time = "2026-11-09T21:08:43.84Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/70/47/ebef304487feea6d8efb6a7d2642964ecb1f5cc785f687628e1d7cac4326/tornado-6.6.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:eb67ba2cbf598e842f14684eab029a5a4ba7ab587e8c4e40940a77ed0596b31e", size = 538566, upload-time = "2026-11-09T21:08:45.203Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a3/6a/87532e6745c415eb2daa9bc1c9c89c69ce9e8255b1c0bde9938f3299440b/tornado-6.6.1-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:d83bac141bd9360d8e995ec512097be19ead2e9213c3e7088510a036f3192b8d", size = 538793, upload-time = "2026-11-09T21:08:46.478Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e4/c7/26af60f71f7c32f19257bad58711500628f579edf1a2c3d8328ad15aae04/tornado-6.6.1-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:60aad449dbcebaa8d69bff50c6ba39858fab8d256e779a99bb30ebf6724b9b48", size = 537691, upload-time = "2026-11-09T21:08:47.975Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ba/9d/af233b8bf4311d3466099ab267eb595ec6f1655607d290dc7f706b6dbd6f/tornado-6.6.1-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:b9ce0d6548bd73b1329075b247d3fdc61538922f558ee42059e08f5df53fc197", size = 535877, upload-time = "2026-11-09T21:08:49.76Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/95/66/78e7583ce69f66e5177c65988a98373be2ab25c1d22405d274e037acbc58/tornado-6.6.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:ce5a18654f5d56d11400ab5d87103660e14deceab41818a06a42acc8dbbe427d", size = 538295, upload-time = "2026-11-09T21:08:51.221Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a3/3a/ad336d4994547cf268a3bd6d10f6ef691e1e888fc776940c0bfe02e8d85c/tornado-6.6.1-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:3298fce72c35f836eab4c4db8b960104ff1ea718033a6b5e236f04efe3a1b6e1", size = 538349, upload-time = "2026-11-09T21:08:52.761Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cf/cf/563d24516afd266f6b3c3f1c7ac15ad39b8668966d2bccce917c169ab0c0/tornado-6.6.1-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:0223e827cedf4e35ebb035e57a0d9974563cd043e3a53f8bb72a859b6f53777e", size = 537469, upload-time = "2026-11-09T21:08:54.279Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c8/ea/1705ff4014c8bad5d7045022647156cfebd6c7014886da47e13512d27c08/tornado-6.6.1-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:533185c89be3ffb01656c9425da4ff42587a3af784b37d39fe762e8fce3b2dbe", size = 537624, upload-time = "2026-11-09T21:08:55.648Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/50/5d/421168e62c8b80e3ef88f80d642e9a7e5b1d0c6e8cd136d99064f663951c/tornado-6.6.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:fbaa022a49a27b65668592cf43b898ff3978cbe4e6926fdfe24dbef59053bd26", size = 537632, upload-time = "2026-11-09T21:08:57.797Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6a/b4/13b2f98a3141c152915fa3e69531a04bdc1cd7dd203f442136f3792a486f/tornado-6.6.1-cp314-cp314t-win32.whl", hash = "sha256:4bc6c60faf86162df25ba2ff5611d27b6ef8226de9d61c07a0fab53c169630a5", size = 535424, upload-time = "2026-11-09T21:08:59.145Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/84/83/6d54c37b3e437ab0ff2bddd71249c6ea2a17051104dd2995cb4e181e95a7/tornado-6.6.1-cp314-cp314t-win_amd64.whl", hash = "sha256:71c16b382b22d3234913a3f74a1ea84bede197d11eb03871df17bb123088dfa5", size = 535715, upload-time = "2026-11-09T21:09:00.456Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d4/38/75419d8cd577b7c4f335f4c5e75f127af286545ad49047a73afffdf877fe/tornado-6.6.1-cp314-cp314t-win_arm64.whl", hash = "sha256:510c7261ed986ecd6f74edc1a13412759e7abc2e8be3a6c85e15f6c53e1f3c84", size = 535718, upload-time = "2026-11-09T21:09:01.783Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/91/8b/96e460653f3e2ad83d70328414394132d73d5655047c692ce7b69ae2f6c0/tornado-6.6.1-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:01dc73e3697eb94d78c42e03931ab621da97d12fdfb6339e64ff5a934b220fcf", size = 533376, upload-time = "2026-11-09T21:09:03.097Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1a/1e/644bace0700e533235f01ffa68a7b5e3d6cc9eb7380e3929039d04b648b9/tornado-6.6.1-cp315-cp315t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:95bd4751357bef52aa655e236b9667ff054885de4b118e4ce9ba5c06e12ef5d0", size = 537696, upload-time = "2026-11-09T21:09:04.519Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e6/0a/afccc23d1ed71bcb1ce4a5b6e0f61f82c7a0b275f3b377ee7aee6680a565/tornado-6.6.1-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:29bce3190c2973fcd2171c95eeab8bf06d2f7a7eb107455ce3e4662c704aecdb", size = 538796, upload-time = "2026-11-09T21:09:05.956Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e5/24/69692f8ba851ed2738c2623eab592360d646f0a2e16b6deea16516aa8595/tornado-6.6.1-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:b777fbe0bdb2c4dc764aadf5f70e9b23b2e536c339d61c799d3ea1b575a7c285", size = 538951, upload-time = "2026-11-09T21:09:07.298Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/00/82/234306b41b33600a470da7e595b8064b85e2f509f64f5c1d39387c0abbb8/tornado-6.6.1-cp315-cp315t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:15443805d6b7aa11610cc6c5be7e71b4a93369aeb2ca5a13c2def53a3af5ba45", size = 537861, upload-time = "2026-11-09T21:09:08.857Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5b/87/6d13a60c320c0379cbfa4c2520b4ba076780c33e6a01ba3073fff74b71db/tornado-6.6.1-cp315-cp315t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:b77ab23d1520c807d11e703e79b020d3bc3676a0f5ebc8531f46d3fac8aecb2f", size = 536178, upload-time = "2026-11-09T21:09:10.424Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/96/c7/e27f2a21e05d7c5aa9886db7368436e6436880b85349072988b4f62422e3/tornado-6.6.1-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:872249311539281c1e8a5d8d6f27f478bf705a9bd931bf374b6b31b05177dfda", size = 538491, upload-time = "2026-11-09T21:09:11.968Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f3/c7/1f981336039c51d81ee6f895e3412178edc409bd709e38767365c55c0daa/tornado-6.6.1-cp315-cp315t-musllinux_1_2_ppc64le.whl", hash = "sha256:08b808e8d3312c268f9fe1ffebfcfaaf342e7fe4ac40d219a7e1b58bac547d6f", size = 538491, upload-time = "2026-11-09T21:09:13.226Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5d/4f/7dafc65726778ac148b68c91920605892e84bf0ffcc02890aaf1a7d0ba8d/tornado-6.6.1-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:8d475f4053c693b5c1483eb4845824129b0b51c65712e736b3c2ea1c8f6080cd", size = 537775, upload-time = "2026-11-09T21:09:14.697Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a1/25/85c852307f9e49896b6dc5119f6a0131f5f6d97c478a687654c2c0c3f0f4/tornado-6.6.1-cp315-cp315t-musllinux_1_2_s390x.whl", hash = "sha256:e923e75c9d641cdb8bbac60070a2dccdb684fc555af2bff48b0eaded0f88c2dc", size = 537798, upload-time = "2026-11-09T21:09:15.946Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/60/43/a37ec29b0f98c3c639da495e1d547d6c44c69a6727b9864cf149bf346433/tornado-6.6.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:a72f70b1aa630fa2106d39a025e2be75c272b7ec8233da94e2f407ea754cc32d", size = 537809, upload-time = "2026-11-09T21:09:17.265Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3b/d4/13973391071552e03acb308d93f6deb4fb535a769a6bbdafdb4cafcb2f91/tornado-6.6.1-cp315-cp315t-win32.whl", hash = "sha256:2fbfd2510b6163b189773155a8246c025cb260ccc7cd12ad18c36c54f5617bb9", size = 535422, upload-time = "2026-11-09T21:09:18.525Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/19/94/c952b625904b63fdac5b747f2eeaca64ab5d36cdb8faff57effa57162d87/tornado-6.6.1-cp315-cp315t-win_amd64.whl", hash = "sha256:3c35091add5863feb9cf651851bb1b23592f1f9551b5dfed72837c83ea4e5b85", size = 535713, upload-time = "2026-11-09T21:09:20.061Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f8/62/8d0c0c42f3346f3f2455738d3bc689bbd8efba38abf7b90ab2b8294eae83/tornado-6.6.1-cp315-cp315t-win_arm64.whl", hash = "sha256:065bc741478b168df9baf754956a3010c04d1330bb45a84833d807c29e11b257", size = 535719, upload-time = "2026-11-09T21:09:21.317Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tqdm"
|
||||
version = "4.70.1"
|
||||
@@ -3770,15 +3154,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/a7/03/921a3d3c75785aca9ebfbfcabfbc3a1be12e2ab5265deb026d55a5a3f83e/tqdm-4.70.1-py3-none-any.whl", hash = "sha256:c293e525e6fef9c20e8728fd4612df02a0aa31bb5fe91ecd93e123b1b7bffa73", size = 80199, upload-time = "2026-09-11T07:25:14.599Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "traitlets"
|
||||
version = "5.16.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/2c/2e/a7fbfe268c8a3b32546930c0297c101d65a4a14c304ad5790a9f478f0e4e/traitlets-5.16.1.tar.gz", hash = "sha256:ed900c2b631aa3a112811139fa97b8d2c3bad5e989656bba4b7e52c7852c18c1", size = 166137, upload-time = "2026-08-03T08:32:36.848Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/ad/66/0d785f0bc5e4315a96c989bb476d0fc07ea4f85132550c7b156ca2035d52/traitlets-5.16.1-py3-none-any.whl", hash = "sha256:f775618166caa0396c8e337099240f2bd3e5e917d203b2e6fbe21a58d3cb1f6b", size = 86211, upload-time = "2026-08-03T08:32:34.48Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typeguard"
|
||||
version = "4.6.0"
|
||||
@@ -3911,7 +3286,7 @@ dependencies = [
|
||||
{ name = "flask" },
|
||||
{ name = "flask-cors" },
|
||||
{ name = "gunicorn" },
|
||||
{ name = "models", extra = ["notebooks"] },
|
||||
{ name = "models", extra = ["export"] },
|
||||
{ name = "openpyxl" },
|
||||
{ name = "pandas" },
|
||||
{ name = "pdfplumber" },
|
||||
@@ -3945,7 +3320,7 @@ requires-dist = [
|
||||
{ name = "flask", specifier = ">=3.0" },
|
||||
{ name = "flask-cors", specifier = ">=4.0" },
|
||||
{ name = "gunicorn", specifier = ">=23.0" },
|
||||
{ name = "models", extras = ["notebooks"], editable = "../models" },
|
||||
{ name = "models", extras = ["export"], editable = "../models" },
|
||||
{ name = "openpyxl", specifier = ">=3.1" },
|
||||
{ name = "pandas", specifier = ">=2.0" },
|
||||
{ name = "pdfplumber", specifier = ">=0.11" },
|
||||
@@ -3969,15 +3344,6 @@ dev = [
|
||||
{ name = "reportlab", specifier = ">=4.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webencodings"
|
||||
version = "0.6.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/d5/a0/8fd707bcb776a7be556bad06a2ea5fb9bd519df78ef8e26f70ccf0f38bff/webencodings-0.6.1.tar.gz", hash = "sha256:565f9ad031c702dae404e27a099e3e09186a3ab1b9520f06d215502b651fd910", size = 15001, upload-time = "2026-08-15T14:22:57.549Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/77/c6/040cbc72480d789a5f40d63fb484d3106554c4dfa2d2b70ad5022057750f/webencodings-0.6.1-py3-none-any.whl", hash = "sha256:7fab6269c8bf237c657876b52058ccb182e861518d1c695c1a9aaa8c1c105d5b", size = 8745, upload-time = "2026-08-15T14:22:56.31Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "werkzeug"
|
||||
version = "3.1.8"
|
||||
|
||||
+11
-10
@@ -10,7 +10,7 @@ from webapi.blueprints.data import data_bp
|
||||
from webapi.blueprints.governance import governance_bp
|
||||
from webapi.blueprints.imports import imports_bp
|
||||
from webapi.blueprints.reports import reports_bp
|
||||
from webapi.follow_up.routes import follow_up_blueprint
|
||||
from webapi.follow_up.routes import follow_up_blueprint, in_dev
|
||||
|
||||
|
||||
class IsoJSONProvider(DefaultJSONProvider):
|
||||
@@ -84,17 +84,18 @@ def create_app() -> Flask:
|
||||
for domain in ("cacu", "cama", "tea"):
|
||||
repositories, manifest = import_module(f"persistance.{domain}"), Path(os.environ["DBT_MANIFEST"])
|
||||
app.register_blueprint(kpis_blueprint(domain, repositories, manifest), url_prefix=f"/{domain}")
|
||||
# The same measures in FHIR R4, with TEA's patient summary (simulated data, marked in every response).
|
||||
app.register_blueprint(fhir_blueprint(domain, repositories, manifest, with_patients=True),
|
||||
# The same measures in FHIR R4, and TEA's patients only in DEV (simulated data).
|
||||
app.register_blueprint(fhir_blueprint(domain, repositories, manifest, with_patients=in_dev()),
|
||||
url_prefix=f"/{domain}/fhir")
|
||||
# Patient-level follow-up list and individual risk, marked `simulado` in every response. Who may see them is
|
||||
# an access rule still to be defined, not an environment variable.
|
||||
from persistance import cacu as cacu_repositories
|
||||
from persistance.db import get_cacu_session
|
||||
# Patient-level follow-up list and individual risk: only in DEV, with simulated data.
|
||||
if in_dev():
|
||||
from persistance.db import get_cacu_session
|
||||
|
||||
from webapi.patient_risk import patient_risk_blueprint
|
||||
app.register_blueprint(follow_up_blueprint(get_cacu_session), url_prefix="/cacu")
|
||||
from persistance import cacu as cacu_repositories
|
||||
|
||||
app.register_blueprint(follow_up_blueprint(get_cacu_session), url_prefix="/cacu")
|
||||
app.register_blueprint(patient_risk_blueprint(cacu_repositories), url_prefix="/cacu")
|
||||
from webapi.patient_risk import patient_risk_blueprint
|
||||
|
||||
app.register_blueprint(patient_risk_blueprint(cacu_repositories), url_prefix="/cacu")
|
||||
|
||||
return app
|
||||
|
||||
+12
-106
@@ -1,32 +1,20 @@
|
||||
"""Model governance (ML, MLD, EL and VAR requirements): model versions and
|
||||
their promotion, notebooks run on a cohort build, and the OCR extraction
|
||||
jobs with their manual review queue.
|
||||
their promotion, and the OCR extraction jobs with their manual review queue.
|
||||
|
||||
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`).
|
||||
Notebooks (`models.pipelines.experiment`) run in the background on the build's
|
||||
file alone and are kept as MLflow runs.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from dataclasses import asdict
|
||||
from pathlib import Path
|
||||
from urllib.parse import quote
|
||||
|
||||
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.lineage import DOMAINS
|
||||
from models.io.registry import REPORT_TAGS, PromotionBlocked, registry
|
||||
from models.io.storage import build_file, cohorts_root, exported_builds
|
||||
from models.ocr import OCR_JOBS, OcrJob, run_pending_extractions
|
||||
from models.pipelines import experiment
|
||||
from persistance.governance import extraction_run_repository
|
||||
from persistance.repository import Repository
|
||||
from persistance.settings import settings
|
||||
|
||||
governance_bp = Blueprint("governance", __name__)
|
||||
|
||||
@@ -120,101 +108,19 @@ def retire_model_version(domain: str, scenario: str, version: str):
|
||||
return jsonify(registry.describe(domain, scenario, version))
|
||||
|
||||
|
||||
@governance_bp.get("/model-versions/<domain>/<scenario>/<version>/artifacts/<path:path>")
|
||||
def download_artifact(domain: str, scenario: str, version: str, path: str):
|
||||
"""ML-01b: one file the version's training run stored; a folder (the saved model) as a zip."""
|
||||
name, data = registry.artifact(domain, scenario, version, path)
|
||||
return _download(name, data)
|
||||
@governance_bp.post("/model-versions/<domain>/<scenario>/<version>/artifacts")
|
||||
def upload_artifact(domain: str, scenario: str, version: str):
|
||||
"""Multipart `file` and `kind` (ArtifactKind); logged to the version's MLflow run."""
|
||||
from core.governance.enums import ArtifactKind
|
||||
|
||||
|
||||
# -- notebooks -------------------------------------------------------------------------
|
||||
|
||||
|
||||
def submit(job, *args):
|
||||
"""Runs a notebook in the background, one at a time per worker by default (`WEBAPI_NOTEBOOK_WORKERS`)."""
|
||||
return _notebooks.submit(job, *args)
|
||||
|
||||
|
||||
_notebooks = ThreadPoolExecutor(max_workers=int(os.environ.get("WEBAPI_NOTEBOOK_WORKERS", "1")), thread_name_prefix="notebook")
|
||||
|
||||
|
||||
def _cohorts_root(domain: str) -> Path:
|
||||
if domain not in DOMAINS:
|
||||
raise ValueError(f"dominio desconocido: {domain!r}")
|
||||
return cohorts_root(getattr(settings, f"{domain}_database_url"))
|
||||
|
||||
|
||||
@governance_bp.get("/cohort-files")
|
||||
def list_cohort_files():
|
||||
"""`?domain=`: the domain's cohort builds that have their file, the data a notebook can run on."""
|
||||
domain = request.args.get("domain", "")
|
||||
return jsonify({"builds": exported_builds(_cohorts_root(domain), domain)})
|
||||
|
||||
|
||||
@governance_bp.get("/experiments")
|
||||
def list_experiments():
|
||||
"""Notebook runs, newest first; `?domain=` and `?domain=&scenario=` narrow them."""
|
||||
return jsonify({"experiments": experiment.experiments(request.args.get("domain") or None,
|
||||
request.args.get("scenario") or None)})
|
||||
|
||||
|
||||
@governance_bp.post("/experiments")
|
||||
def run_experiment():
|
||||
"""Multipart `file` (a .ipynb), `domain`, `scenario`, `url`, `source` (kit|dbt), `build` and optionally `version`:
|
||||
runs the notebook on that build's file in the background and answers 202 with the run, still `en_curso`."""
|
||||
upload = request.files.get("file")
|
||||
form = request.form
|
||||
missing = [k for k in ("domain", "scenario", "url", "source", "build") if not form.get(k)]
|
||||
if upload is None or missing:
|
||||
return jsonify({"error": f"faltan campos: {(['file'] if upload is None else []) + missing}"}), 400
|
||||
domain, scenario, version = form["domain"], form["scenario"], form.get("version") or None
|
||||
url = form["url"]
|
||||
if url.split("/", 1)[0] != domain:
|
||||
return jsonify({"error": f"la cohorte {url!r} no es del dominio {domain!r}"}), 400
|
||||
if not form["build"].isdigit():
|
||||
return jsonify({"error": "build debe ser un número"}), 400
|
||||
path = build_file(_cohorts_root(domain), url, form["source"], int(form["build"]))
|
||||
try:
|
||||
notebook = experiment.check_notebook(json.loads(upload.read()))
|
||||
except (UnicodeDecodeError, json.JSONDecodeError):
|
||||
return jsonify({"error": "el archivo no es un notebook de Jupyter (.ipynb)"}), 400
|
||||
if version:
|
||||
registry.get(domain, scenario, version)
|
||||
name = experiment.notebook_name(upload.filename or "notebook")
|
||||
run_id = experiment.start(notebook, name, path, domain, scenario, version)
|
||||
submit(experiment.execute, run_id, notebook, name, path, domain, scenario, version)
|
||||
return jsonify(experiment.describe(run_id)), 202
|
||||
|
||||
|
||||
@governance_bp.get("/experiments/<run_id>")
|
||||
def get_experiment(run_id: str):
|
||||
return jsonify(experiment.describe(run_id))
|
||||
|
||||
|
||||
@governance_bp.get("/experiments/<run_id>/page")
|
||||
def experiment_page(run_id: str):
|
||||
"""The notebook's rendered page. It's served sandboxed, as an origin of its own, since its scripts are the
|
||||
notebook's."""
|
||||
page = experiment.page(run_id)
|
||||
if page is None:
|
||||
return jsonify({"error": "el notebook todavía no tiene página"}), 404
|
||||
response = Response(page, mimetype="text/html")
|
||||
response.headers["Content-Security-Policy"] = "sandbox allow-scripts allow-popups"
|
||||
response.headers["X-Content-Type-Options"] = "nosniff"
|
||||
return response
|
||||
|
||||
|
||||
@governance_bp.get("/experiments/<run_id>/artifacts/<path:path>")
|
||||
def download_experiment_artifact(run_id: str, path: str):
|
||||
name, data = experiment.artifact(run_id, path)
|
||||
return _download(name, data)
|
||||
|
||||
|
||||
def _download(name: str, data: bytes):
|
||||
response = Response(data, mimetype="application/octet-stream")
|
||||
response.headers["Content-Disposition"] = f"attachment; filename*=UTF-8''{quote(name)}"
|
||||
response.headers["X-Content-Type-Options"] = "nosniff"
|
||||
return response
|
||||
if upload is None:
|
||||
return jsonify({"error": "falta file"}), 400
|
||||
kinds = [k.value for k in ArtifactKind]
|
||||
if request.form.get("kind") not in kinds:
|
||||
return jsonify({"error": f"kind debe ser uno de {kinds}"}), 400
|
||||
registry.add_artifact(domain, scenario, version, kind=ArtifactKind(request.form["kind"]), filename=upload.filename or "artefacto", data=upload.read())
|
||||
return jsonify(registry.describe(domain, scenario, version)), 201
|
||||
|
||||
|
||||
# -- OCR ---------------------------------------------------------------------------------
|
||||
|
||||
@@ -4,7 +4,6 @@ import json
|
||||
import logging
|
||||
|
||||
from flask import Blueprint, Response, jsonify, request
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from extraction import BBox, ExtractionError
|
||||
from extraction.readers import reader_for
|
||||
@@ -12,19 +11,13 @@ from webapi.imports import audit as import_audit
|
||||
from webapi.imports.connectors import ConnectorError, build_connector, catalog, connector_class, kind_for_filename
|
||||
from webapi.imports.connectors.base import decode_file
|
||||
from webapi.imports.connectors.pdf import PdfConnector
|
||||
from webapi.orchestration.reference.catalogs import CatalogoInvalido
|
||||
from webapi.imports.connectors.sql import SqlConnector
|
||||
from webapi.imports.connectors.tabular import FileConnector
|
||||
from webapi.imports.schemas.registry import ENTITY_REGISTRY
|
||||
from webapi.imports.services.catalog_commit_service import commit_discovered_fields
|
||||
from webapi.imports.mapping.derived import CASES, DERIVATIONS
|
||||
from webapi.imports.services.import_service import (
|
||||
DatabaseRefused,
|
||||
ImportRequestError,
|
||||
ImportSource,
|
||||
commit_sources,
|
||||
document_columns_preview,
|
||||
mapped_sample,
|
||||
serialize_errors,
|
||||
validate_source,
|
||||
)
|
||||
@@ -34,7 +27,6 @@ from webapi.imports.services.introspection_service import (
|
||||
document_report,
|
||||
extract_pdf_regions,
|
||||
preview_with_suggestions,
|
||||
suggest_mapping,
|
||||
)
|
||||
|
||||
imports_bp = Blueprint("imports", __name__)
|
||||
@@ -258,17 +250,12 @@ def pdf_regions_extract():
|
||||
def document_extract():
|
||||
"""Reads the documents, splits them into patient records and extracts
|
||||
the target's fields: `{files: [{name, file_base64}], target,
|
||||
segmentation?, pages_per_record?, ocr_mode?, key_pattern?, overrides?,
|
||||
include_pattern?, exclude_pattern?}`. `files` may be `sql` instead (a
|
||||
connection plus `table`/`query` and `DocumentColumns`' options), or the
|
||||
whole body may be `{source}`, an import source with `documents`.
|
||||
segmentation?, pages_per_record?, ocr_mode?, key_pattern?, overrides?}`.
|
||||
Each record comes back with per-field confidence and evidence, conflicts
|
||||
between sources, and the images found on its pages."""
|
||||
body = _json_body()
|
||||
if body.get("source"):
|
||||
return jsonify(document_report(body))
|
||||
_require(body, "target")
|
||||
if not body.get("files") and not body.get("sql"):
|
||||
if not body.get("files"):
|
||||
raise BadRequest("faltan los archivos")
|
||||
return jsonify(document_report(body))
|
||||
|
||||
@@ -292,32 +279,6 @@ def document_page_image():
|
||||
# -- validate and load -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@imports_bp.get("/derivations")
|
||||
def derivations():
|
||||
"""The operations a source's `derived` fields may use, with their
|
||||
parameters, so a client can build the form for each."""
|
||||
return jsonify({"derivations": [cls.describe() for cls in DERIVATIONS.values()], "cases": list(CASES)})
|
||||
|
||||
|
||||
@imports_bp.post("/mapped-preview")
|
||||
def mapped_preview():
|
||||
"""`{source, limit?}`: the source's first rows as they would be
|
||||
written, with its mapping, derived fields and defaults applied."""
|
||||
body = _json_body()
|
||||
return jsonify({"rows": mapped_sample(_require(body, "source"), limit=min(int(body.get("limit", 20)), 200))})
|
||||
|
||||
|
||||
@imports_bp.post("/sources/document/columns")
|
||||
def document_columns_of_source():
|
||||
"""`{source, target?}` for a source with `documents`: its own columns
|
||||
plus every field and caption its documents print, as a preview the
|
||||
mapping screen offers like any table's, with suggestions."""
|
||||
body = _json_body()
|
||||
preview = document_columns_preview(_require(body, "source"), limit=min(int(body.get("limit", 20)), 200))
|
||||
target = body.get("target") or body["source"].get("target")
|
||||
return jsonify({**preview, "suggested_mapping": suggest_mapping([c["name"] for c in preview["columns"]], target)})
|
||||
|
||||
|
||||
@imports_bp.post("/validate")
|
||||
def validate():
|
||||
source = _require(_json_body(), "source")
|
||||
@@ -341,49 +302,6 @@ def validate():
|
||||
)
|
||||
|
||||
|
||||
def _commit_catalog_fallback(raw_sources: list) -> list[dict]:
|
||||
"""For every source that asks for it (`catalog_fallback: true`) and
|
||||
reads documents, writes the captions no known field claimed but the
|
||||
project's catalog does know straight into the silver layer
|
||||
(`catalog_commit_service`). Best-effort: the structured fields already
|
||||
landed through `commit_sources`, so a failure here is reported, not
|
||||
raised."""
|
||||
reports = []
|
||||
for raw in raw_sources:
|
||||
if not isinstance(raw, dict) or raw.get("catalog_fallback") is not True:
|
||||
continue
|
||||
if raw.get("source_type") != "document" and not raw.get("documents"):
|
||||
continue
|
||||
target = raw.get("target") or ""
|
||||
domain = target.split(".", 1)[0]
|
||||
if not domain:
|
||||
continue
|
||||
payload = {**(raw.get("payload") or {}), "target": target}
|
||||
try:
|
||||
if raw.get("documents"):
|
||||
connector, _, _ = ImportSource.parse(raw).document_connector()
|
||||
if connector is None:
|
||||
continue
|
||||
else:
|
||||
connector = build_connector("document", payload)
|
||||
result = commit_discovered_fields(connector.records, proyecto=domain, estudio_id=payload.get("estudio_id"))
|
||||
except (ConnectorError, ExtractionError, CatalogoInvalido, SQLAlchemyError, ImportRequestError) as exc:
|
||||
log.warning("catalog_fallback: %s no se pudo procesar: %s", raw.get("label") or target, exc)
|
||||
continue
|
||||
reports.append(
|
||||
{
|
||||
"label": raw.get("label"),
|
||||
"domain": result.proyecto,
|
||||
"records_written": result.records_written,
|
||||
"records_without_patient": result.records_without_patient,
|
||||
"fields_matched": result.fields_matched,
|
||||
"fields_minted": result.fields_minted,
|
||||
"fields_unmatched": result.fields_unmatched,
|
||||
}
|
||||
)
|
||||
return reports
|
||||
|
||||
|
||||
@imports_bp.post("/commit")
|
||||
def commit():
|
||||
"""`{sources: [...], on_conflict: "reject"|"upsert", merge_duplicates: bool}`.
|
||||
@@ -415,7 +333,6 @@ def commit():
|
||||
"ok": all(r.rejected == 0 for r in results),
|
||||
"audit_id": audit.id,
|
||||
"indicadores_en_recalculo": recalculating,
|
||||
"catalog_fallback": _commit_catalog_fallback(body.get("sources") or []),
|
||||
"results": [
|
||||
{
|
||||
"target": r.target,
|
||||
|
||||
@@ -342,13 +342,17 @@ def tea_outcome(status: int, code: str, error: Exception):
|
||||
|
||||
|
||||
def _included(tea, queries, e, simulated: bool) -> list[dict]:
|
||||
"""What an episode's search includes: its patient, its steps, its M-CHAT, its diagnosis and its study EEG."""
|
||||
"""What an episode's search includes: its patient, its steps, its M-CHAT, its ADOS-2, its diagnosis and its study
|
||||
EEG."""
|
||||
from sqlalchemy import select
|
||||
|
||||
persons = tea._rows(queries, select(tea.PERSONS).where(tea.PERSONS.c.pac_id == e.child["pac_id"]))
|
||||
resources = [tea.patient(e.child["pac_id"], persons[0]["fecha_nacimiento"] if persons else None, simulated),
|
||||
pac_id = e.child["pac_id"]
|
||||
persons = tea._rows(queries, select(tea.PERSONS).where(tea.PERSONS.c.pac_id == pac_id))
|
||||
ados2 = tea.ados2_observation(tea._rows(queries, select(tea.ADOS2).where(tea.ADOS2.c.pac_id == pac_id)),
|
||||
e.pseudonym, simulated)
|
||||
resources = [tea.patient(pac_id, persons[0]["fecha_nacimiento"] if persons else None, simulated),
|
||||
tea.care_plan(e, simulated)]
|
||||
resources += [r for r in (tea.mchat_observation(e, simulated), tea.condition(e, simulated)) if r]
|
||||
resources += [r for r in (tea.mchat_observation(e, simulated), ados2, tea.condition(e, simulated)) if r]
|
||||
if (eeg := e.study_eeg()) is not None:
|
||||
resources += tea.eeg_resources(eeg, e.pseudonym, e.metrics, [], simulated)
|
||||
return resources
|
||||
|
||||
@@ -120,15 +120,9 @@ def _proportion_cells(definition, counts: Counts, excluded: int | None = None) -
|
||||
|
||||
|
||||
def _label(spec: dict, value: str) -> str | None:
|
||||
"""A stratum value's label: from `valores` as a map of values to labels, or as a list of entries with `etiqueta`
|
||||
(a timeline stratum's), or `resto_etiqueta` for its `resto`."""
|
||||
"""A stratum value's label, when the stratum's `valores` maps values to labels."""
|
||||
labels_of = spec.get("valores")
|
||||
if isinstance(labels_of, dict):
|
||||
return labels_of.get(value)
|
||||
if isinstance(labels_of, list):
|
||||
found = [v.get("etiqueta") for v in labels_of if isinstance(v, dict) and v.get("valor") == value]
|
||||
return found[0] if found else (spec.get("resto_etiqueta") if value == spec.get("resto") else None)
|
||||
return None
|
||||
return labels_of.get(value) if isinstance(labels_of, dict) else None
|
||||
|
||||
|
||||
def _stratum_value(stratifier: str, value: str, display: str | None = None) -> dict:
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
"""La lista de seguimiento de CaCu (T-24d): `GET /cacu/seguimiento`.
|
||||
"""La lista de seguimiento de CaCu (T-24d): `GET /cacu/seguimiento`, solo en DEV.
|
||||
|
||||
GET /cacu/seguimiento?corte=AAAA-MM-DD&meses=&estatus=&page=&page_size=
|
||||
|
||||
Es dato por paciente, sobre datos simulados: toda respuesta lleva `simulado: true`. La ruta se registra
|
||||
siempre; quién puede verla lo decidirá una regla de acceso. La lista la arma `webapi.follow_up.listing`; aquí solo se valida,
|
||||
Es dato por paciente: **solo se registra en DEV** (con `DEV_REVISION`, que define el despliegue de
|
||||
`deploy/dev`) y con datos simulados; toda respuesta lleva `simulado: true`. Fuera de DEV la ruta no
|
||||
existe (404). La lista la arma el kit (`webapi.follow_up.listing`); aquí solo se valida,
|
||||
se abre la sesión y se traducen los errores.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import warnings
|
||||
from collections.abc import Callable
|
||||
from datetime import date
|
||||
|
||||
@@ -23,13 +23,12 @@ DEFAULT_SALT = "dev-simulado" # los datos de DEV son simulados; con datos reale
|
||||
|
||||
|
||||
def in_dev() -> bool:
|
||||
"""Obsoleta: las rutas por paciente ya no dependen de `DEV_REVISION` y nada la llama. Se quitará."""
|
||||
warnings.warn("in_dev() está obsoleta: las rutas por paciente se registran siempre", DeprecationWarning, stacklevel=2)
|
||||
"""Si esta WebApi corre en el despliegue de DEV (`deploy/dev/compose.yml` define `DEV_REVISION`)."""
|
||||
return bool(os.environ.get("DEV_REVISION"))
|
||||
|
||||
|
||||
def follow_up_blueprint(get_session: Callable[[], Session]) -> Blueprint:
|
||||
"""El blueprint de la lista, para registrarlo con `url_prefix="/cacu"`."""
|
||||
"""El blueprint de la lista, para registrarlo con `url_prefix="/cacu"` solo en DEV."""
|
||||
blueprint = Blueprint("cacu_seguimiento", __name__)
|
||||
|
||||
@blueprint.get("/seguimiento")
|
||||
|
||||
+7
-33
@@ -15,7 +15,6 @@ from __future__ import annotations
|
||||
|
||||
import fcntl
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
@@ -24,7 +23,7 @@ from collections import Counter, defaultdict
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any, Callable, Iterable
|
||||
from typing import TYPE_CHECKING, Any, Iterable
|
||||
|
||||
from webapi.imports.schemas.classify import ErrorCategory
|
||||
|
||||
@@ -32,11 +31,7 @@ if TYPE_CHECKING:
|
||||
from webapi.imports.schemas.service import BatchValidationResult
|
||||
from webapi.imports.services.import_service import ImportSource
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
SCHEMA_VERSION = 1
|
||||
# Longest caption, in words, that document discovery reports.
|
||||
CAPTION_MAX_WORDS = 6
|
||||
_SHAPE_MAX = 40
|
||||
_MESSAGE_MAX = 300
|
||||
_QUOTED = re.compile(r"'[^']*'|\"[^\"]*\"")
|
||||
@@ -62,12 +57,11 @@ def value_shape(value: Any) -> str:
|
||||
return shape + ("…" if len(text) > _SHAPE_MAX else "")
|
||||
|
||||
|
||||
def column_label(name: Any, *, max_words: int = 4) -> str:
|
||||
def column_label(name: Any) -> str:
|
||||
"""A source column name as it can be logged: verbatim when it looks like a
|
||||
header, its shape when it looks like data. A document caption, already
|
||||
cut at a colon, may run to more words (`max_words`) than a header."""
|
||||
header, its shape when it looks like data."""
|
||||
text = str(name).strip()
|
||||
if len(text) > _SHAPE_MAX or text.count(" ") >= max_words or _VALUE_LIKE.search(text):
|
||||
if len(text) > _SHAPE_MAX or text.count(" ") > 3 or _VALUE_LIKE.search(text):
|
||||
return value_shape(text)
|
||||
return text
|
||||
|
||||
@@ -134,10 +128,9 @@ class _SourceAudit:
|
||||
self.rows: dict[str, Any] = {"leidas": 0}
|
||||
self.links: dict[str, int] = {}
|
||||
self.warnings: Counter = Counter()
|
||||
self.captions: Counter = Counter()
|
||||
|
||||
def observe_rows(self, rows: Iterable[dict[str, Any] | None]) -> None:
|
||||
mapped = set(self.source.column_mapping.values()) | set(self.source.derived) | set(self.source.defaults)
|
||||
mapped = set(self.source.column_mapping.values()) | set(self.source.defaults)
|
||||
merged = 0
|
||||
for row in rows:
|
||||
self.rows["leidas"] += 1
|
||||
@@ -171,15 +164,6 @@ class _SourceAudit:
|
||||
self.rows.update(insertadas=created, actualizadas=updated, rechazadas_por_conflicto=conflicts)
|
||||
self.links = dict(linked)
|
||||
|
||||
def observe_captions(self, count: Callable[[], Counter]) -> None:
|
||||
"""Captions the source's documents print that the import didn't
|
||||
use (`ImportSource.unused_captions`). Best-effort: the report must
|
||||
never be what makes an import fail."""
|
||||
try:
|
||||
self.captions = Counter(count())
|
||||
except Exception:
|
||||
log.warning("no se pudieron contar las etiquetas sin usar de %s", self.source.target, exc_info=True)
|
||||
|
||||
def observe_warnings(self, warnings: Iterable[dict[str, Any]]) -> None:
|
||||
for warning in warnings:
|
||||
self.warnings[f"{warning.get('category')}:{warning.get('field')}"] += 1
|
||||
@@ -187,14 +171,13 @@ class _SourceAudit:
|
||||
def as_dict(self, threshold: int) -> dict[str, Any]:
|
||||
spec_fields = self.source.spec.schema.model_fields
|
||||
required = {name for name, info in spec_fields.items() if info.is_required()}
|
||||
mapped = set(self.source.column_mapping.values()) | set(self.source.derived)
|
||||
mapped = set(self.source.column_mapping.values())
|
||||
fixed = set(self.source.defaults)
|
||||
out: dict[str, Any] = {
|
||||
"destino": self.source.target,
|
||||
"origen": _source_origin(self.source),
|
||||
"mapeo": {
|
||||
"columnas_origen": sorted(column_label(c) for c in self.source.source_columns),
|
||||
"campos_derivados": {name: rule.op for name, rule in sorted(self.source.derived.items())},
|
||||
"columnas_origen": sorted(column_label(c) for c in self.source.column_mapping),
|
||||
"campos_mapeados": sorted(mapped),
|
||||
"campos_con_valor_fijo": sorted(fixed),
|
||||
"campos_sin_mapear": sorted(set(spec_fields) - mapped - fixed),
|
||||
@@ -207,15 +190,6 @@ class _SourceAudit:
|
||||
out["vinculos_resueltos"] = self.links
|
||||
if self.warnings:
|
||||
out["advertencias"] = dict(self.warnings)
|
||||
if self.captions:
|
||||
# Captions only, and only those enough records print: a caption
|
||||
# seen once or twice can be a misread line holding a value.
|
||||
out["etiquetas_sin_usar"] = {
|
||||
column_label(c, max_words=CAPTION_MAX_WORDS): n for c, n in self.captions.most_common() if n >= threshold
|
||||
}
|
||||
rare = sum(1 for n in self.captions.values() if n < threshold)
|
||||
if rare:
|
||||
out["etiquetas_sin_usar_poco_frecuentes"] = rare
|
||||
return out
|
||||
|
||||
|
||||
|
||||
@@ -1,27 +1,19 @@
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
import threading
|
||||
import unicodedata
|
||||
from collections import OrderedDict
|
||||
from importlib.metadata import PackageNotFoundError
|
||||
from importlib.metadata import version as package_version
|
||||
from typing import Any, ClassVar, Iterator
|
||||
from typing import Any, ClassVar
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from extraction import DocumentExtractor, ExtractedRecord, ExtractionError, make_segmenter, read_document, reader_for
|
||||
from extraction.readers import PdfReader, combine_pages, supported_extensions
|
||||
from extraction.nlp.ranking import examples_for, same_value
|
||||
from extraction.segmentation import SEGMENTERS
|
||||
from webapi.imports.connectors.base import decode_file
|
||||
from webapi.imports.connectors.document_columns import DocumentBatch, DocumentColumns, document_bytes # noqa: F401
|
||||
from webapi.imports.connectors.errors import ConnectorError
|
||||
from webapi.imports.connectors.registry import register_connector
|
||||
from webapi.imports.connectors.sql import SqlConnector
|
||||
from webapi.imports.connectors.tabular import DataFrameConnector
|
||||
from webapi.imports.schemas.field_specs import field_specs_for, foreign_subjects_for, key_field_for, subject_for
|
||||
from webapi.imports.schemas.field_specs import field_specs_for, key_field_for
|
||||
from webapi.imports.schemas.registry import ENTITY_REGISTRY
|
||||
|
||||
DOCUMENT_COLUMN = "documento"
|
||||
@@ -29,8 +21,6 @@ IMAGE_COLUMN = "imagen"
|
||||
CONFIDENCE_COLUMN = "confianza_extraccion"
|
||||
SOURCES_COLUMN = "origen"
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class _ResultCache:
|
||||
"""OCR over a stack of scans is slow, and the stateless API runs the
|
||||
@@ -38,11 +28,11 @@ class _ResultCache:
|
||||
per worker for the last few distinct requests."""
|
||||
|
||||
def __init__(self, size: int = 8):
|
||||
self._items: OrderedDict[str, Any] = OrderedDict()
|
||||
self._items: OrderedDict[str, list[ExtractedRecord]] = OrderedDict()
|
||||
self._size = size
|
||||
self._lock = threading.Lock()
|
||||
|
||||
def get_or_compute(self, key: str, compute) -> Any:
|
||||
def get_or_compute(self, key: str, compute) -> list[ExtractedRecord]:
|
||||
with self._lock:
|
||||
if key in self._items:
|
||||
self._items.move_to_end(key)
|
||||
@@ -58,50 +48,24 @@ class _ResultCache:
|
||||
_CACHE = _ResultCache()
|
||||
|
||||
|
||||
def _files_from_sql(sql: dict[str, Any]) -> DocumentBatch:
|
||||
"""The documents of a SQL table or query (connected the same way
|
||||
`SqlConnector` is), read as `DocumentColumns` describes: `column` or
|
||||
`columns` hold them, and `key_column`/`name_by`, `group_column`/
|
||||
`group_by` and `fields` name, group and carry values for them."""
|
||||
if not sql.get("table") and not sql.get("query"):
|
||||
raise ConnectorError("falta table o query")
|
||||
spec = DocumentColumns.parse(sql)
|
||||
connector = SqlConnector.connect(sql)
|
||||
connector = (
|
||||
connector.select_query(sql["query"]) if sql.get("query") else connector.select_table(sql["table"], schema=sql.get("schema"))
|
||||
)
|
||||
return spec.assemble(connector.read_rows({column: column for column in spec.source_columns()}))
|
||||
|
||||
|
||||
@register_connector
|
||||
class DocumentConnector(DataFrameConnector):
|
||||
"""Clinical documents that are not tables: one report per patient,
|
||||
several pages per patient, many patients per file, scans, free text —
|
||||
uploaded directly, or read one row at a time from a SQL source whose
|
||||
`payload` carries `sql` (a connection plus `table`/`query`, `column`
|
||||
and `key_column`) instead of `files`; either way, every row's content
|
||||
reaches the same extraction, PDF, image or plain text alike.
|
||||
several pages per patient, many patients per file, scans, free text.
|
||||
|
||||
Every file is read page by page (text layer or OCR; plain text as its
|
||||
own lines), split into per-patient records, and the target entity's
|
||||
fields are extracted from labels and narrative text. Records of the
|
||||
same patient found in other pages or files — or rows — are merged.
|
||||
Each row also carries the record's pages as a PDF (`documento`),
|
||||
mappable to the entity's file column, when the source produced one.
|
||||
Every file is read page by page (text layer or OCR), split into
|
||||
per-patient records, and the target entity's fields are extracted from
|
||||
labels and narrative text. Records of the same patient found in other
|
||||
pages or files are merged. Each row also carries the record's pages as
|
||||
a PDF (`documento`), mappable to the entity's file column.
|
||||
|
||||
A SQL source's `sql.fields` (`{target_field: sql_column}`) carries other
|
||||
columns of the same row straight through as that row's values for those
|
||||
fields, overriding whatever the document's own text parses to — a
|
||||
source's own patient or study id is a structured join key, not a guess,
|
||||
so it wins even over a page that prints nothing recognizable, or
|
||||
prints something else entirely. Corrections made while reviewing
|
||||
travel in `overrides` (`{"<row>": {"field": value}}`) and win over
|
||||
both.
|
||||
Corrections made while reviewing travel in `overrides`
|
||||
(`{"<row>": {"field": value}}`) and win over the extracted value.
|
||||
"""
|
||||
|
||||
kind = "document"
|
||||
label = "Documentos clínicos"
|
||||
description = "Reportes, formatos y notas en PDF, imagen o texto; los campos se extraen del contenido"
|
||||
description = "Reportes, formatos y notas en PDF o imagen; los campos se extraen del texto libre"
|
||||
category = "document"
|
||||
icon = "document_scanner"
|
||||
extensions: ClassVar[tuple[str, ...]] = tuple(supported_extensions())
|
||||
@@ -116,10 +80,6 @@ class DocumentConnector(DataFrameConnector):
|
||||
ocr_mode: str = "auto",
|
||||
key_pattern: str | None = None,
|
||||
overrides: dict[str, dict[str, Any]] | None = None,
|
||||
source_fields: dict[str, dict[str, Any]] | None = None,
|
||||
record_keys: dict[str, str] | None = None,
|
||||
include_pattern: str | None = None,
|
||||
exclude_pattern: str | None = None,
|
||||
):
|
||||
if not files:
|
||||
raise ConnectorError("no se recibieron documentos")
|
||||
@@ -132,12 +92,6 @@ class DocumentConnector(DataFrameConnector):
|
||||
raise ConnectorError(f"ocr_mode desconocido {ocr_mode!r}")
|
||||
self.files = files
|
||||
self.target = target
|
||||
self.domain = target.split(".", 1)[0]
|
||||
self.subject = subject_for(entity)
|
||||
self.foreign = foreign_subjects_for(entity)
|
||||
# The entity's column for the extraction version that filled it, when it has one.
|
||||
self.nlp_field = next((name for name in entity.schema.model_fields if name.endswith("_nlp_version")), None)
|
||||
self.ranker = _ranker(self.domain)
|
||||
self.specs = field_specs_for(entity, key_pattern=key_pattern)
|
||||
self.key_field = key_field_for(entity)
|
||||
self.segmentation = segmentation
|
||||
@@ -145,37 +99,19 @@ class DocumentConnector(DataFrameConnector):
|
||||
self.ocr_mode = ocr_mode
|
||||
self.key_pattern = key_pattern
|
||||
self.overrides = {str(k): v for k, v in (overrides or {}).items()}
|
||||
self.source_fields = {str(k): v for k, v in (source_fields or {}).items()}
|
||||
self.record_keys = {str(k): str(v) for k, v in (record_keys or {}).items()}
|
||||
self.include_pattern = _compile_filter(include_pattern, "include_pattern")
|
||||
self.exclude_pattern = _compile_filter(exclude_pattern, "exclude_pattern")
|
||||
self.skipped: list[dict[str, str]] = []
|
||||
known = {spec.name for spec in self.specs}
|
||||
unknown = sorted({name for values in self.source_fields.values() for name in values} - known)
|
||||
if unknown:
|
||||
raise ConnectorError(f"fields desconocidos para {target}: {', '.join(unknown)}")
|
||||
self._df: pd.DataFrame | None = None
|
||||
|
||||
@classmethod
|
||||
def from_payload(cls, payload: dict[str, Any]) -> "DocumentConnector":
|
||||
if payload.get("sql"):
|
||||
documents = _files_from_sql(payload["sql"])
|
||||
else:
|
||||
documents = DocumentBatch(
|
||||
files=[(f.get("name") or f"documento_{i}", decode_file(f)) for i, f in enumerate(payload.get("files") or [], 1)]
|
||||
)
|
||||
files = [(f.get("name") or f"documento_{i}", decode_file(f)) for i, f in enumerate(payload.get("files") or [], 1)]
|
||||
return cls(
|
||||
documents.files,
|
||||
files,
|
||||
target=payload["target"],
|
||||
segmentation=payload.get("segmentation", "auto"),
|
||||
pages_per_record=payload.get("pages_per_record", 1),
|
||||
ocr_mode=payload.get("ocr_mode", "auto"),
|
||||
key_pattern=payload.get("key_pattern") or None,
|
||||
overrides=payload.get("overrides"),
|
||||
source_fields=documents.source_fields,
|
||||
record_keys=documents.record_keys,
|
||||
include_pattern=payload.get("include_pattern") or None,
|
||||
exclude_pattern=payload.get("exclude_pattern") or None,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -187,119 +123,41 @@ class DocumentConnector(DataFrameConnector):
|
||||
|
||||
@property
|
||||
def records(self) -> list[ExtractedRecord]:
|
||||
records, self.skipped = _CACHE.get_or_compute(self._cache_key(), self._extract)
|
||||
return records
|
||||
return _CACHE.get_or_compute(self._cache_key(), self._extract)
|
||||
|
||||
def _extract(self) -> tuple[list[ExtractedRecord], list[dict[str, str]]]:
|
||||
documents, skipped = [], []
|
||||
for name, raw in self.files:
|
||||
try:
|
||||
document = read_document(name, raw, ocr_mode=self.ocr_mode)
|
||||
except ExtractionError as exc:
|
||||
skipped.append({"document": name, "reason": f"ilegible: {exc}"})
|
||||
continue
|
||||
reason = self._filtered_out(document)
|
||||
if reason:
|
||||
skipped.append({"document": name, "reason": reason})
|
||||
continue
|
||||
documents.append(document)
|
||||
if not documents:
|
||||
detail = "; ".join(f"{s['document']}: {s['reason']}" for s in skipped[:5])
|
||||
raise ConnectorError(f"ningún documento se pudo usar ({detail})")
|
||||
def _extract(self) -> list[ExtractedRecord]:
|
||||
try:
|
||||
documents = [read_document(name, raw, ocr_mode=self.ocr_mode) for name, raw in self.files]
|
||||
except ExtractionError as exc:
|
||||
raise ConnectorError(str(exc)) from exc
|
||||
segmenter = make_segmenter(
|
||||
self.segmentation,
|
||||
key=next((s for s in self.specs if s.name == self.key_field), None),
|
||||
pages_per_record=self.pages_per_record,
|
||||
)
|
||||
records = DocumentExtractor(
|
||||
self.specs, key_field=self.key_field, segmenter=segmenter, subject=self.subject, foreign=self.foreign, ranker=self.ranker
|
||||
).extract(documents, source_fields=self.source_fields, record_keys=self.record_keys)
|
||||
return records, skipped
|
||||
|
||||
@property
|
||||
def nlp_version(self) -> str:
|
||||
"""The extraction code's version and the ranker's (`extraccion:<n>`), when one was used."""
|
||||
try:
|
||||
code = package_version("extraction")
|
||||
except PackageNotFoundError:
|
||||
code = "dev"
|
||||
return f"extraction {code}" + (f" + {self.ranker.version}" if self.ranker is not None and self.ranker.version else "")
|
||||
|
||||
def _filtered_out(self, document) -> str | None:
|
||||
"""Why a document is left out by `include_pattern`/`exclude_pattern`,
|
||||
matched case- and accent-insensitively against all of its text,
|
||||
so a source mixing several kinds of report feeds each target only
|
||||
its own."""
|
||||
text = "\n".join(page.text for page in document.pages)
|
||||
plain = _unaccented(text)
|
||||
if self.include_pattern and not (self.include_pattern.search(text) or self.include_pattern.search(plain)):
|
||||
return "no coincide con include_pattern"
|
||||
if self.exclude_pattern and (self.exclude_pattern.search(text) or self.exclude_pattern.search(plain)):
|
||||
return "coincide con exclude_pattern"
|
||||
return None
|
||||
return DocumentExtractor(self.specs, key_field=self.key_field, segmenter=segmenter).extract(documents)
|
||||
|
||||
def _cache_key(self) -> str:
|
||||
digest = hashlib.sha256()
|
||||
for name, raw in self.files:
|
||||
digest.update(name.encode())
|
||||
digest.update(hashlib.sha256(raw).digest())
|
||||
config = [
|
||||
self.target,
|
||||
self.nlp_version,
|
||||
self.segmentation,
|
||||
self.pages_per_record,
|
||||
self.ocr_mode,
|
||||
self.key_pattern,
|
||||
self.source_fields,
|
||||
self.record_keys,
|
||||
self.include_pattern.pattern if self.include_pattern else None,
|
||||
self.exclude_pattern.pattern if self.exclude_pattern else None,
|
||||
]
|
||||
digest.update(json.dumps(config, sort_keys=True, default=str).encode())
|
||||
config = [self.target, self.segmentation, self.pages_per_record, self.ocr_mode, self.key_pattern]
|
||||
digest.update(json.dumps(config).encode())
|
||||
return digest.hexdigest()
|
||||
|
||||
# -- rows -----------------------------------------------------------------
|
||||
|
||||
def _dataframe(self) -> pd.DataFrame:
|
||||
if self._df is None:
|
||||
columns = (
|
||||
[spec.name for spec in self.specs]
|
||||
+ ([self.nlp_field] if self.nlp_field else [])
|
||||
+ self.caption_columns()
|
||||
+ [DOCUMENT_COLUMN, IMAGE_COLUMN, CONFIDENCE_COLUMN, SOURCES_COLUMN]
|
||||
)
|
||||
columns = [spec.name for spec in self.specs] + [DOCUMENT_COLUMN, IMAGE_COLUMN, CONFIDENCE_COLUMN, SOURCES_COLUMN]
|
||||
rows = [self._row(index, record) for index, record in enumerate(self.records)]
|
||||
self._df = pd.DataFrame(rows, columns=columns, dtype=object)
|
||||
return self._df
|
||||
|
||||
def caption_columns(self) -> list[str]:
|
||||
"""Every caption the documents print that no field of the target
|
||||
claims, in the order first seen: columns of their own, mappable
|
||||
and usable in derived fields like any column of a table."""
|
||||
reserved = {spec.name for spec in self.specs} | {DOCUMENT_COLUMN, IMAGE_COLUMN, CONFIDENCE_COLUMN, SOURCES_COLUMN}
|
||||
columns: list[str] = []
|
||||
for record in self.records:
|
||||
for found in record.discovered:
|
||||
name = _caption_column(found.caption, reserved)
|
||||
if name not in columns:
|
||||
columns.append(name)
|
||||
return columns
|
||||
|
||||
def record_rows(self) -> Iterator[tuple[dict[str, Any], list[str]]]:
|
||||
"""Each record's row (overrides applied, its captions as columns,
|
||||
its pages as `documento`) with the names of the documents it was
|
||||
read from."""
|
||||
for index, record in enumerate(self.records):
|
||||
yield self._row(index, record), [source.document for source in record.sources]
|
||||
|
||||
def _row(self, index: int, record: ExtractedRecord) -> dict[str, Any]:
|
||||
row: dict[str, Any] = record.row()
|
||||
reserved = {spec.name for spec in self.specs} | {DOCUMENT_COLUMN, IMAGE_COLUMN, CONFIDENCE_COLUMN, SOURCES_COLUMN}
|
||||
for found in record.discovered:
|
||||
row.setdefault(_caption_column(found.caption, reserved), found.value)
|
||||
row.update(self.overrides.get(str(index), {}))
|
||||
if self.nlp_field and record.values:
|
||||
row[self.nlp_field] = self.nlp_version
|
||||
row[DOCUMENT_COLUMN] = self._record_pdf(record)
|
||||
row[IMAGE_COLUMN] = self._record_image(record)
|
||||
row[CONFIDENCE_COLUMN] = round(record.confidence, 3)
|
||||
@@ -349,13 +207,7 @@ class DocumentConnector(DataFrameConnector):
|
||||
"index": index,
|
||||
"key": record.key,
|
||||
"confidence": round(record.confidence, 3),
|
||||
"on_topic": record.on_topic,
|
||||
"fields": fields,
|
||||
"alternatives": {
|
||||
name: _alternatives(proposed, record.values.get(name))
|
||||
for name, proposed in record.candidates.items()
|
||||
if _alternatives(proposed, record.values.get(name))
|
||||
},
|
||||
"missing": [s.name for s in self.specs if s.required and s.name not in fields],
|
||||
"conflicts": [
|
||||
{"field": c.field, "kept": c.kept.to_dict(), "discarded": c.discarded.to_dict()}
|
||||
@@ -371,109 +223,4 @@ class DocumentConnector(DataFrameConnector):
|
||||
return report
|
||||
|
||||
def metadata(self) -> dict[str, Any]:
|
||||
return {
|
||||
"records": len(self.records),
|
||||
"key_field": self.key_field,
|
||||
"documents": [name for name, _ in self.files],
|
||||
"skipped": self.skipped,
|
||||
"nlp_version": self.nlp_version,
|
||||
}
|
||||
|
||||
# -- learning -------------------------------------------------------------
|
||||
|
||||
def reviewed(self) -> list[tuple[ExtractedRecord, dict[str, Any]]]:
|
||||
"""The records a person corrected while reviewing, each with what is
|
||||
known to be right about it: the corrected fields, and every other
|
||||
field as it was extracted, since whoever corrected the record read
|
||||
it. Fields a correction emptied are known to be empty."""
|
||||
reviewed = []
|
||||
for index, record in enumerate(self.records):
|
||||
corrections = self.overrides.get(str(index))
|
||||
if not corrections:
|
||||
continue
|
||||
truth: dict[str, Any] = {name: value.value for name, value in record.values.items()}
|
||||
truth.update({name: (None if value in ("", None) else value) for name, value in corrections.items()})
|
||||
known = {spec.name for spec in self.specs}
|
||||
reviewed.append((record, {name: value for name, value in truth.items() if name in known}))
|
||||
return reviewed
|
||||
|
||||
def learning_examples(self) -> tuple[list, dict[str, int], int]:
|
||||
"""Examples for the ranker from the reviewed records
|
||||
(`extraction.nlp.ranking.examples_for`), per field how many right
|
||||
values no candidate had proposed, and how many records they came from."""
|
||||
examples: list = []
|
||||
unreachable: dict[str, int] = {}
|
||||
reviewed = self.reviewed()
|
||||
for record, truth in reviewed:
|
||||
examples.extend(examples_for(self.specs, record.candidates, truth))
|
||||
for name, value in truth.items():
|
||||
if value is not None and not any(same_value(c.value, value) for c in record.candidates.get(name, ())):
|
||||
unreachable[name] = unreachable.get(name, 0) + 1
|
||||
return examples, unreachable, len(reviewed)
|
||||
|
||||
|
||||
def _ranker(domain: str):
|
||||
"""The domain's extraction ranker in the model registry, or `None` (rank by
|
||||
confidence) when there is none or the registry can't be read."""
|
||||
try:
|
||||
from models.io.extraction_ranker import current
|
||||
|
||||
return current(domain)
|
||||
except Exception as exc: # noqa: BLE001 - extraction must work without the registry
|
||||
logger.warning("sin ranker de extracción para %s: %s", domain, exc)
|
||||
return None
|
||||
|
||||
|
||||
def _alternatives(proposed: list, chosen) -> list[dict[str, Any]]:
|
||||
"""The other values the extractors proposed for a field, best first, for a reviewer to pick from."""
|
||||
seen, found = set(), []
|
||||
for candidate in sorted(proposed, key=lambda c: -c.confidence):
|
||||
if chosen is not None and same_value(candidate.value, chosen.value):
|
||||
continue
|
||||
key = json.dumps(candidate.to_dict()["value"], default=str)
|
||||
if key in seen:
|
||||
continue
|
||||
seen.add(key)
|
||||
found.append({**candidate.to_dict(), "confidence": round(candidate.confidence, 3)})
|
||||
return found[:5]
|
||||
|
||||
|
||||
def _caption_column(caption: str, reserved: set[str]) -> str:
|
||||
"""A discovered caption as a column name, kept apart from the target's
|
||||
own fields and the connector's bookkeeping columns."""
|
||||
name = " ".join(caption.split())
|
||||
return f"texto: {name}" if name in reserved else name
|
||||
|
||||
|
||||
def _compile_filter(pattern: str | None, name: str) -> re.Pattern | None:
|
||||
if not pattern:
|
||||
return None
|
||||
try:
|
||||
return re.compile(pattern, re.I)
|
||||
except re.error as exc:
|
||||
raise ConnectorError(f"{name} no es una expresión regular válida: {exc}") from exc
|
||||
|
||||
|
||||
def _unaccented(text: str) -> str:
|
||||
return "".join(ch for ch in unicodedata.normalize("NFKD", text) if not unicodedata.combining(ch))
|
||||
|
||||
|
||||
DOCUMENT_OPTIONS = ("segmentation", "pages_per_record", "ocr_mode", "key_pattern", "overrides", "include_pattern", "exclude_pattern")
|
||||
|
||||
|
||||
def document_options(raw: dict[str, Any]) -> dict[str, Any]:
|
||||
"""The extraction settings `DocumentConnector` takes, out of a request."""
|
||||
return {name: raw[name] for name in DOCUMENT_OPTIONS if raw.get(name) not in (None, "")}
|
||||
|
||||
|
||||
def connector_for_batch(batch: DocumentBatch, target: str, options: dict[str, Any]) -> "DocumentConnector":
|
||||
"""A `DocumentConnector` over documents read from a source's columns,
|
||||
their row values restricted to the fields extraction knows."""
|
||||
entity = ENTITY_REGISTRY.get(target)
|
||||
if entity is None:
|
||||
raise ConnectorError(f"destino desconocido: {target!r}")
|
||||
known = {spec.name for spec in field_specs_for(entity)}
|
||||
source_fields = {name: {k: v for k, v in values.items() if k in known} for name, values in batch.source_fields.items()}
|
||||
return DocumentConnector(
|
||||
batch.files, target=target, source_fields=source_fields, record_keys=batch.record_keys, **document_options(options)
|
||||
)
|
||||
return {"records": len(self.records), "key_field": self.key_field, "documents": [name for name, _ in self.files]}
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
"""Documents stored in the columns of any tabular source: a SQL table or
|
||||
query, a CSV or Excel sheet, a JSON list. Each non-empty cell of a document
|
||||
column becomes one document; the rest of its row travels with it as values
|
||||
the extraction must trust over the page, and an optional grouping decides
|
||||
which documents form one record.
|
||||
|
||||
A cell may hold the file itself (binary), the same file written as hex or
|
||||
base64 text, or plain text; `document_bytes` tells them apart.
|
||||
"""
|
||||
import base64
|
||||
import binascii
|
||||
import re
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Iterable
|
||||
|
||||
from webapi.imports.connectors.errors import ConnectorError
|
||||
from webapi.imports.mapping.derived import Derivation, rule_from
|
||||
|
||||
_HEX = re.compile(r"^(?:0x)?(?:[0-9a-fA-F]{2})+$")
|
||||
_BASE64 = re.compile(r"^[A-Za-z0-9+/\r\n]+={0,2}$")
|
||||
DOCUMENT_MAGIC = (b"%PDF", b"\x89PNG", b"\xff\xd8\xff", b"II*\x00", b"MM\x00*", b"BM", b"RIFF", b"GIF8")
|
||||
|
||||
|
||||
def document_bytes(raw: Any) -> bytes:
|
||||
"""A stored document as bytes. Binary values pass through; text is
|
||||
checked for a binary file written out as hex or base64 before being
|
||||
taken as plain UTF-8 text."""
|
||||
if isinstance(raw, memoryview):
|
||||
raw = raw.tobytes()
|
||||
if isinstance(raw, (bytes, bytearray)):
|
||||
return bytes(raw)
|
||||
text = str(raw).strip()
|
||||
if len(text) >= 16 and _HEX.match(text):
|
||||
decoded = bytes.fromhex(text[2:] if text[:2].lower() == "0x" else text)
|
||||
if decoded.startswith(DOCUMENT_MAGIC):
|
||||
return decoded
|
||||
if len(text) >= 16 and _BASE64.match(text):
|
||||
try:
|
||||
decoded = base64.b64decode(text, validate=False)
|
||||
except (binascii.Error, ValueError):
|
||||
decoded = b""
|
||||
if decoded.startswith(DOCUMENT_MAGIC):
|
||||
return decoded
|
||||
return text.encode("utf-8")
|
||||
|
||||
|
||||
def is_document(raw: Any) -> bool:
|
||||
"""Whether a cell holds a file a document reader opens (as opposed to
|
||||
a plain value), whatever way it was stored."""
|
||||
if raw is None or isinstance(raw, (int, float, bool)):
|
||||
return False
|
||||
return document_bytes(raw).startswith(DOCUMENT_MAGIC)
|
||||
|
||||
|
||||
@dataclass
|
||||
class DocumentBatch:
|
||||
"""What the extractor receives: one `(name, bytes)` per document and,
|
||||
per document name, its authoritative values and the record it joins.
|
||||
`rows` and `row_numbers` keep, per document name, the values of the row
|
||||
it came from and that row's position (from 1)."""
|
||||
|
||||
files: list[tuple[str, bytes]] = field(default_factory=list)
|
||||
source_fields: dict[str, dict[str, Any]] = field(default_factory=dict)
|
||||
record_keys: dict[str, str] = field(default_factory=dict)
|
||||
rows: dict[str, dict[str, Any]] = field(default_factory=dict)
|
||||
row_numbers: dict[str, int] = field(default_factory=dict)
|
||||
without_documents: list[dict[str, Any]] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass
|
||||
class DocumentColumns:
|
||||
"""How to read documents out of a source's rows.
|
||||
|
||||
`columns`: the columns holding documents (one or several per row).
|
||||
`name_by`: names each row in reports (default: its row number).
|
||||
`group_by`: rows giving the same value form one record, apart from
|
||||
the same patient's other rows; without it, documents merge by the
|
||||
target's key field, as uploaded files do.
|
||||
`fields`: target fields filled from the row, trusted over the page.
|
||||
The last three take a column name, a list of columns or a `derived`
|
||||
rule (`webapi.imports.mapping.derived`)."""
|
||||
|
||||
columns: list[str]
|
||||
name_by: Derivation | None = None
|
||||
group_by: Derivation | None = None
|
||||
fields: dict[str, Derivation] = field(default_factory=dict)
|
||||
|
||||
@classmethod
|
||||
def parse(cls, raw: Any) -> "DocumentColumns":
|
||||
if not isinstance(raw, dict):
|
||||
raise ConnectorError("'documents' debe ser un objeto")
|
||||
columns = raw.get("columns", raw.get("column"))
|
||||
columns = [columns] if isinstance(columns, str) else list(columns or [])
|
||||
if not columns or not all(isinstance(column, str) and column for column in columns):
|
||||
raise ConnectorError("indique la columna (o columnas) con los documentos")
|
||||
fields = raw.get("fields") or {}
|
||||
if not isinstance(fields, dict):
|
||||
raise ConnectorError("'fields' debe ser un objeto {campo: columna o regla}")
|
||||
name_by = raw.get("name_by", raw.get("key_column"))
|
||||
group_by = raw.get("group_by", raw.get("group_column"))
|
||||
parsed = cls(
|
||||
columns=columns,
|
||||
name_by=rule_from(name_by) if name_by else None,
|
||||
group_by=rule_from(group_by) if group_by else None,
|
||||
fields={name: rule_from(rule, separator=" ") for name, rule in fields.items()},
|
||||
)
|
||||
roles = {"name_by (key_column)": [parsed.name_by], "group_by (group_column)": [parsed.group_by], "fields": list(parsed.fields.values())}
|
||||
for role, rules in roles.items():
|
||||
reused = set().union(*(rule.columns() for rule in rules if rule is not None)) & set(columns)
|
||||
if reused:
|
||||
raise ConnectorError(f"{sorted(reused)} contiene los documentos; no puede usarse también en {role}")
|
||||
return parsed
|
||||
|
||||
def columns_read_by_rules(self) -> set[str]:
|
||||
read: set[str] = set()
|
||||
for rule in [self.name_by, self.group_by, *self.fields.values()]:
|
||||
if rule is not None:
|
||||
read |= rule.columns()
|
||||
return read
|
||||
|
||||
def source_columns(self) -> set[str]:
|
||||
return set(self.columns) | self.columns_read_by_rules()
|
||||
|
||||
def assemble(
|
||||
self, raw_rows: Iterable[dict[str, Any]], mapped_rows: Iterable[dict[str, Any]] | None = None
|
||||
) -> DocumentBatch:
|
||||
"""`raw_rows` keyed by source column; `mapped_rows`, when the source
|
||||
also has a mapping, the same rows already mapped to target fields,
|
||||
whose values join `fields` as values to trust."""
|
||||
batch = DocumentBatch()
|
||||
seen: dict[str, int] = {}
|
||||
mapped = iter(mapped_rows) if mapped_rows is not None else None
|
||||
for number, raw in enumerate(raw_rows, start=1):
|
||||
values = dict(next(mapped)) if mapped is not None else {}
|
||||
values.update({name: rule.apply(raw) for name, rule in self.fields.items()})
|
||||
values = {name: value for name, value in values.items() if not _blank(value)}
|
||||
contents = [(column, raw.get(column)) for column in self.columns if not _blank(raw.get(column))]
|
||||
if not contents:
|
||||
batch.without_documents.append(values)
|
||||
continue
|
||||
base = _text(self.name_by.apply(raw)) if self.name_by else ""
|
||||
base = base or str(number)
|
||||
group = _text(self.group_by.apply(raw)) if self.group_by else ""
|
||||
for column, content in contents:
|
||||
name = base if len(self.columns) == 1 else f"{base}:{column}"
|
||||
seen[name] = seen.get(name, 0) + 1
|
||||
if seen[name] > 1:
|
||||
name = f"{name}#{seen[name]}"
|
||||
batch.files.append((name, document_bytes(content)))
|
||||
batch.source_fields[name] = values
|
||||
batch.rows[name] = values
|
||||
batch.row_numbers[name] = number
|
||||
if group:
|
||||
batch.record_keys[name] = group
|
||||
return batch
|
||||
|
||||
|
||||
def _blank(value: Any) -> bool:
|
||||
return value is None or (isinstance(value, str) and not value.strip())
|
||||
|
||||
|
||||
def _text(value: Any) -> str:
|
||||
if value is None:
|
||||
return ""
|
||||
if isinstance(value, float) and value.is_integer():
|
||||
value = int(value)
|
||||
return str(value).strip()
|
||||
@@ -1,19 +1,17 @@
|
||||
import datetime as _dt
|
||||
import importlib.util
|
||||
import re
|
||||
from contextlib import contextmanager
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, ClassVar, Iterator
|
||||
|
||||
import pandas as pd
|
||||
import sqlalchemy as sa
|
||||
import sqlglot
|
||||
from sqlalchemy.pool import NullPool
|
||||
|
||||
from webapi.imports.connectors.base import Connector, PreviewResult, SourceColumn
|
||||
from webapi.imports.connectors.errors import ConnectorError
|
||||
from webapi.imports.connectors.registry import register_connector
|
||||
from webapi.imports.connectors.sql_policy import SQLGLOT_DIALECTS, SqlSourcePolicy
|
||||
from webapi.imports.connectors.sql_policy import SqlSourcePolicy
|
||||
from webapi.imports.connectors.tabular import infer_type
|
||||
|
||||
|
||||
@@ -29,7 +27,6 @@ class SqlEngine:
|
||||
driver_module: str
|
||||
description: str = ""
|
||||
default_schema: str | None = None
|
||||
supports_instance_name: bool = False
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
@@ -70,10 +67,7 @@ class SqlConnector(Connector):
|
||||
SqlEngine("mysql", "MySQL", "mysql+pymysql", 3306, "pymysql", "Servidor MySQL 5.7+ / 8"),
|
||||
SqlEngine("mariadb", "MariaDB", "mariadb+pymysql", 3306, "pymysql", "Servidor MariaDB"),
|
||||
SqlEngine("postgresql", "PostgreSQL", "postgresql+psycopg2", 5432, "psycopg2", "Servidor PostgreSQL", "public"),
|
||||
SqlEngine(
|
||||
"mssql", "SQL Server", "mssql+pymssql", 1433, "pymssql",
|
||||
"Microsoft SQL Server 2017+ / Azure SQL", "dbo", supports_instance_name=True,
|
||||
),
|
||||
SqlEngine("mssql", "SQL Server", "mssql+pymssql", 1433, "pymssql", "Microsoft SQL Server 2017+ / Azure SQL", "dbo"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -108,27 +102,15 @@ class SqlConnector(Connector):
|
||||
raise ConnectorError(f"el controlador de {engine.label} ({engine.driver_module}) no está instalado en el servidor")
|
||||
if not server.get("host") or not server.get("database"):
|
||||
raise ConnectorError("se requieren el servidor (host) y la base de datos")
|
||||
|
||||
host, instance, embedded_port = _parse_server_address(str(server["host"]))
|
||||
if instance and not engine.supports_instance_name:
|
||||
raise ConnectorError(f"{engine.label} no admite una instancia con nombre ({server['host']!r}); indique solo el host y, si aplica, el puerto")
|
||||
|
||||
explicit_port = server.get("port")
|
||||
try:
|
||||
port = int(explicit_port) if explicit_port not in (None, "") else embedded_port
|
||||
port = int(server.get("port") or engine.default_port)
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise ConnectorError("el puerto debe ser un número") from exc
|
||||
|
||||
if instance:
|
||||
host = f"{host}\\{instance}"
|
||||
elif port is None:
|
||||
port = engine.default_port
|
||||
|
||||
return sa.engine.URL.create(
|
||||
engine.drivername,
|
||||
username=server.get("user") or None,
|
||||
password=server.get("password") or None,
|
||||
host=host,
|
||||
host=server["host"],
|
||||
port=port,
|
||||
database=server["database"],
|
||||
)
|
||||
@@ -223,7 +205,7 @@ class SqlConnector(Connector):
|
||||
if self._table is not None:
|
||||
return sa.select(self._table).subquery("source")
|
||||
if self._query:
|
||||
return _text_subquery(self._query, self.get_dialect())
|
||||
return _text_subquery(self._query)
|
||||
raise ConnectorError("no hay tabla ni consulta seleccionada")
|
||||
|
||||
def _columns(self, names: list[str], rows: list[dict[str, Any]]) -> list[SourceColumn]:
|
||||
@@ -253,87 +235,12 @@ class SqlConnector(Connector):
|
||||
conn.rollback()
|
||||
|
||||
|
||||
_ADDRESS_SCHEME_RE = re.compile(r"^[a-zA-Z][a-zA-Z0-9+.\-:]*?://")
|
||||
_ADDRESS_PORT_SEPARATORS = (",", ":")
|
||||
|
||||
|
||||
def _parse_server_address(raw: str) -> tuple[str, str | None, int | None]:
|
||||
"""Tolerates the ways a server address arrives typed or pasted from
|
||||
a SQL client, a JDBC string or a connection URI instead of a bare host: a
|
||||
leading scheme (`jdbc:sqlserver://`, `postgresql://`, `tcp:`), a
|
||||
trailing path/query/property list, surrounding whitespace, a SQL
|
||||
Server named instance (`host\\instance`), and a port given as
|
||||
`host:port` or SQL Server's `host,port` / `host\\instance,port`.
|
||||
|
||||
Returns `(host, instance, port)`, with `instance` and `port` `None`
|
||||
when absent, so the caller can leave the port unset for a named
|
||||
instance instead of forcing the engine's default one.
|
||||
"""
|
||||
address = _ADDRESS_SCHEME_RE.sub("", raw.strip(), count=1)
|
||||
if address.lower().startswith("tcp:"):
|
||||
address = address[len("tcp:") :]
|
||||
for cut in ("/", "?", ";"):
|
||||
address = address.split(cut, 1)[0]
|
||||
address = address.strip()
|
||||
|
||||
instance: str | None = None
|
||||
if "\\" in address:
|
||||
host, instance = (part.strip() for part in address.split("\\", 1))
|
||||
else:
|
||||
host = address
|
||||
|
||||
tail = instance or host
|
||||
port: int | None = None
|
||||
for sep in _ADDRESS_PORT_SEPARATORS:
|
||||
if tail.count(sep) == 1:
|
||||
prefix, suffix = (part.strip() for part in tail.split(sep))
|
||||
if suffix.isdigit():
|
||||
tail, port = prefix, int(suffix)
|
||||
break
|
||||
|
||||
if instance:
|
||||
instance = tail or None
|
||||
else:
|
||||
host = tail
|
||||
|
||||
return host, (instance or None), port
|
||||
|
||||
|
||||
def _text_subquery(query: str, dialect: str | None = None) -> sa.Subquery:
|
||||
def _text_subquery(query: str) -> sa.Subquery:
|
||||
"""Wraps policy-checked SELECT text as a derived table, so SQLAlchemy
|
||||
composes LIMIT/TOP and COUNT(*) for whichever dialect the source speaks."""
|
||||
query = _without_trailing_order_by(query, dialect)
|
||||
return sa.select(sa.literal_column("*")).select_from(sa.text(f"({query}) AS source_query")).subquery("source")
|
||||
|
||||
|
||||
_ORDER_BY = re.compile(r"\bORDER\s+BY\b", re.I)
|
||||
|
||||
|
||||
def _without_trailing_order_by(query: str, dialect: str | None) -> str:
|
||||
"""Drops a top-level `ORDER BY` that nothing limits: SQL Server refuses
|
||||
one inside a derived table, and row order means nothing to an import.
|
||||
Kept when TOP, LIMIT or OFFSET makes it choose the rows."""
|
||||
try:
|
||||
[root] = sqlglot.parse(query, read=SQLGLOT_DIALECTS.get(dialect, dialect))
|
||||
except Exception:
|
||||
return query
|
||||
if root is None or not root.args.get("order") or root.args.get("limit") or root.args.get("offset"):
|
||||
return query
|
||||
depth, quote, cut = 0, None, None
|
||||
for position, char in enumerate(query):
|
||||
if quote:
|
||||
quote = None if char == quote else quote
|
||||
elif char in "'\"[`":
|
||||
quote = "]" if char == "[" else char
|
||||
elif char == "(":
|
||||
depth += 1
|
||||
elif char == ")":
|
||||
depth -= 1
|
||||
elif depth == 0 and _ORDER_BY.match(query, position):
|
||||
cut = position
|
||||
return query[:cut].rstrip() if cut is not None else query
|
||||
|
||||
|
||||
def _sa_type_to_kind(sa_type: sa.types.TypeEngine) -> str:
|
||||
try:
|
||||
python_type = sa_type.python_type
|
||||
|
||||
@@ -22,7 +22,7 @@ from webapi.imports.connectors.errors import ConnectorError
|
||||
_DEFAULT_DIALECTS = "mysql,mariadb,postgresql,mssql"
|
||||
_DEFAULT_PORTS = {"mysql": 3306, "mariadb": 3306, "postgresql": 5432, "mssql": 1433}
|
||||
# SQLAlchemy dialect name -> sqlglot's name for it, where they differ.
|
||||
SQLGLOT_DIALECTS = {"postgresql": "postgres", "mssql": "tsql", "mariadb": "mysql"}
|
||||
_SQLGLOT_DIALECTS = {"postgresql": "postgres", "mssql": "tsql", "mariadb": "mysql"}
|
||||
# Anything that writes, wherever it sits in the tree: a top-level
|
||||
# `SELECT ... INTO table`/`INTO OUTFILE`, or a writable CTE
|
||||
# (`WITH t AS (DELETE FROM x RETURNING *) SELECT * FROM t` still parses as a
|
||||
@@ -73,7 +73,7 @@ class SqlSourcePolicy:
|
||||
if not statement:
|
||||
raise ConnectorError("la consulta no puede estar vacía")
|
||||
try:
|
||||
parsed = [node for node in sqlglot.parse(statement, read=SQLGLOT_DIALECTS.get(dialect, dialect)) if node is not None]
|
||||
parsed = [node for node in sqlglot.parse(statement, read=_SQLGLOT_DIALECTS.get(dialect, dialect)) if node is not None]
|
||||
except sqlglot.errors.ParseError as exc:
|
||||
raise ConnectorError(f"la consulta no es SQL válido: {exc}") from exc
|
||||
if len(parsed) != 1:
|
||||
|
||||
@@ -1,305 +0,0 @@
|
||||
"""Target fields computed from one or more source columns, for sources whose
|
||||
columns don't line up one-to-one with the target: a name and surnames kept
|
||||
apart where the target wants one full name, or the reverse; an id spread
|
||||
over two columns; a code that must be read out of a longer text.
|
||||
|
||||
A source's `derived` maps each target field to one rule,
|
||||
`{"op": <name>, ...params}`, plus the optional `case` (`upper`, `lower`,
|
||||
`title`) applied to the result. To add an operation, subclass `Derivation`,
|
||||
declare its `params` and register it with `@register_derivation`.
|
||||
"""
|
||||
import re
|
||||
import string
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, ClassVar
|
||||
|
||||
from webapi.imports.connectors.errors import ConnectorError
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Param:
|
||||
"""One parameter of an operation, described so a client can build its form."""
|
||||
|
||||
name: str
|
||||
kind: str # column | columns | text | integer | mapping | boolean
|
||||
label: str
|
||||
required: bool = True
|
||||
default: Any = None
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
return {"name": self.name, "kind": self.kind, "label": self.label, "required": self.required, "default": self.default}
|
||||
|
||||
|
||||
CASES = {"upper": str.upper, "lower": str.lower, "title": str.title}
|
||||
|
||||
|
||||
class Derivation(ABC):
|
||||
op: ClassVar[str]
|
||||
label: ClassVar[str]
|
||||
description: ClassVar[str]
|
||||
params: ClassVar[tuple[Param, ...]]
|
||||
|
||||
def __init__(self, rule: dict[str, Any]):
|
||||
self.args: dict[str, Any] = {}
|
||||
for param in self.params:
|
||||
value = rule.get(param.name, param.default)
|
||||
if param.required and _blank(value):
|
||||
raise ConnectorError(f"la regla {self.op!r} requiere {param.name!r}")
|
||||
if param.kind == "columns" and value is not None and not isinstance(value, list):
|
||||
raise ConnectorError(f"{param.name!r} debe ser una lista de columnas")
|
||||
self.args[param.name] = value
|
||||
self.case = rule.get("case") or None
|
||||
if self.case is not None and self.case not in CASES:
|
||||
raise ConnectorError(f"case desconocido {self.case!r} (disponibles: {', '.join(CASES)})")
|
||||
|
||||
@abstractmethod
|
||||
def columns(self) -> set[str]:
|
||||
"""The source columns this rule reads."""
|
||||
|
||||
@abstractmethod
|
||||
def compute(self, row: dict[str, Any]) -> Any: ...
|
||||
|
||||
def apply(self, row: dict[str, Any]) -> Any:
|
||||
value = self.compute(row)
|
||||
if isinstance(value, str):
|
||||
value = " ".join(value.split())
|
||||
if self.case:
|
||||
value = CASES[self.case](value)
|
||||
return value or None
|
||||
return value
|
||||
|
||||
@classmethod
|
||||
def describe(cls) -> dict[str, Any]:
|
||||
return {
|
||||
"op": cls.op,
|
||||
"label": cls.label,
|
||||
"description": cls.description,
|
||||
"params": [param.to_dict() for param in cls.params],
|
||||
}
|
||||
|
||||
|
||||
DERIVATIONS: dict[str, type[Derivation]] = {}
|
||||
|
||||
|
||||
def register_derivation(cls: type[Derivation]) -> type[Derivation]:
|
||||
DERIVATIONS[cls.op] = cls
|
||||
return cls
|
||||
|
||||
|
||||
def build_derivation(rule: Any) -> Derivation:
|
||||
if not isinstance(rule, dict):
|
||||
raise ConnectorError("cada regla de 'derived' debe ser un objeto")
|
||||
cls = DERIVATIONS.get(rule.get("op", ""))
|
||||
if cls is None:
|
||||
raise ConnectorError(f"operación desconocida {rule.get('op')!r} (disponibles: {', '.join(DERIVATIONS)})")
|
||||
return cls(rule)
|
||||
|
||||
|
||||
def _blank(value: Any) -> bool:
|
||||
return value is None or (isinstance(value, str) and not value.strip()) or value == [] or value == {}
|
||||
|
||||
|
||||
def _index(value: Any) -> int | None:
|
||||
if value in (None, ""):
|
||||
return None
|
||||
try:
|
||||
return int(value)
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise ConnectorError(f"se esperaba un número entero, no {value!r}") from exc
|
||||
|
||||
|
||||
def _text(value: Any) -> str:
|
||||
if value is None:
|
||||
return ""
|
||||
if isinstance(value, float) and value.is_integer():
|
||||
value = int(value)
|
||||
return str(value).strip()
|
||||
|
||||
|
||||
@register_derivation
|
||||
class Column(Derivation):
|
||||
op = "column"
|
||||
label = "Columna"
|
||||
description = "El valor de una columna, tal cual."
|
||||
params = (Param("column", "column", "Columna"),)
|
||||
|
||||
def columns(self) -> set[str]:
|
||||
return {self.args["column"]}
|
||||
|
||||
def compute(self, row: dict[str, Any]) -> Any:
|
||||
return row.get(self.args["column"])
|
||||
|
||||
|
||||
@register_derivation
|
||||
class Concat(Derivation):
|
||||
op = "concat"
|
||||
label = "Unir columnas"
|
||||
description = "Une los valores no vacíos de varias columnas, en orden, con un separador."
|
||||
params = (
|
||||
Param("columns", "columns", "Columnas"),
|
||||
Param("separator", "text", "Separador", required=False, default=" "),
|
||||
)
|
||||
|
||||
def columns(self) -> set[str]:
|
||||
return set(self.args["columns"])
|
||||
|
||||
def compute(self, row: dict[str, Any]) -> Any:
|
||||
parts = [_text(row.get(column)) for column in self.args["columns"]]
|
||||
separator = self.args["separator"] if self.args["separator"] is not None else " "
|
||||
return separator.join(part for part in parts if part)
|
||||
|
||||
|
||||
@register_derivation
|
||||
class Template(Derivation):
|
||||
op = "template"
|
||||
label = "Plantilla"
|
||||
description = "Arma un texto con columnas entre llaves: `{Nombre} {Apellido}`. Las columnas vacías se omiten."
|
||||
params = (Param("template", "text", "Plantilla"),)
|
||||
|
||||
def __init__(self, rule: dict[str, Any]):
|
||||
super().__init__(rule)
|
||||
try:
|
||||
self._names = [name for _, name, _, _ in string.Formatter().parse(self.args["template"]) if name]
|
||||
except ValueError as exc:
|
||||
raise ConnectorError(f"plantilla inválida: {exc}") from exc
|
||||
|
||||
def columns(self) -> set[str]:
|
||||
return set(self._names)
|
||||
|
||||
def compute(self, row: dict[str, Any]) -> Any:
|
||||
values = {name: _text(row.get(name)) for name in self._names}
|
||||
return string.Formatter().vformat(self.args["template"], (), _Fill(values))
|
||||
|
||||
|
||||
class _Fill(dict):
|
||||
def __missing__(self, key: str) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
@register_derivation
|
||||
class Split(Derivation):
|
||||
op = "split"
|
||||
label = "Tomar partes"
|
||||
description = (
|
||||
"Separa el valor de una columna y toma las partes de `start` a `stop` "
|
||||
"(se cuentan desde 0; negativas desde el final): de un nombre completo, "
|
||||
"el primer apellido es `start=-2, stop=-1`."
|
||||
)
|
||||
params = (
|
||||
Param("column", "column", "Columna"),
|
||||
Param("separator", "text", "Separador (vacío: espacios)", required=False, default=""),
|
||||
Param("start", "integer", "Desde", required=False, default=0),
|
||||
Param("stop", "integer", "Hasta (sin incluir)", required=False, default=None),
|
||||
)
|
||||
|
||||
def columns(self) -> set[str]:
|
||||
return {self.args["column"]}
|
||||
|
||||
def compute(self, row: dict[str, Any]) -> Any:
|
||||
text = _text(row.get(self.args["column"]))
|
||||
if not text:
|
||||
return None
|
||||
separator = self.args["separator"] or None
|
||||
parts = text.split(separator) if separator else text.split()
|
||||
start, stop = (_index(self.args[name]) for name in ("start", "stop"))
|
||||
return (separator or " ").join(part.strip() for part in parts[start:stop] if part.strip())
|
||||
|
||||
|
||||
@register_derivation
|
||||
class Coalesce(Derivation):
|
||||
op = "coalesce"
|
||||
label = "Primera con valor"
|
||||
description = "El valor de la primera columna, en orden, que no esté vacía."
|
||||
params = (Param("columns", "columns", "Columnas"),)
|
||||
|
||||
def columns(self) -> set[str]:
|
||||
return set(self.args["columns"])
|
||||
|
||||
def compute(self, row: dict[str, Any]) -> Any:
|
||||
for column in self.args["columns"]:
|
||||
value = row.get(column)
|
||||
if not _blank(value):
|
||||
return value
|
||||
return None
|
||||
|
||||
|
||||
@register_derivation
|
||||
class Extract(Derivation):
|
||||
op = "extract"
|
||||
label = "Extraer con patrón"
|
||||
description = "La parte del valor que coincide con una expresión regular (o su grupo `group`)."
|
||||
params = (
|
||||
Param("column", "column", "Columna"),
|
||||
Param("pattern", "text", "Expresión regular"),
|
||||
Param("group", "integer", "Grupo", required=False, default=0),
|
||||
)
|
||||
|
||||
def __init__(self, rule: dict[str, Any]):
|
||||
super().__init__(rule)
|
||||
try:
|
||||
self._regex = re.compile(self.args["pattern"], re.I)
|
||||
except re.error as exc:
|
||||
raise ConnectorError(f"expresión regular inválida: {exc}") from exc
|
||||
|
||||
def columns(self) -> set[str]:
|
||||
return {self.args["column"]}
|
||||
|
||||
def compute(self, row: dict[str, Any]) -> Any:
|
||||
match = self._regex.search(_text(row.get(self.args["column"])))
|
||||
if not match:
|
||||
return None
|
||||
try:
|
||||
return match.group(_index(self.args["group"]) or 0)
|
||||
except IndexError as exc:
|
||||
raise ConnectorError(f"la expresión no tiene el grupo {self.args['group']}") from exc
|
||||
|
||||
|
||||
@register_derivation
|
||||
class Translate(Derivation):
|
||||
op = "map"
|
||||
label = "Traducir valores"
|
||||
description = "Cambia cada valor por otro según una tabla (`M` → `Masculino`), sin distinguir mayúsculas ni espacios."
|
||||
params = (
|
||||
Param("column", "column", "Columna"),
|
||||
Param("values", "mapping", "Tabla de valores"),
|
||||
Param("keep_unmatched", "boolean", "Conservar los que no estén en la tabla", required=False, default=True),
|
||||
)
|
||||
|
||||
def __init__(self, rule: dict[str, Any]):
|
||||
super().__init__(rule)
|
||||
if not isinstance(self.args["values"], dict):
|
||||
raise ConnectorError("'values' debe ser un objeto")
|
||||
self._table = {_text(key).casefold(): value for key, value in self.args["values"].items()}
|
||||
|
||||
def columns(self) -> set[str]:
|
||||
return {self.args["column"]}
|
||||
|
||||
def compute(self, row: dict[str, Any]) -> Any:
|
||||
value = row.get(self.args["column"])
|
||||
key = _text(value).casefold()
|
||||
if key in self._table:
|
||||
return self._table[key]
|
||||
return value if self.args["keep_unmatched"] is not False else None
|
||||
|
||||
|
||||
def rule_from(value: Any, *, separator: str = " | ") -> Derivation:
|
||||
"""A rule given in short form: a column name, a list of columns (joined
|
||||
with `separator`) or a full rule object."""
|
||||
if isinstance(value, str):
|
||||
return Column({"column": value})
|
||||
if isinstance(value, list):
|
||||
return Concat({"columns": value, "separator": separator})
|
||||
return build_derivation(value)
|
||||
|
||||
|
||||
def parse_derived(raw: Any, fields: set[str]) -> dict[str, Derivation]:
|
||||
"""`{target_field: rule}` validated against the target's fields."""
|
||||
if raw in (None, {}):
|
||||
return {}
|
||||
if not isinstance(raw, dict):
|
||||
raise ConnectorError("'derived' debe ser un objeto {campo: regla}")
|
||||
unknown = sorted(set(raw) - fields)
|
||||
if unknown:
|
||||
raise ConnectorError(f"campos desconocidos en 'derived': {unknown}")
|
||||
return {field: rule_from(rule, separator=" ") for field, rule in raw.items()}
|
||||
@@ -1,160 +0,0 @@
|
||||
"""Matching OCR-discovered captions against a project's catalog, and
|
||||
minting new catalog entries when nothing matches well enough.
|
||||
|
||||
`discover_captions` (Extraction) finds `caption: value` lines no known
|
||||
`FieldSpec` already explains. For each one, this module decides whether an
|
||||
existing `resultado_id` means the same thing closely enough to reuse
|
||||
(`rapidfuzz`, tolerant of how a hospital's own report wording differs from
|
||||
the catalog's own), or whether it's a field the catalog doesn't have yet —
|
||||
in which case it's added (`add_resultado`), never silently dropped.
|
||||
"""
|
||||
import re
|
||||
import unicodedata
|
||||
from dataclasses import dataclass
|
||||
|
||||
from rapidfuzz import fuzz, process
|
||||
|
||||
from extraction.nlp import DiscoveredField
|
||||
from extraction.nlp.text import find_date, fold
|
||||
from webapi.orchestration.reference.catalogs import Catalogo, add_resultado
|
||||
from webapi.orchestration.silver.procedures import valor_de_observacion
|
||||
|
||||
# `token_sort_ratio`, not `WRatio`: `WRatio`'s partial-alignment bonus scores
|
||||
# two short, unrelated captions that merely share common words ("de", "del")
|
||||
# too high for this use (two genuinely different captions can clear 80).
|
||||
# Lower than `extraction.nlp.extractors.FUZZY_LABEL_THRESHOLD` (0-100 scale
|
||||
# here, that one 0-1): a caption is free text, not a single known label
|
||||
# tolerating only OCR noise, so it varies more from the catalog's wording.
|
||||
CAPTION_MATCH_THRESHOLD = 80.0
|
||||
CAPTION_SCORER = fuzz.token_sort_ratio
|
||||
FALLBACK_ESTUDIO_ID = "documento_externo"
|
||||
FALLBACK_ESTUDIO_ETIQUETA = "Documento externo"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class MatchedField:
|
||||
"""One discovered caption, resolved to a `resultado_id` (existing or
|
||||
just minted) with its value already shaped for `observacion`."""
|
||||
|
||||
resultado_id: str
|
||||
is_new: bool
|
||||
observacion: dict
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class _NewResultado:
|
||||
resultado_id: str
|
||||
tipo_valor: str
|
||||
|
||||
|
||||
def match_or_mint(
|
||||
discovered: list[DiscoveredField],
|
||||
*,
|
||||
proyecto: str,
|
||||
catalogo: Catalogo,
|
||||
estudio_id: str | None = None,
|
||||
mint: bool = True,
|
||||
) -> list[MatchedField]:
|
||||
"""One `MatchedField` per discovered caption, in order. With
|
||||
`mint=False`, a caption nothing in the catalog matches is left out
|
||||
instead of being added to the catalog file.
|
||||
|
||||
`estudio_id`, when the caller already knows it (the row's own
|
||||
study-type column, resolved through `codigos_hospital`), scopes which
|
||||
resultados are tried first and which estudio a minted field joins;
|
||||
without it, every resultado in the catalog is a candidate and a new
|
||||
field's estudio is guessed the same way, or falls back to
|
||||
`documento_externo`.
|
||||
"""
|
||||
labels = _resultado_labels(catalogo, estudio_id)
|
||||
valid_codes = {(v.resultado_id, v.valor_id) for v in catalogo.valores if v.estado == "vigente"}
|
||||
by_resultado_id = {r.resultado_id: r for r in catalogo.resultados}
|
||||
resolved = []
|
||||
for field in discovered:
|
||||
found = _best_match(field.caption, labels)
|
||||
if found is not None:
|
||||
resultado, is_new = by_resultado_id[found], False
|
||||
elif not mint:
|
||||
continue
|
||||
else:
|
||||
resultado = _mint(field, proyecto=proyecto, estudio_id=estudio_id, catalogo=catalogo)
|
||||
is_new = True
|
||||
value = _coerce_value(field.value, resultado.tipo_valor)
|
||||
observacion = valor_de_observacion(
|
||||
value,
|
||||
field.value,
|
||||
tipo_valor=resultado.tipo_valor,
|
||||
en_catalogo=lambda v, r=resultado.resultado_id: (r, v) in valid_codes,
|
||||
)
|
||||
resolved.append(MatchedField(resultado.resultado_id, is_new, observacion))
|
||||
return resolved
|
||||
|
||||
|
||||
def _resultado_labels(catalogo: Catalogo, estudio_id: str | None) -> dict[str, str]:
|
||||
resultados = catalogo.resultados
|
||||
if estudio_id is not None:
|
||||
of_estudio = [r for r in resultados if r.estudio_id == estudio_id]
|
||||
if of_estudio:
|
||||
resultados = of_estudio
|
||||
return {r.resultado_id: fold(r.etiqueta) for r in resultados}
|
||||
|
||||
|
||||
def _best_match(caption: str, labels: dict[str, str]) -> str | None:
|
||||
if not labels:
|
||||
return None
|
||||
found = process.extractOne(fold(caption), labels, scorer=CAPTION_SCORER, score_cutoff=CAPTION_MATCH_THRESHOLD)
|
||||
return found[2] if found is not None else None
|
||||
|
||||
|
||||
def _mint(field: DiscoveredField, *, proyecto: str, estudio_id: str | None, catalogo: Catalogo) -> _NewResultado:
|
||||
estudio = estudio_id
|
||||
estudio_etiqueta = None
|
||||
if estudio is None:
|
||||
estudio_labels = {e.estudio_id: fold(e.etiqueta) for e in catalogo.estudios}
|
||||
found = process.extractOne(fold(field.caption), estudio_labels, scorer=CAPTION_SCORER, score_cutoff=CAPTION_MATCH_THRESHOLD)
|
||||
estudio = found[2] if found is not None else None
|
||||
if estudio is None:
|
||||
estudio, estudio_etiqueta = FALLBACK_ESTUDIO_ID, FALLBACK_ESTUDIO_ETIQUETA
|
||||
tipo_valor = _infer_tipo_valor(field.value)
|
||||
resultado_id = add_resultado(
|
||||
proyecto,
|
||||
estudio_id=estudio,
|
||||
nombre=_slug(field.caption),
|
||||
etiqueta=field.caption.strip(),
|
||||
tipo_valor=tipo_valor,
|
||||
estudio_etiqueta=estudio_etiqueta,
|
||||
)
|
||||
return _NewResultado(resultado_id, tipo_valor)
|
||||
|
||||
|
||||
def _slug(text: str) -> str:
|
||||
without_accents = unicodedata.normalize("NFKD", text).encode("ascii", "ignore").decode("ascii")
|
||||
return re.sub(r"[^a-z0-9]+", "_", without_accents.lower()).strip("_") or "campo"
|
||||
|
||||
|
||||
def _infer_tipo_valor(value: str) -> str:
|
||||
if find_date(value) is not None:
|
||||
return "fecha"
|
||||
if _is_number(value):
|
||||
return "numero"
|
||||
return "texto"
|
||||
|
||||
|
||||
def _is_number(value: str) -> bool:
|
||||
try:
|
||||
float(value.strip().replace(",", "."))
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
def _coerce_value(value: str, tipo_valor: str):
|
||||
if tipo_valor == "fecha":
|
||||
found = find_date(value)
|
||||
return found[0] if found else None
|
||||
if tipo_valor in ("numero", "booleano"):
|
||||
try:
|
||||
return float(value.strip().replace(",", "."))
|
||||
except ValueError:
|
||||
return None
|
||||
return value
|
||||
@@ -8,17 +8,7 @@ import typing
|
||||
from datetime import date, datetime
|
||||
|
||||
from extraction.nlp import FieldKind, FieldSpec
|
||||
from extraction.nlp.vocabulary import (
|
||||
ANCHORS,
|
||||
CLINICAL_TERMS,
|
||||
FREE_TEXT_FIELDS,
|
||||
NEGATED_VALUES,
|
||||
PATTERNS,
|
||||
SEVERITY,
|
||||
SUBJECTS,
|
||||
UNITS,
|
||||
labels_for,
|
||||
)
|
||||
from extraction.nlp.vocabulary import CLINICAL_TERMS, FREE_TEXT_FIELDS, PATTERNS, labels_for
|
||||
from webapi.imports.schemas.registry import EntitySpec
|
||||
|
||||
# Surrogate keys, stored files and OCR bookkeeping are never read from a document.
|
||||
@@ -52,28 +42,11 @@ def field_specs_for(entity: EntitySpec, *, key_pattern: str | None = None) -> li
|
||||
scan_free_text=name in FREE_TEXT_FIELDS or (pattern is not None and pattern == key_pattern),
|
||||
multiline=kind is FieldKind.TEXT and bool(_LONG_TEXT.search(name)),
|
||||
required=info.is_required(),
|
||||
anchors=ANCHORS.get(name, ()),
|
||||
severity=SEVERITY.get(name, ()),
|
||||
negated_value=NEGATED_VALUES.get(name),
|
||||
unit=UNITS.get(name),
|
||||
)
|
||||
)
|
||||
return specs
|
||||
|
||||
|
||||
def subject_for(entity: EntitySpec) -> tuple[str, ...]:
|
||||
"""What a document feeding this entity is about (`vocabulary.SUBJECTS`)."""
|
||||
return SUBJECTS.get(entity.model.__table__.name, ())
|
||||
|
||||
|
||||
def foreign_subjects_for(entity: EntitySpec) -> tuple[str, ...]:
|
||||
"""What documents feeding other entities are about, less this one's own terms."""
|
||||
own = set(subject_for(entity))
|
||||
if not own:
|
||||
return ()
|
||||
return tuple(sorted({term for table, terms in SUBJECTS.items() if table != entity.model.__table__.name for term in terms} - own))
|
||||
|
||||
|
||||
def key_field_for(entity: EntitySpec) -> str | None:
|
||||
"""The field that identifies whose record a page belongs to."""
|
||||
fields = entity.schema.model_fields
|
||||
|
||||
@@ -15,3 +15,4 @@ class OrdenesEstudioImportSchema(ImportSchema):
|
||||
ord_id_hospital: OptionalStr = None
|
||||
ord_tipo_estudio: CatalogValue(_TIPO_ESTUDIO_CATALOG) = None
|
||||
ord_fecha: FlexDate = None
|
||||
ord_pdf_blob: Optional[bytes] = None
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
"""Writes the catalog-fallback fields a document source's records carry
|
||||
(captions no known `FieldSpec` claimed, see `extraction.nlp.discovery`)
|
||||
into the silver layer directly: one synthetic `procedimiento` per record
|
||||
per estudio its resolved fields touch, with their `observacion`s matched
|
||||
against the project's catalog (`catalog_matching`). Only a source that
|
||||
asks for it (`catalog_fallback`) gets here, and only captions the catalog
|
||||
already knows are written: the catalog is versioned with the code, so a
|
||||
running import never adds to it. Captions nothing matches are counted;
|
||||
the import report lists them (`webapi.imports.audit`).
|
||||
|
||||
There is no staging row for these — the whole point is a field outside
|
||||
today's structured schemas — so this bypasses `DESDE_STAGING` and writes
|
||||
straight through the domain's existing `carga_repository`, the same one
|
||||
`webapi.orchestration`'s `load` step uses for staging-derived batches.
|
||||
|
||||
Marked clearly apart from every staging-derived procedimiento:
|
||||
`fuente_tabla` is the sentinel `FUENTE_CATALOGO_ABIERTO`, never a real
|
||||
staging table name. `fuente_id` is the record's own natural key (not a SQL
|
||||
row's surrogate id), so reprocessing the same record later — read again
|
||||
from the SQL source, re-uploaded as a file, or corrected by hand — updates
|
||||
the same rows in place instead of duplicating them; the structured fields
|
||||
a source also carries keep going through the unmodified staging/import
|
||||
path (`commit_sources`), independently of this.
|
||||
"""
|
||||
from collections import defaultdict
|
||||
from dataclasses import dataclass
|
||||
from importlib import import_module
|
||||
|
||||
from extraction import ExtractedRecord
|
||||
|
||||
from webapi.imports.schemas.catalog_matching import MatchedField, match_or_mint
|
||||
from webapi.orchestration.reference.catalogs import Catalogo, catalogo_desde_toml, ruta_de_catalogo
|
||||
from webapi.orchestration.silver.procedures import LotePlata
|
||||
from webapi.orchestration.tables import tablas_de
|
||||
|
||||
FUENTE_CATALOGO_ABIERTO = "catalogo_abierto"
|
||||
|
||||
|
||||
@dataclass
|
||||
class CatalogCommitResult:
|
||||
proyecto: str
|
||||
records_written: int = 0
|
||||
records_without_patient: int = 0
|
||||
fields_matched: int = 0
|
||||
fields_minted: int = 0
|
||||
fields_unmatched: int = 0
|
||||
|
||||
|
||||
def commit_discovered_fields(
|
||||
records: list[ExtractedRecord], *, proyecto: str, estudio_id: str | None = None, mint: bool = False
|
||||
) -> CatalogCommitResult:
|
||||
"""A patient without a row in `persona` is counted and skipped: this
|
||||
path only fills in fields for a patient already known, it doesn't
|
||||
create one. `mint` lets unmatched captions become new catalog entries,
|
||||
written to the catalog file; the import path never sets it."""
|
||||
dominio = import_module(f"persistance.{proyecto}")
|
||||
tablas = tablas_de(proyecto)
|
||||
ruta = ruta_de_catalogo(proyecto)
|
||||
catalogo = catalogo_desde_toml(ruta, tablas=tablas)
|
||||
|
||||
result = CatalogCommitResult(proyecto=proyecto)
|
||||
procedures, observations = [], []
|
||||
for record in records:
|
||||
if not record.discovered or record.key is None:
|
||||
continue
|
||||
patients = dominio.paciente_repository.list(pac_id_hospital=record.key, limit=1)
|
||||
if not patients:
|
||||
result.records_without_patient += 1
|
||||
continue
|
||||
pac_id = patients[0].pac_id
|
||||
|
||||
matched = match_or_mint(record.discovered, proyecto=proyecto, catalogo=catalogo, estudio_id=estudio_id, mint=mint)
|
||||
result.fields_unmatched += len(record.discovered) - len(matched)
|
||||
if not matched:
|
||||
continue
|
||||
if any(field.is_new for field in matched):
|
||||
catalogo = catalogo_desde_toml(ruta, tablas=tablas) # so a later record in this batch can match it too
|
||||
matched = _fold_duplicates(matched)
|
||||
|
||||
by_estudio: dict[str, list] = defaultdict(list)
|
||||
for field in matched:
|
||||
by_estudio[field.resultado_id.split(".", 1)[0]].append(field)
|
||||
result.fields_minted += int(field.is_new)
|
||||
result.fields_matched += int(not field.is_new)
|
||||
for estudio, fields in by_estudio.items():
|
||||
key = (FUENTE_CATALOGO_ABIERTO, record.key, estudio, "reporte")
|
||||
procedures.append({"llave": key, "padres": [], "pac_id": pac_id, "fecha": None, "fecha_del_padre": False})
|
||||
observations += [
|
||||
{"procedimiento": key, "pac_id": pac_id, "resultado_id": field.resultado_id, **field.observacion}
|
||||
for field in fields
|
||||
]
|
||||
result.records_written += 1
|
||||
|
||||
if procedures:
|
||||
_sync_catalog(dominio, proyecto, tablas)
|
||||
dominio.carga_repository.save_load(
|
||||
fuente=FUENTE_CATALOGO_ABIERTO, personas=(), plata=LotePlata(procedures, observations, {})
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
def _fold_duplicates(matched: list[MatchedField]) -> list[MatchedField]:
|
||||
"""A record's discovered captions can repeat the same resultado_id (a
|
||||
static label such as "FECHA" printed on several pages): `observacion`
|
||||
has one row per `(procedimiento, resultado_id)`, so only the first
|
||||
occurrence survives. `discover_captions` keeps every repeat on purpose
|
||||
and leaves folding to the caller (see its docstring)."""
|
||||
seen: set[str] = set()
|
||||
folded = []
|
||||
for field in matched:
|
||||
if field.resultado_id in seen:
|
||||
continue
|
||||
seen.add(field.resultado_id)
|
||||
folded.append(field)
|
||||
return folded
|
||||
|
||||
|
||||
def _sync_catalog(dominio, proyecto: str, tablas) -> None:
|
||||
"""A field minted by `match_or_mint` only exists in the TOML until this
|
||||
runs: `procedimiento.estudio_id` and `observacion`'s catalog both need
|
||||
the matching `cat_estudio`/`cat_resultado` row to already be there."""
|
||||
catalogo: Catalogo = catalogo_desde_toml(ruta_de_catalogo(proyecto), tablas=tablas)
|
||||
dominio.catalog_repository.sync(catalogo.estudios, catalogo.resultados, catalogo.valores)
|
||||
@@ -8,8 +8,6 @@ sources of a batch target the same domain and the batch is written in one
|
||||
transaction: it lands completely or not at all.
|
||||
"""
|
||||
from dataclasses import dataclass, field
|
||||
from collections import Counter
|
||||
from itertools import islice
|
||||
from typing import Any, Iterator
|
||||
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
@@ -17,20 +15,9 @@ from sqlalchemy.exc import SQLAlchemyError
|
||||
from persistance.repository import ConflictPolicy
|
||||
from webapi.imports.audit import ImportAudit
|
||||
from webapi.imports.connectors import Connector, ConnectorError, build_connector
|
||||
from webapi.imports.connectors.document import (
|
||||
CONFIDENCE_COLUMN,
|
||||
DOCUMENT_COLUMN,
|
||||
IMAGE_COLUMN,
|
||||
SOURCES_COLUMN,
|
||||
DocumentConnector,
|
||||
connector_for_batch,
|
||||
)
|
||||
from webapi.imports.connectors.document_columns import DocumentColumns
|
||||
from webapi.imports.mapping.derived import Derivation, parse_derived
|
||||
from webapi.imports.schemas.registry import ENTITY_REGISTRY, EntitySpec
|
||||
from webapi.imports.schemas.service import BatchValidationResult, validate_rows
|
||||
from webapi.imports.services.link_resolver import LinkResolver, dependency_rank
|
||||
from webapi.imports.services.review_learning import learn_from_reviews
|
||||
|
||||
|
||||
class ImportRequestError(Exception):
|
||||
@@ -53,8 +40,6 @@ class ImportSource:
|
||||
defaults: dict[str, Any]
|
||||
payload: dict[str, Any]
|
||||
label: str | None = None
|
||||
derived: dict[str, Derivation] = field(default_factory=dict)
|
||||
documents: dict[str, Any] | None = None
|
||||
|
||||
@classmethod
|
||||
def parse(cls, raw: Any) -> "ImportSource":
|
||||
@@ -75,24 +60,11 @@ class ImportSource:
|
||||
unknown = sorted((set(mapping.values()) | set(defaults)) - fields)
|
||||
if unknown:
|
||||
raise ImportRequestError(f"{target} no tiene los campos {unknown}")
|
||||
try:
|
||||
derived = parse_derived(raw.get("derived"), fields)
|
||||
except ConnectorError as exc:
|
||||
raise ImportRequestError(str(exc)) from exc
|
||||
targets = list(mapping.values()) + list(derived)
|
||||
targets = list(mapping.values())
|
||||
duplicated = sorted({t for t in targets if targets.count(t) > 1})
|
||||
if duplicated:
|
||||
raise ImportRequestError(f"más de una columna de origen asignada a {duplicated}")
|
||||
documents = raw.get("documents") or None
|
||||
if documents is not None:
|
||||
try:
|
||||
DocumentColumns.parse(documents)
|
||||
except ConnectorError as exc:
|
||||
raise ImportRequestError(str(exc)) from exc
|
||||
file_field = documents.get("file_field")
|
||||
if file_field and file_field not in fields:
|
||||
raise ImportRequestError(f"{target} no tiene el campo {file_field!r}")
|
||||
if not mapping and not defaults and not derived and not documents:
|
||||
if not mapping and not defaults:
|
||||
raise ImportRequestError(f"la fuente de {target} no asigna ninguna columna")
|
||||
|
||||
payload = raw.get("payload")
|
||||
@@ -106,8 +78,6 @@ class ImportSource:
|
||||
defaults=defaults,
|
||||
payload=payload,
|
||||
label=raw.get("label"),
|
||||
derived=derived,
|
||||
documents=documents,
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -124,106 +94,12 @@ class ImportSource:
|
||||
except ConnectorError as exc:
|
||||
raise ImportRequestError(str(exc)) from exc
|
||||
|
||||
@property
|
||||
def source_columns(self) -> set[str]:
|
||||
"""Every source column the mapping, the derived fields and the
|
||||
document columns read."""
|
||||
columns = set(self.column_mapping)
|
||||
for rule in self.derived.values():
|
||||
columns |= rule.columns()
|
||||
if self.documents:
|
||||
columns |= DocumentColumns.parse(self.documents).source_columns()
|
||||
return columns
|
||||
|
||||
def _mapped(self, raw: dict[str, Any]) -> dict[str, Any]:
|
||||
row = {target: raw.get(column) for column, target in self.column_mapping.items()}
|
||||
for field_name, rule in self.derived.items():
|
||||
row[field_name] = rule.apply(raw)
|
||||
return row
|
||||
|
||||
def document_connector(
|
||||
self, raw_rows: list[dict[str, Any]] | None = None
|
||||
) -> tuple[DocumentConnector | None, list[dict[str, Any]], dict[str, dict[str, Any]]]:
|
||||
"""For a source with `documents`: the extraction over its document
|
||||
cells, the rows that had none (as read) and, per document, the row
|
||||
it came from. Values the mapping and `derived` take from the row's
|
||||
own columns go to the extraction as values to trust."""
|
||||
if raw_rows is None:
|
||||
raw_rows = list(self.connector().read_rows({column: column for column in self.source_columns}))
|
||||
spec = DocumentColumns.parse(self.documents)
|
||||
batch = spec.assemble(raw_rows, [self._mapped(raw) for raw in raw_rows])
|
||||
raw_by_document = {name: raw_rows[number - 1] for name, number in batch.row_numbers.items()}
|
||||
with_documents = set(batch.row_numbers.values())
|
||||
plain = [raw for number, raw in enumerate(raw_rows, start=1) if number not in with_documents]
|
||||
if not batch.files:
|
||||
return None, plain, raw_by_document
|
||||
return connector_for_batch(batch, self.target, self.documents), plain, raw_by_document
|
||||
|
||||
def record_namespaces(self, raw_rows: list[dict[str, Any]] | None = None) -> Iterator[tuple[dict[str, Any], dict[str, Any]]]:
|
||||
"""Per record of a source with `documents`: everything known about
|
||||
it by column name (its rows' own columns first, then every field
|
||||
and caption its documents gave) and what extraction produced."""
|
||||
connector, plain, raw_by_document = self.document_connector(raw_rows)
|
||||
if connector is not None:
|
||||
for extracted, documents in connector.record_rows():
|
||||
namespace: dict[str, Any] = {}
|
||||
for name in documents:
|
||||
for key, value in raw_by_document.get(name, {}).items():
|
||||
if _is_blank(namespace.get(key)):
|
||||
namespace[key] = value
|
||||
for key, value in extracted.items():
|
||||
if _is_blank(namespace.get(key)):
|
||||
namespace[key] = value
|
||||
yield namespace, extracted
|
||||
for raw in plain:
|
||||
yield raw, {}
|
||||
|
||||
def unused_captions(self) -> Counter:
|
||||
"""For a source that reads documents: per caption its documents
|
||||
print that neither a field claims nor the mapping or a derived
|
||||
field uses, how many records print it. Captions only, never their
|
||||
values, for the import report."""
|
||||
if self.source_type == "document":
|
||||
connector = self.connector()
|
||||
elif self.documents:
|
||||
connector, _, _ = self.document_connector()
|
||||
else:
|
||||
return Counter()
|
||||
if not isinstance(connector, DocumentConnector):
|
||||
return Counter()
|
||||
used = {column.casefold() for column in self.source_columns}
|
||||
counts: Counter = Counter()
|
||||
for record in connector.records:
|
||||
captions = {" ".join(found.caption.split()) for found in record.discovered}
|
||||
counts.update(caption for caption in captions if caption.casefold() not in used)
|
||||
return counts
|
||||
|
||||
def _document_rows(self, raw_rows: list[dict[str, Any]]) -> Iterator[dict[str, Any]]:
|
||||
"""Rows of a source with document columns: the mapping and `derived`
|
||||
applied to each record's namespace, so they reach what the
|
||||
documents print as well as the row's own columns; then every field
|
||||
extraction filled that they left empty, and the record's pages in
|
||||
`file_field`."""
|
||||
fields = set(self.spec.schema.model_fields)
|
||||
file_field = self.documents.get("file_field")
|
||||
for namespace, extracted in self.record_namespaces(raw_rows):
|
||||
row = self._mapped(namespace)
|
||||
for key, value in extracted.items():
|
||||
if key in fields and _is_blank(row.get(key)) and not _is_blank(value):
|
||||
row[key] = value
|
||||
if file_field and extracted:
|
||||
row[file_field] = extracted.get(DOCUMENT_COLUMN)
|
||||
yield row
|
||||
|
||||
def rows(self) -> Iterator[dict[str, Any]]:
|
||||
"""Mapped rows: each mapped column under its field, each `derived`
|
||||
field computed from the source columns it names, and `defaults`
|
||||
filling any field still empty or not mapped at all (a constant
|
||||
"dependencia" for a file that has none, a fallback for blank cells)."""
|
||||
"""Mapped rows, with `defaults` filling any field the source left
|
||||
empty or didn't map at all (a constant "dependencia" for a file that
|
||||
has none, a fallback for blank cells)."""
|
||||
try:
|
||||
raw_rows = self.connector().read_rows({column: column for column in self.source_columns})
|
||||
mapped = self._document_rows(list(raw_rows)) if self.documents else (self._mapped(raw) for raw in raw_rows)
|
||||
for row in mapped:
|
||||
for row in self.connector().read_rows(self.column_mapping):
|
||||
for field_name, value in self.defaults.items():
|
||||
if _is_blank(row.get(field_name)):
|
||||
row[field_name] = value
|
||||
@@ -235,9 +111,6 @@ class ImportSource:
|
||||
return validate_rows(self.spec.schema, self.rows())
|
||||
|
||||
|
||||
DOCUMENT_BOOKKEEPING = {DOCUMENT_COLUMN, IMAGE_COLUMN, CONFIDENCE_COLUMN, SOURCES_COLUMN}
|
||||
|
||||
|
||||
def _is_blank(value: Any) -> bool:
|
||||
return value is None or (isinstance(value, str) and not value.strip())
|
||||
|
||||
@@ -262,33 +135,6 @@ def _jsonable(value: Any) -> Any:
|
||||
return str(value)
|
||||
|
||||
|
||||
def document_columns_preview(raw_source: dict[str, Any], limit: int = 20) -> dict[str, Any]:
|
||||
"""The columns a source with `documents` offers to its mapping (its own
|
||||
columns and every field and caption its documents print), with sample
|
||||
values per record, shaped like a source preview."""
|
||||
source = ImportSource.parse({**raw_source, "column_mapping": raw_source.get("column_mapping") or {}})
|
||||
connector = source.connector()
|
||||
own = [column.name for column in connector.preview(limit=1).columns]
|
||||
raw_rows = list(connector.read_rows({column: column for column in set(own) | source.source_columns}))
|
||||
names: list[str] = list(own)
|
||||
rows = []
|
||||
for namespace, _ in source.record_namespaces(raw_rows):
|
||||
for key in namespace:
|
||||
if key not in names and key not in DOCUMENT_BOOKKEEPING:
|
||||
names.append(key)
|
||||
if len(rows) < limit:
|
||||
rows.append({key: _jsonable(value) for key, value in namespace.items() if key not in DOCUMENT_BOOKKEEPING})
|
||||
columns = [{"name": name, "inferred_type": "string"} for name in names]
|
||||
return {"columns": columns, "sample_rows": rows, "total_rows": None}
|
||||
|
||||
|
||||
def mapped_sample(raw_source: dict[str, Any], limit: int = 20) -> list[dict[str, Any]]:
|
||||
"""The first rows of a source as they would be written: mapping,
|
||||
derived fields and defaults applied, before validation."""
|
||||
source = ImportSource.parse(raw_source)
|
||||
return [{name: _jsonable(value) for name, value in row.items()} for row in islice(source.rows(), max(1, limit))]
|
||||
|
||||
|
||||
def validate_source(raw_source: dict[str, Any], audit: ImportAudit | None = None) -> BatchValidationResult:
|
||||
source = ImportSource.parse(raw_source)
|
||||
if audit is None:
|
||||
@@ -296,7 +142,6 @@ def validate_source(raw_source: dict[str, Any], audit: ImportAudit | None = None
|
||||
tracked = audit.source(source)
|
||||
rows = list(source.rows())
|
||||
tracked.observe_rows(rows)
|
||||
tracked.observe_captions(source.unused_captions)
|
||||
validation = validate_rows(source.spec.schema, rows)
|
||||
tracked.observe_validation(validation)
|
||||
return validation
|
||||
@@ -406,7 +251,6 @@ def commit_sources(
|
||||
source_audit.observe_rows(rows[position])
|
||||
source_audit.observe_validation(validated[position][1])
|
||||
source_audit.observe_warnings(merge_warnings.get(position, []))
|
||||
source_audit.observe_captions(sources[position].unused_captions)
|
||||
|
||||
session = sources[0].spec.repository.open_session()
|
||||
links = LinkResolver(session)
|
||||
@@ -466,5 +310,4 @@ def commit_sources(
|
||||
) from exc
|
||||
finally:
|
||||
session.close()
|
||||
learn_from_reviews(sources)
|
||||
return [results[i] for i in range(len(validated))]
|
||||
|
||||
@@ -7,7 +7,6 @@ import pandas as pd
|
||||
|
||||
from webapi.imports.connectors import Connector, ConnectorError
|
||||
from webapi.imports.connectors.document import DocumentConnector
|
||||
from webapi.imports.connectors.document_columns import is_document
|
||||
from webapi.imports.connectors.pdf import PdfConnector, RegionSpec
|
||||
from webapi.imports.connectors.tabular import columns_from_dataframe, rows_from_dataframe
|
||||
from webapi.imports.mapping import column_matcher
|
||||
@@ -36,16 +35,9 @@ def preview_with_suggestions(connector: Connector, target_key: str | None, *, li
|
||||
"suggested_mapping": suggest_mapping([c.name for c in preview.columns], target_key),
|
||||
"tables": [{"name": t.name, "options": t.options, "kind": t.kind} for t in connector.tables()],
|
||||
"source_metadata": connector.metadata(),
|
||||
"document_columns": document_columns(preview.columns, preview.sample_rows),
|
||||
}
|
||||
|
||||
|
||||
def document_columns(columns, rows: list[dict[str, Any]]) -> list[str]:
|
||||
"""The columns whose sampled cells hold files a document reader opens,
|
||||
so a client can offer to read them as documents."""
|
||||
return [column.name for column in columns if any(is_document(row.get(column.name)) for row in rows)]
|
||||
|
||||
|
||||
def detect_pdf(raw: bytes) -> dict[str, Any]:
|
||||
"""Page count, whether there is a text layer, and every ruled table
|
||||
pdfplumber found, best candidates first."""
|
||||
@@ -80,27 +72,10 @@ def extract_pdf_regions(raw: bytes, regions: list[dict[str, Any]], *, dpi: int =
|
||||
|
||||
|
||||
def document_report(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
"""The extraction report of uploaded documents, of a document source's
|
||||
SQL table, or (with `source`) of the document columns of any import
|
||||
source, read through that source's own mapping."""
|
||||
if payload.get("source"):
|
||||
from webapi.imports.services.import_service import ImportSource
|
||||
|
||||
connector, _, _ = ImportSource.parse(payload["source"]).document_connector()
|
||||
if connector is None:
|
||||
raise ConnectorError("ninguna fila de la fuente tiene documentos")
|
||||
else:
|
||||
connector = DocumentConnector.from_payload(payload)
|
||||
connector = DocumentConnector.from_payload(payload)
|
||||
preview = preview_with_suggestions(connector, connector.target, limit=500)
|
||||
fields = [
|
||||
{"name": spec.name, "kind": spec.kind.value, "required": spec.required, "labels": list(spec.labels)}
|
||||
for spec in connector.specs
|
||||
]
|
||||
return {
|
||||
**preview,
|
||||
"key_field": connector.key_field,
|
||||
"fields": fields,
|
||||
"records": connector.report(),
|
||||
"skipped": connector.skipped,
|
||||
"nlp_version": connector.nlp_version,
|
||||
}
|
||||
return {**preview, "key_field": connector.key_field, "fields": fields, "records": connector.report()}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
"""Learning from the corrections made while reviewing documents: once an
|
||||
import is written, each document source whose records a person corrected
|
||||
teaches its domain's extraction ranker (`models.io.extraction_ranker`), in
|
||||
the background so the import never waits for it, one batch at a time.
|
||||
|
||||
`EXTRACTION_LEARNING=0` turns it off.
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
from concurrent.futures import Future, ThreadPoolExecutor
|
||||
from typing import Sequence
|
||||
|
||||
from webapi.imports.connectors.document import DocumentConnector
|
||||
|
||||
LEARNING_ENV = "EXTRACTION_LEARNING"
|
||||
SOURCE = "revision"
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
_executor = ThreadPoolExecutor(max_workers=1, thread_name_prefix="extraction-learning")
|
||||
|
||||
|
||||
def enabled() -> bool:
|
||||
return os.environ.get(LEARNING_ENV, "1").strip().lower() not in ("0", "false", "no")
|
||||
|
||||
|
||||
def _connector(source) -> DocumentConnector | None:
|
||||
if source.source_type == "document":
|
||||
connector = source.connector()
|
||||
elif source.documents:
|
||||
connector, _, _ = source.document_connector()
|
||||
else:
|
||||
return None
|
||||
return connector if isinstance(connector, DocumentConnector) else None
|
||||
|
||||
|
||||
def learn_from_reviews(sources: Sequence) -> list[Future]:
|
||||
"""Queues one learning step per corrected document source; returns them,
|
||||
for a caller that wants to wait."""
|
||||
if not enabled():
|
||||
return []
|
||||
futures = []
|
||||
for source in sources:
|
||||
try:
|
||||
connector = _connector(source)
|
||||
if connector is None or not connector.overrides:
|
||||
continue
|
||||
examples, unreachable, records = connector.learning_examples()
|
||||
except Exception: # noqa: BLE001 - the import is already written
|
||||
logger.exception("no se pudieron preparar ejemplos de %s", getattr(source, "target", "?"))
|
||||
continue
|
||||
if examples:
|
||||
documents = len(connector.files)
|
||||
futures.append(_executor.submit(_learn, connector.domain, examples, unreachable, records, documents))
|
||||
return futures
|
||||
|
||||
|
||||
def _learn(domain: str, examples: list, unreachable: dict[str, int], records: int, documents: int) -> str | None:
|
||||
from models.io.extraction_ranker import Batch, learn
|
||||
|
||||
try:
|
||||
return learn(domain, Batch(examples, SOURCE, documents, records, unreachable))
|
||||
except Exception: # noqa: BLE001
|
||||
logger.exception("el ranker de extracción de %s no pudo aprender de la revisión", domain)
|
||||
return None
|
||||
+3
-12
@@ -46,7 +46,6 @@ TOTAL = "total"
|
||||
NO_DATA = "sin_dato"
|
||||
AGE_AT_PERIOD_START = "edad_al_inicio_del_periodo"
|
||||
TIMELINE_AT_PERIOD_START = "linea_de_tiempo_al_inicio_del_periodo"
|
||||
TIMELINE_BY_CUTOFF = "linea_de_tiempo_al_corte"
|
||||
OF_THE_CHOSEN = "del_elegido"
|
||||
COLUMN = "columna"
|
||||
STATUS_AT_PERIOD_END = "estado_al_fin_del_periodo"
|
||||
@@ -130,9 +129,6 @@ class Stratum:
|
||||
`fecha` and `conocida_en`) held before the period's start. `valores` are tried in order and the first whose
|
||||
condition holds is the value, else `resto`; a condition (`si`) is a list of alternatives, each a map from a
|
||||
timeline `tipo` to whether there was one;
|
||||
- `linea_de_tiempo_al_corte`: the same, with what the timeline held by the question's event cut-off (all of it
|
||||
without one) instead of before the period's start: a patient's characteristic learned after the fact that
|
||||
put her in the period, such as the stage of a cancer whose biopsy the period counts;
|
||||
- `del_elegido`: in a composition, the `valor` column of the fact that gave the unit its category;
|
||||
- `columna`: a column of the event model (`columna`), one value per unit; `sin_dato` when null.
|
||||
"""
|
||||
@@ -147,7 +143,7 @@ class Stratum:
|
||||
|
||||
@classmethod
|
||||
def of(cls, name: str, spec: dict) -> "Stratum":
|
||||
if spec["tipo"] not in (AGE_AT_PERIOD_START, TIMELINE_AT_PERIOD_START, TIMELINE_BY_CUTOFF, OF_THE_CHOSEN, COLUMN):
|
||||
if spec["tipo"] not in (AGE_AT_PERIOD_START, TIMELINE_AT_PERIOD_START, OF_THE_CHOSEN, COLUMN):
|
||||
raise NotImplementedError(f"strata of kind {spec['tipo']!r} aren't answered")
|
||||
return cls(name, spec["tipo"], spec)
|
||||
|
||||
@@ -415,8 +411,7 @@ class MeasureQueries:
|
||||
return joined
|
||||
|
||||
def _timeline(self, stratum: Stratum):
|
||||
"""Per patient, one 0/1 column per timeline `tipo` the stratum asks about: had one before the period's start
|
||||
(or, for `linea_de_tiempo_al_corte`, by the event cut-off).
|
||||
"""Per patient, one 0/1 column per timeline `tipo` the stratum asks about: had one before the period's start.
|
||||
|
||||
Known by the knowledge cut-off, if the question has one. Joined, not correlated, so the value can be grouped
|
||||
by on every engine.
|
||||
@@ -427,11 +422,7 @@ class MeasureQueries:
|
||||
line = table(stratum.spec["linea"], column("pac_id"), column("tipo"), column("fecha"),
|
||||
column("conocida_en", FechaHoraUTC))
|
||||
period = self.periods.alias(f"periodo_{stratum.name}")
|
||||
conditions = [line.c.tipo.in_(kinds)]
|
||||
if stratum.kind == TIMELINE_AT_PERIOD_START:
|
||||
conditions.append(line.c.fecha < period.c.inicio)
|
||||
elif self.q.event_cutoff is not None:
|
||||
conditions.append(line.c.fecha <= self.q.event_cutoff.isoformat())
|
||||
conditions = [line.c.tipo.in_(kinds), line.c.fecha < period.c.inicio]
|
||||
if self.q.knowledge_cutoff is not None:
|
||||
conditions.append(line.c.conocida_en <= self.q.knowledge_cutoff)
|
||||
had = (select(line.c.pac_id, *(func.max(case((line.c.tipo == k, 1), else_=0)).label(k) for k in kinds))
|
||||
|
||||
-153
@@ -1,153 +0,0 @@
|
||||
"""Measuring and training document extraction against an answer key (VAR-04, VARM-05).
|
||||
|
||||
python -m webapi.nlp evaluate --documents <folder> --key <key.json> [--with-values] [--no-ranker]
|
||||
python -m webapi.nlp train --documents <folder> --key <key.json>
|
||||
|
||||
The key is JSON: per document file name, per import target, per field, the right value (`null` for a field that
|
||||
must stay empty); fields left out are not scored.
|
||||
|
||||
{"reporte_01.pdf": {"cacu.BiopsiaCervical": {"bx_cin_grado": "LIEBG", "bx_fecha_reporte": "2025-01-31"}}}
|
||||
|
||||
Each document is read as one record. `evaluate` prints precision, recall and F1 per field and overall, with the
|
||||
domain's current ranker (`models.io.extraction_ranker`) unless `--no-ranker`; errors list which document and
|
||||
field, and their values only with `--with-values`. `train` first estimates how a ranker trained on the key would do
|
||||
on documents it has not seen (leaving each document out in turn), then teaches the domain's ranker the whole key and
|
||||
registers it as a new DEV version, which a person promotes like any model.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from extraction import DocumentExtractor, read_document
|
||||
from extraction.nlp.evaluation import evaluate
|
||||
from extraction.nlp.ranking import LearnedRanker, examples_for, same_value
|
||||
from extraction.readers import supported_extensions
|
||||
from extraction.segmentation import WholeDocument
|
||||
from webapi.imports.schemas.field_specs import field_specs_for, foreign_subjects_for, key_field_for, subject_for
|
||||
from webapi.imports.schemas.registry import ENTITY_REGISTRY
|
||||
|
||||
|
||||
def _documents(folder: Path, names) -> dict[str, Any]:
|
||||
extensions = tuple(supported_extensions())
|
||||
found = {}
|
||||
for name in names:
|
||||
path = folder / name
|
||||
if not path.is_file() or not path.name.lower().endswith(extensions):
|
||||
raise SystemExit(f"no se encontró el documento {name} en {folder}")
|
||||
found[name] = read_document(name, path.read_bytes())
|
||||
return found
|
||||
|
||||
|
||||
def _extractor(target: str, ranker) -> DocumentExtractor:
|
||||
entity = ENTITY_REGISTRY.get(target)
|
||||
if entity is None:
|
||||
raise SystemExit(f"destino desconocido: {target}")
|
||||
return DocumentExtractor(
|
||||
field_specs_for(entity), key_field=key_field_for(entity), segmenter=WholeDocument(), merger=None,
|
||||
subject=subject_for(entity), foreign=foreign_subjects_for(entity), ranker=ranker,
|
||||
)
|
||||
|
||||
|
||||
def _records(documents: dict[str, Any], key: dict[str, dict[str, dict[str, Any]]], rankers: dict[str, Any]):
|
||||
"""Per (document, target): the extracted record."""
|
||||
records = {}
|
||||
for name, targets in key.items():
|
||||
for target in targets:
|
||||
extractor = _extractor(target, rankers.get(target.split(".", 1)[0]))
|
||||
[records[(name, target)]] = extractor.extract([documents[name]])[:1] or [None]
|
||||
return records
|
||||
|
||||
|
||||
def _scores(records, key) -> dict[str, Any]:
|
||||
extracted = {f"{name} · {target}": {f: v.value for f, v in record.values.items()} for (name, target), record in records.items() if record}
|
||||
expected = {f"{name} · {target}": fields for name, targets in key.items() for target, fields in targets.items()}
|
||||
return evaluate(extracted, expected)
|
||||
|
||||
|
||||
def _examples(records, key) -> tuple[dict[str, list], dict[str, dict[str, int]]]:
|
||||
"""Per domain, the labelled examples of every record, and per field how many right values no candidate had."""
|
||||
examples: dict[str, list] = {}
|
||||
unreachable: dict[str, dict[str, int]] = {}
|
||||
for (name, target), record in records.items():
|
||||
if record is None:
|
||||
continue
|
||||
domain = target.split(".", 1)[0]
|
||||
specs = field_specs_for(ENTITY_REGISTRY[target])
|
||||
truth = key[name][target]
|
||||
examples.setdefault(domain, []).extend(examples_for(specs, record.candidates, truth))
|
||||
missing = unreachable.setdefault(domain, {})
|
||||
for field, value in truth.items():
|
||||
if value is not None and not any(same_value(c.value, value) for c in record.candidates.get(field, ())):
|
||||
missing[field] = missing.get(field, 0) + 1
|
||||
return examples, unreachable
|
||||
|
||||
|
||||
def _current_rankers(domains) -> dict[str, Any]:
|
||||
from models.io.extraction_ranker import current
|
||||
|
||||
return {domain: current(domain) for domain in domains}
|
||||
|
||||
|
||||
def command_evaluate(args) -> dict[str, Any]:
|
||||
key = json.loads(Path(args.key).read_text())
|
||||
documents = _documents(Path(args.documents), key)
|
||||
domains = {target.split(".", 1)[0] for targets in key.values() for target in targets}
|
||||
rankers = {} if args.no_ranker else _current_rankers(domains)
|
||||
result = _scores(_records(documents, key, rankers), key).to_dict(with_values=args.with_values)
|
||||
result["rankers"] = {domain: getattr(ranker, "version", None) for domain, ranker in rankers.items()}
|
||||
return result
|
||||
|
||||
|
||||
def command_train(args) -> dict[str, Any]:
|
||||
from models.io.extraction_ranker import Batch, learn
|
||||
|
||||
key = json.loads(Path(args.key).read_text())
|
||||
documents = _documents(Path(args.documents), key)
|
||||
records = _records(documents, key, {})
|
||||
held_out = {}
|
||||
for left_out in key:
|
||||
training = {k: v for k, v in records.items() if k[0] != left_out}
|
||||
examples, _ = _examples(training, key)
|
||||
rankers = {domain: _trained(batch) for domain, batch in examples.items()}
|
||||
held_out.update({k: v for k, v in _records({left_out: documents[left_out]}, {left_out: key[left_out]}, rankers).items()})
|
||||
estimate = _scores(held_out, key).to_dict()
|
||||
examples, unreachable = _examples(records, key)
|
||||
versions = {}
|
||||
for domain, batch in examples.items():
|
||||
documents_in_domain = len({name for (name, target) in records if target.startswith(f"{domain}.")})
|
||||
records_in_domain = sum(1 for (_, target) in records if target.startswith(f"{domain}."))
|
||||
versions[domain] = learn(domain, Batch(batch, "clave", documents_in_domain, records_in_domain, unreachable.get(domain, {})))
|
||||
return {
|
||||
"sin_ranker": _scores(records, key).to_dict()["global"],
|
||||
"estimacion_dejando_uno_fuera": estimate["global"],
|
||||
"versiones": versions,
|
||||
}
|
||||
|
||||
|
||||
def _trained(examples) -> LearnedRanker:
|
||||
ranker = LearnedRanker()
|
||||
ranker.learn(examples)
|
||||
return ranker
|
||||
|
||||
|
||||
def main(argv=None) -> int:
|
||||
parser = argparse.ArgumentParser(prog="python -m webapi.nlp", description=__doc__.split("\n\n")[0])
|
||||
commands = parser.add_subparsers(dest="command", required=True)
|
||||
for name in ("evaluate", "train"):
|
||||
command = commands.add_parser(name)
|
||||
command.add_argument("--documents", required=True, help="carpeta con los documentos")
|
||||
command.add_argument("--key", required=True, help="JSON con los valores correctos")
|
||||
if name == "evaluate":
|
||||
command.add_argument("--with-values", action="store_true", help="incluir los valores de cada error")
|
||||
command.add_argument("--no-ranker", action="store_true", help="ordenar candidatos solo por confianza")
|
||||
args = parser.parse_args(argv)
|
||||
result = command_evaluate(args) if args.command == "evaluate" else command_train(args)
|
||||
json.dump(result, sys.stdout, ensure_ascii=False, indent=1, default=str)
|
||||
sys.stdout.write("\n")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -27,7 +27,6 @@ from webapi.orchestration.reference.support import (
|
||||
grupos_de_edad_de,
|
||||
)
|
||||
from webapi.orchestration.reference.catalogs import catalogo_desde_toml, ruta_de_catalogo
|
||||
from webapi.orchestration.reference.source_mapping import catalog_rows
|
||||
from webapi.orchestration.reference.rules import (
|
||||
RUTA_PARAMETROS,
|
||||
leer_parametros,
|
||||
@@ -67,18 +66,9 @@ def migrate(ctx: Context) -> str:
|
||||
|
||||
|
||||
def catalogs(migrate: str, ctx: Context) -> dict[str, int]:
|
||||
"""`core/catalogos/<proyecto>.toml` -> `cat_estudio`, `cat_resultado`, `cat_valor`: agrega, actualiza y retira; no borra.
|
||||
|
||||
Then the catalog's own mappings (`cat_mapeo`, system `catalogo`): only the forms with no row yet are added, so a
|
||||
mapping edited in the application survives every deploy."""
|
||||
"""`core/catalogos/<proyecto>.toml` -> `cat_estudio`, `cat_resultado`, `cat_valor`: agrega, actualiza y retira; no borra."""
|
||||
catalogo = catalogo_desde_toml(ruta_de_catalogo(ctx.project), tablas=tablas_de(ctx.project))
|
||||
counts = ctx.repos.silver.catalogs.sync(catalogo.estudios, catalogo.resultados, catalogo.valores)
|
||||
mappings = ctx.repos.silver.mappings
|
||||
if mappings is not None:
|
||||
system, rows = catalog_rows(ctx.project, mappings)
|
||||
mappings.ensure_system(system)
|
||||
counts["mapeos_nuevos"] = mappings.seed(rows)
|
||||
return counts
|
||||
return ctx.repos.silver.catalogs.sync(catalogo.estudios, catalogo.resultados, catalogo.valores)
|
||||
|
||||
|
||||
def load(catalogs: dict[str, int], ctx: Context) -> SQLModel:
|
||||
|
||||
@@ -18,7 +18,6 @@ import core
|
||||
from core.indicadores.catalogos import TIPOS_DE_VALOR
|
||||
from sqlmodel import SQLModel
|
||||
|
||||
from webapi.orchestration.reference.source_mapping import check_function, from_result
|
||||
from webapi.orchestration.tables import TablasKit
|
||||
|
||||
# Los catálogos viven en Core, junto a los modelos de sus tablas.
|
||||
@@ -55,7 +54,6 @@ def catalogo_desde_toml(ruta: Path, *, tablas: TablasKit) -> Catalogo:
|
||||
for nombre, resultado in estudio.get("resultados", {}).items():
|
||||
resultado_id = f"{estudio_id}.{nombre}"
|
||||
tipo_valor = _tipo_de_valor(resultado, resultado_id)
|
||||
_claves_de_extraccion(resultado, resultado_id)
|
||||
resultados.append(
|
||||
tablas.CatResultado(
|
||||
resultado_id=resultado_id,
|
||||
@@ -79,40 +77,6 @@ def catalogo_desde_toml(ruta: Path, *, tablas: TablasKit) -> Catalogo:
|
||||
return Catalogo(estudios, resultados, valores)
|
||||
|
||||
|
||||
def add_resultado(
|
||||
proyecto: str, *, estudio_id: str, nombre: str, etiqueta: str, tipo_valor: str, estudio_etiqueta: str | None = None
|
||||
) -> str:
|
||||
"""Appends a new `resultado_id` to the project's TOML (not to the
|
||||
database): a `[estudio.resultados.nombre]` table, and the `[estudio]`
|
||||
table too if it didn't exist yet. The file stays the source: the next
|
||||
`catalogo_desde_toml` already brings it, and whoever syncs the table
|
||||
writes it.
|
||||
|
||||
Idempotent: if the resultado is already in the file, nothing is
|
||||
written and its `resultado_id` is returned as is. `nombre` must be a
|
||||
valid TOML key (whoever discovers the field builds it, e.g. from a
|
||||
slug of the text found).
|
||||
"""
|
||||
if tipo_valor not in TIPOS_DE_VALOR:
|
||||
raise CatalogoInvalido(f"{estudio_id}.{nombre}: tipo_valor {tipo_valor!r} no es uno de {', '.join(TIPOS_DE_VALOR)}.")
|
||||
ruta = ruta_de_catalogo(proyecto)
|
||||
existentes = _leer(ruta)
|
||||
resultado_id = f"{estudio_id}.{nombre}"
|
||||
if estudio_id in existentes and nombre in existentes[estudio_id].get("resultados", {}):
|
||||
return resultado_id
|
||||
blocks = []
|
||||
if estudio_id not in existentes:
|
||||
blocks.append(f'\n[{estudio_id}]\netiqueta = "{_escape(estudio_etiqueta or estudio_id)}"\n')
|
||||
blocks.append(f'\n[{estudio_id}.resultados.{nombre}]\netiqueta = "{_escape(etiqueta)}"\ntipo_valor = "{tipo_valor}"\n')
|
||||
with Path(ruta).open("a", encoding="utf-8") as archivo:
|
||||
archivo.write("".join(blocks))
|
||||
return resultado_id
|
||||
|
||||
|
||||
def _escape(text: str) -> str:
|
||||
return text.replace("\\", "\\\\").replace('"', '\\"')
|
||||
|
||||
|
||||
def codigos_hospital(proyecto: str) -> dict[str, str]:
|
||||
"""Código del hospital -> `estudio_id`, del catálogo del proyecto.
|
||||
|
||||
@@ -129,60 +93,6 @@ def codigos_hospital(proyecto: str) -> dict[str, str]:
|
||||
return codigos
|
||||
|
||||
|
||||
class ResultadoExtraible(NamedTuple):
|
||||
"""A result read from a document's text: the captions it's printed under and, if coded, each value's spellings."""
|
||||
|
||||
resultado_id: str
|
||||
tipo_valor: str
|
||||
etiquetas_fuente: tuple[str, ...]
|
||||
alias: dict[str, tuple[str, ...]] # valor -> its spellings, the label included
|
||||
buscar_en_texto: bool # also as a mention anywhere in the text, without a caption
|
||||
provisional: bool
|
||||
|
||||
|
||||
def resultados_extraibles(proyecto: str) -> dict[str, ResultadoExtraible]:
|
||||
"""`resultado_id` -> how it's found in a document, for every result of the catalog with `etiquetas_fuente`.
|
||||
|
||||
The mapping lives in the catalog so that a new caption or spelling from the laboratory is one line there:
|
||||
the next load reads it, and nothing already stored is renamed.
|
||||
"""
|
||||
extraibles = {}
|
||||
for estudio_id, estudio in _leer(ruta_de_catalogo(proyecto)).items():
|
||||
for nombre, resultado in estudio.get("resultados", {}).items():
|
||||
resultado_id = f"{estudio_id}.{nombre}"
|
||||
_claves_de_extraccion(resultado, resultado_id)
|
||||
if "etiquetas_fuente" not in resultado:
|
||||
continue
|
||||
extraibles[resultado_id] = ResultadoExtraible(
|
||||
resultado_id=resultado_id,
|
||||
tipo_valor=resultado["tipo_valor"],
|
||||
etiquetas_fuente=tuple(resultado["etiquetas_fuente"]),
|
||||
alias={v["valor"]: (v["etiqueta"], *v.get("alias", ())) for v in resultado.get("valores", ())},
|
||||
buscar_en_texto=bool(resultado.get("buscar_en_texto", False)),
|
||||
provisional=bool(resultado.get("provisional", False)),
|
||||
)
|
||||
return extraibles
|
||||
|
||||
|
||||
def _claves_de_extraccion(resultado: dict, resultado_id: str) -> None:
|
||||
"""The extraction keys of a result: captions as a non-empty list of texts, and its spellings a function into
|
||||
its values (`source_mapping.check_function`)."""
|
||||
etiquetas = resultado.get("etiquetas_fuente")
|
||||
if etiquetas is not None and (not isinstance(etiquetas, list) or not etiquetas
|
||||
or not all(isinstance(e, str) and e.strip() for e in etiquetas)):
|
||||
raise CatalogoInvalido(f"{resultado_id}: etiquetas_fuente es una lista de textos, no vacía.")
|
||||
if etiquetas is None and ("buscar_en_texto" in resultado or any("alias" in v for v in resultado.get("valores", ()))):
|
||||
raise CatalogoInvalido(f"{resultado_id}: alias y buscar_en_texto solo sirven con etiquetas_fuente.")
|
||||
if etiquetas is not None and resultado.get("tipo_valor") not in ("codigo", "numero", "fecha", "texto"):
|
||||
raise CatalogoInvalido(f"{resultado_id}: un resultado de tipo {resultado.get('tipo_valor')} no se extrae de texto.")
|
||||
if resultado.get("buscar_en_texto") and resultado.get("tipo_valor") != "codigo":
|
||||
raise CatalogoInvalido(f"{resultado_id}: solo un resultado de tipo codigo se busca como mención en el texto.")
|
||||
try:
|
||||
check_function(from_result(resultado_id, resultado))
|
||||
except ValueError as e:
|
||||
raise CatalogoInvalido(str(e)) from None
|
||||
|
||||
|
||||
def _leer(ruta: Path) -> dict:
|
||||
return tomllib.loads(Path(ruta).read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
"""How a source writes the catalog's values: a partial, non-injective function into a fixed set of codes.
|
||||
|
||||
A source form (a spelling, an abbreviation, a lab's own code) maps to one `valor_id` of one result:
|
||||
|
||||
f : (source system, resultado_id, normalized form, document date) -> valor_id
|
||||
|
||||
- non-injective: many forms give the same code ("3+", "Positivo (score 3)" -> H3);
|
||||
- partial: a form with no mapping gives nothing, and the observation keeps it as `valor_fuente`, counted as out of
|
||||
catalog, until a mapping is added;
|
||||
- per source system and per date: the same form may mean different codes at two labs, and a mapping applies to the
|
||||
documents dated within its validity;
|
||||
- into a fixed set: a mapping only names a `valor_id` the catalog defines (`cat_valor`).
|
||||
|
||||
For `f` to be a function, two mappings in force on the same date can't give the same key two codes:
|
||||
`check_function` rejects that, and `resolve` returns nothing for a key it still finds ambiguous, so the observation
|
||||
goes back to the out-of-catalog queue instead of keeping a code.
|
||||
|
||||
The mappings are stored in `cat_sistema_fuente` and `cat_mapeo`: the `catalogs` step seeds the catalog's own
|
||||
(`catalog_rows`, system `catalogo`, always in force) and never changes a stored row, and `register` adds one after
|
||||
checking it against the rows of the same form.
|
||||
"""
|
||||
|
||||
import tomllib
|
||||
from collections import defaultdict
|
||||
from datetime import date, datetime, timezone
|
||||
from typing import Iterable, NamedTuple
|
||||
|
||||
from extraction.nlp.text import fold
|
||||
|
||||
CATALOG = "catalogo" # the source system of the mappings written in the catalog's TOML
|
||||
|
||||
|
||||
class SourceForm(NamedTuple):
|
||||
"""One mapping: how `system` writes `value_id` of `result_id`, in force from `valid_from` to `valid_to`."""
|
||||
|
||||
system: str
|
||||
result_id: str
|
||||
form: str
|
||||
value_id: str
|
||||
valid_from: date | None = None # None: since always
|
||||
valid_to: date | None = None # None: while current
|
||||
|
||||
@property
|
||||
def key(self) -> tuple[str, str, str]:
|
||||
return self.system, self.result_id, normalize(self.form)
|
||||
|
||||
def in_force(self, on: date | None) -> bool:
|
||||
return on is None or ((self.valid_from is None or self.valid_from <= on)
|
||||
and (self.valid_to is None or on <= self.valid_to))
|
||||
|
||||
|
||||
class AmbiguousForm(NamedTuple):
|
||||
"""Two mappings of the same key whose validities overlap and whose codes differ."""
|
||||
|
||||
first: SourceForm
|
||||
second: SourceForm
|
||||
|
||||
|
||||
def normalize(form: str) -> str:
|
||||
"""What is compared: uppercase, without accents, single spaces."""
|
||||
return " ".join(fold(form).split())
|
||||
|
||||
|
||||
def ambiguities(rows: Iterable[SourceForm]) -> list[AmbiguousForm]:
|
||||
"""Every pair of mappings that would give one key two codes on some date."""
|
||||
by_key: dict[tuple, list[SourceForm]] = defaultdict(list)
|
||||
for row in rows:
|
||||
by_key[row.key].append(row)
|
||||
found = []
|
||||
for same_key in by_key.values():
|
||||
for i, a in enumerate(same_key):
|
||||
found += [AmbiguousForm(a, b) for b in same_key[i + 1:] if a.value_id != b.value_id and _overlap(a, b)]
|
||||
return found
|
||||
|
||||
|
||||
def check_function(rows: Iterable[SourceForm]) -> None:
|
||||
"""Raises `ValueError` naming each form that maps to two codes while both mappings are in force."""
|
||||
found = ambiguities(rows)
|
||||
if found:
|
||||
raise ValueError("; ".join(f"{a.first.result_id}: {a.first.form!r} se escribe igual para "
|
||||
f"{a.first.value_id!r} y {a.second.value_id!r}" for a in found) + ".")
|
||||
|
||||
|
||||
def resolve(rows: Iterable[SourceForm], system: str, result_id: str, form: str, on: date | None = None) -> str | None:
|
||||
"""The code `form` maps to on `on` for `system`; None when no mapping in force matches it or two disagree."""
|
||||
key = (system, result_id, normalize(form))
|
||||
codes = {r.value_id for r in rows if r.key == key and r.in_force(on)}
|
||||
return codes.pop() if len(codes) == 1 else None
|
||||
|
||||
|
||||
def from_result(result_id: str, result: dict, system: str = CATALOG) -> list[SourceForm]:
|
||||
"""A catalog result's mappings: each value's code, label and aliases, in force always."""
|
||||
return [SourceForm(system, result_id, form, value["valor"])
|
||||
for value in result.get("valores", ())
|
||||
for form in (value["valor"], value.get("etiqueta", ""), *value.get("alias", ())) if form.strip()]
|
||||
|
||||
|
||||
def _overlap(a: SourceForm, b: SourceForm) -> bool:
|
||||
starts_before_b_ends = a.valid_from is None or b.valid_to is None or a.valid_from <= b.valid_to
|
||||
b_starts_before_a_ends = b.valid_from is None or a.valid_to is None or b.valid_from <= a.valid_to
|
||||
return starts_before_b_ends and b_starts_before_a_ends
|
||||
|
||||
|
||||
# --- the mappings stored in `cat_sistema_fuente` and `cat_mapeo` ---
|
||||
|
||||
CATALOG_SINCE = date(1900, 1, 1) # the catalog's own mappings hold for every document
|
||||
|
||||
|
||||
def as_source_form(row) -> SourceForm:
|
||||
"""A `cat_mapeo` row as the function sees it: a study code maps to its `estudio_id`, a spelling to its value."""
|
||||
return SourceForm(row.sistema_fuente_id, row.resultado_id or "", row.forma, row.valor_id or row.estudio_id,
|
||||
row.vigente_desde, row.vigente_hasta)
|
||||
|
||||
|
||||
def check_stored(same_form: list, new) -> None:
|
||||
"""`SourceMappingRepository.add`'s check: a study code or a spelling stays a function with the new row. A
|
||||
caption may introduce several results (a receptor and its percentage), so it isn't checked."""
|
||||
if new.clase == "etiqueta":
|
||||
return
|
||||
check_function([as_source_form(r) for r in same_form if r.clase == new.clase] + [as_source_form(new)])
|
||||
|
||||
|
||||
def register(repository, *, sistema_fuente_id: str, clase: str, forma: str, registrado_por: str,
|
||||
vigente_desde: date, estudio_id: str | None = None, resultado_id: str | None = None,
|
||||
valor_id: str | None = None, motivo: str | None = None):
|
||||
"""Adds one mapping, rejected with `ValueError` if it makes a form give two codes while both are in force."""
|
||||
row = repository.model(
|
||||
sistema_fuente_id=sistema_fuente_id, clase=clase, forma=forma.strip(), forma_normalizada=normalize(forma),
|
||||
estudio_id=estudio_id, resultado_id=resultado_id, valor_id=valor_id, vigente_desde=vigente_desde,
|
||||
registrado_por=registrado_por, registrado_en=datetime.now(timezone.utc), motivo=motivo)
|
||||
return repository.add(row, check=check_stored)
|
||||
|
||||
|
||||
def catalog_rows(project: str, repository) -> tuple[object, list]:
|
||||
"""The catalog's source system and its mappings, from the TOML: study codes, captions, and each value's code,
|
||||
label and aliases. What `SourceMappingRepository.seed` adds when they're missing."""
|
||||
from webapi.orchestration.reference.catalogs import ruta_de_catalogo
|
||||
|
||||
system = repository.sistema(sistema_fuente_id=CATALOG, etiqueta="Catálogo del proyecto", fuente_tabla=None,
|
||||
vigente_desde=CATALOG_SINCE)
|
||||
now = datetime.now(timezone.utc)
|
||||
rows = {}
|
||||
|
||||
def add(clase, forma, **target):
|
||||
row = repository.model(sistema_fuente_id=CATALOG, clase=clase, forma=forma, forma_normalizada=normalize(forma),
|
||||
vigente_desde=CATALOG_SINCE, registrado_por=CATALOG, registrado_en=now, **target)
|
||||
rows.setdefault((clase, target.get("resultado_id"), target.get("estudio_id"), row.forma_normalizada), row)
|
||||
|
||||
for study_id, study in tomllib.loads(ruta_de_catalogo(project).read_text(encoding="utf-8")).items():
|
||||
for code in study.get("codigos_hospital", ()):
|
||||
add("estudio", code, estudio_id=study_id)
|
||||
for name, result in study.get("resultados", {}).items():
|
||||
result_id = f"{study_id}.{name}"
|
||||
for caption in result.get("etiquetas_fuente", ()):
|
||||
add("etiqueta", caption, resultado_id=result_id)
|
||||
for form in from_result(result_id, result):
|
||||
add("valor", form.form, resultado_id=result_id, valor_id=form.value_id)
|
||||
return system, list(rows.values())
|
||||
@@ -21,7 +21,6 @@ from persistance.edges.silver import (
|
||||
ObservationRepository,
|
||||
TimelineRepository,
|
||||
LinksRepository,
|
||||
SourceMappingRepository,
|
||||
ViewsRepository,
|
||||
)
|
||||
from persistance.materializer import Materializer
|
||||
@@ -44,7 +43,6 @@ class Silver:
|
||||
observation: ObservationRepository
|
||||
links: LinksRepository
|
||||
timeline: TimelineRepository | None = None # the patients' timeline: dbt's view, as the models and the strata read it
|
||||
mappings: SourceMappingRepository | None = None # how each source writes the catalog's codes
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -82,7 +80,6 @@ def repositories_of(proyecto: str) -> Repositories:
|
||||
observation=dominio.observation_period_repository,
|
||||
links=dominio.links_repository,
|
||||
timeline=dominio.timeline_repository,
|
||||
mappings=dominio.source_mapping_repository,
|
||||
),
|
||||
materializer=dominio.materializer,
|
||||
gold=Gold(
|
||||
|
||||
@@ -7,7 +7,6 @@ derivadas. La lee `plata_desde_staging` (`plata.carga.carga_desde_staging`).
|
||||
from core.cama.models import BiopsiaMama, Mastografia, NotaMedica, OrdenesEstudio, Paciente
|
||||
from core.cama.nota_medica.enums import ESPECIALIDAD_ALIAS, Especialidad
|
||||
|
||||
from webapi.orchestration.silver.extracted import DesdeTexto
|
||||
from webapi.orchestration.silver.orders_and_notes import nota_medica, orden_de_estudio
|
||||
from webapi.orchestration.silver.procedures import DeStaging, Hija, Padre
|
||||
|
||||
@@ -24,23 +23,6 @@ def _biopsia_que_pasa(fila) -> bool:
|
||||
return fila.bx_fecha_solicitud is not None or fila.bx_fecha_reporte is not None
|
||||
|
||||
|
||||
# Results read from text, with how the catalog says each is printed (`etiquetas_fuente`, `alias`): the
|
||||
# radiologist's interpretation, the pathology report's text layer, and the note's diagnosis and prognosis.
|
||||
DE_LA_INTERPRETACION = DesdeTexto(
|
||||
"cama", ("mastografia.densidad", "mastografia.tamano_lesion_mm"), texto=lambda f: f.mast_interpretacion,
|
||||
)
|
||||
DEL_REPORTE_DE_PATOLOGIA = DesdeTexto(
|
||||
"cama",
|
||||
("biopsia.tipo_histologico", "biopsia.grado_nottingham", "biopsia.receptor_estrogeno",
|
||||
"biopsia.receptor_estrogeno_pct", "biopsia.receptor_progesterona", "biopsia.receptor_progesterona_pct",
|
||||
"biopsia.her2", "biopsia.ki67_pct"),
|
||||
texto=lambda f: f.bx_pdf_blob,
|
||||
)
|
||||
DE_LA_NOTA = DesdeTexto(
|
||||
"cama", ("nota_medica.estadio_clinico",),
|
||||
texto=lambda f: "\n".join(t for t in (f.nm_diagnostico_texto, f.nm_pronostico) if t),
|
||||
)
|
||||
|
||||
DESDE_STAGING = (
|
||||
DeStaging(
|
||||
Mastografia, "mast_id", "toma", estudio_id="mastografia", fecha="mast_fecha_toma",
|
||||
@@ -51,17 +33,14 @@ DESDE_STAGING = (
|
||||
DeStaging(
|
||||
Mastografia, "mast_id", "reporte", estudio_id="mastografia", fecha="mast_fecha_reporte",
|
||||
solo_si=lambda f: f.mast_fecha_reporte is not None, padres=(LA_MASTOGRAFIA_DE_SU_FILA,),
|
||||
derivadas=DE_LA_INTERPRETACION.derivadas,
|
||||
resultados={"mast_birads": "mastografia.birads", **DE_LA_INTERPRETACION.resultados},
|
||||
fuentes=DE_LA_INTERPRETACION.fuentes,
|
||||
resultados={"mast_birads": "mastografia.birads"},
|
||||
),
|
||||
DeStaging(
|
||||
BiopsiaMama, "bx_id", "orden", estudio_id="biopsia", fecha="bx_fecha_solicitud",
|
||||
solo_si=_biopsia_que_pasa, padres=(LA_MASTOGRAFIA_DE_SU_FILA,), columnas={"orden_numero": "ord_numero_hospital"},
|
||||
derivadas=DEL_REPORTE_DE_PATOLOGIA.derivadas, fuentes=DEL_REPORTE_DE_PATOLOGIA.fuentes,
|
||||
hijas=(Hija("biopsia", "reporte", solo_si=("bx_fecha_reporte",), fecha="bx_fecha_reporte",
|
||||
resultados={"bx_grado_histologico": "biopsia.grado", **DEL_REPORTE_DE_PATOLOGIA.resultados}),),
|
||||
resultados={"bx_grado_histologico": "biopsia.grado"}),),
|
||||
),
|
||||
orden_de_estudio(OrdenesEstudio, ESPECIALIDAD_ALIAS, ESPECIALIDADES),
|
||||
nota_medica(NotaMedica, ESPECIALIDAD_ALIAS, ESPECIALIDADES, extraidos=DE_LA_NOTA),
|
||||
nota_medica(NotaMedica, ESPECIALIDAD_ALIAS, ESPECIALIDADES),
|
||||
)
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
"""Results of the catalog read from a staging row's text: a report's interpretation, a note, a PDF's text layer.
|
||||
|
||||
The catalog says how each result is printed (`etiquetas_fuente`, each value's `alias`;
|
||||
`reference.catalogs.resultados_extraibles`); `DesdeTexto` turns that into Extraction's field specs and into the
|
||||
derived columns, results and sources of a `DeStaging`. A coded value comes out as its `valor_id` when one of its
|
||||
spellings matches, and always with what was read as `valor_fuente`: a spelling the catalog doesn't know yet stays
|
||||
stored as text, counted as out of catalog by the silver check, and becomes a code on the next load after its alias
|
||||
is added. Nothing extracted is written anywhere but silver's two tables.
|
||||
"""
|
||||
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass, field
|
||||
from functools import lru_cache
|
||||
|
||||
from extraction import BBox, ExtractionError, FieldKind, FieldSpec, Line, read_document
|
||||
from extraction.nlp.extractors import RecordExtractor, SegmentLine
|
||||
|
||||
from webapi.orchestration.reference.catalogs import ResultadoExtraible, resultados_extraibles
|
||||
|
||||
# A value read after a caption, kept as its source when the catalog doesn't know it: enough to recognize it.
|
||||
LARGO_DE_FUENTE = 120
|
||||
TIPOS = {"codigo": FieldKind.CHOICE, "numero": FieldKind.DECIMAL, "fecha": FieldKind.DATE, "texto": FieldKind.TEXT}
|
||||
SUFIJO_DE_TEXTO = "#texto" # the plain-text twin of a coded field: what follows its caption, matched or not
|
||||
|
||||
|
||||
def especificaciones(resultado: ResultadoExtraible) -> tuple[FieldSpec, ...]:
|
||||
"""Extraction's fields for one result: the result itself and, if coded, the text after its caption."""
|
||||
choices = {forma: valor for valor, formas in resultado.alias.items() for forma in formas}
|
||||
campo = FieldSpec(
|
||||
resultado.resultado_id, TIPOS[resultado.tipo_valor], labels=resultado.etiquetas_fuente,
|
||||
choices=choices, scan_free_text=resultado.buscar_en_texto,
|
||||
)
|
||||
if resultado.tipo_valor != "codigo":
|
||||
return (campo,)
|
||||
return campo, FieldSpec(resultado.resultado_id + SUFIJO_DE_TEXTO, FieldKind.TEXT, labels=resultado.etiquetas_fuente)
|
||||
|
||||
|
||||
def lineas_de_texto(texto: str, nombre: str = "texto") -> list[SegmentLine]:
|
||||
"""A plain text as the lines of one page, as a reader would give them."""
|
||||
renglones = [r for r in texto.splitlines() if r.strip()]
|
||||
alto = 1 / max(len(renglones), 1)
|
||||
return [SegmentLine(nombre, 1, Line(r, BBox(0, i * alto, 1, (i + 1) * alto))) for i, r in enumerate(renglones)]
|
||||
|
||||
|
||||
def lineas_de_pdf(contenido: bytes) -> list[SegmentLine]:
|
||||
"""The text layer of a PDF, without OCR: a load doesn't run OCR, and a scan without text gives no lines."""
|
||||
try:
|
||||
documento = read_document("documento.pdf", contenido, ocr_mode="never")
|
||||
except ExtractionError:
|
||||
return []
|
||||
return [SegmentLine(documento.name, p.number, linea) for p in documento.pages for linea in p.lines]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class DesdeTexto:
|
||||
"""Catalog results read from what `texto` gives for a row: a text, a PDF's bytes, or nothing.
|
||||
|
||||
`derivadas`, `resultados` and `fuentes` go into the `DeStaging` (or its `Hija`) as they are. The row is read
|
||||
once for all its results.
|
||||
"""
|
||||
|
||||
proyecto: str
|
||||
resultado_ids: tuple[str, ...]
|
||||
texto: Callable[[object], str | bytes | None]
|
||||
_extraer: Callable = field(init=False, repr=False, compare=False)
|
||||
|
||||
def __post_init__(self):
|
||||
extraibles = resultados_extraibles(self.proyecto)
|
||||
faltan = [r for r in self.resultado_ids if r not in extraibles]
|
||||
if faltan:
|
||||
raise ValueError(f"Sin etiquetas_fuente en el catálogo de {self.proyecto}: {', '.join(faltan)}.")
|
||||
tipos = {r: extraibles[r].tipo_valor for r in self.resultado_ids}
|
||||
extractor = RecordExtractor([e for r in self.resultado_ids for e in especificaciones(extraibles[r])])
|
||||
|
||||
@lru_cache(maxsize=256)
|
||||
def extraer(contenido: str | bytes) -> dict[str, tuple]:
|
||||
lineas = lineas_de_pdf(contenido) if isinstance(contenido, bytes) else lineas_de_texto(contenido)
|
||||
leidos = extractor.extract(lineas)
|
||||
return {r: _valor_y_fuente(leidos.get(r), leidos.get(r + SUFIJO_DE_TEXTO), tipos[r]) for r in tipos}
|
||||
|
||||
object.__setattr__(self, "_extraer", extraer)
|
||||
|
||||
def leer(self, fila) -> dict[str, tuple]:
|
||||
"""`resultado_id` -> (value, source) read from the row; (None, None) when it isn't there."""
|
||||
contenido = self.texto(fila)
|
||||
if not contenido or (isinstance(contenido, str) and not contenido.strip()):
|
||||
return dict.fromkeys(self.resultado_ids, (None, None))
|
||||
return self._extraer(contenido)
|
||||
|
||||
@property
|
||||
def derivadas(self) -> dict[str, Callable]:
|
||||
columnas = {}
|
||||
for r in self.resultado_ids:
|
||||
columnas[_columna(r)] = lambda f, r=r: self.leer(f)[r][0]
|
||||
columnas[_columna(r) + "_fuente"] = lambda f, r=r: self.leer(f)[r][1]
|
||||
return columnas
|
||||
|
||||
@property
|
||||
def resultados(self) -> dict[str, str]:
|
||||
return {_columna(r): r for r in self.resultado_ids}
|
||||
|
||||
@property
|
||||
def fuentes(self) -> dict[str, str]:
|
||||
return {_columna(r): _columna(r) + "_fuente" for r in self.resultado_ids}
|
||||
|
||||
|
||||
def _columna(resultado_id: str) -> str:
|
||||
return "extraido:" + resultado_id
|
||||
|
||||
|
||||
def _valor_y_fuente(leido, texto, tipo_valor: str) -> tuple:
|
||||
"""A coded value with the spelling it matched, or, unmatched, with what followed its caption; others as read."""
|
||||
if tipo_valor != "codigo":
|
||||
return (None, None) if leido is None else (leido.value, None)
|
||||
if leido is not None:
|
||||
return leido.value, leido.raw
|
||||
if texto is not None and str(texto.value).strip():
|
||||
return None, str(texto.value).strip()[:LARGO_DE_FUENTE]
|
||||
return None, None
|
||||
@@ -9,13 +9,11 @@ da sus tablas y su catálogo de especialidades. Es la normalización que hacían
|
||||
como llegó;
|
||||
- el CIE-10 de la nota, sin espacios ni punto y en mayúsculas; su identificador del hospital, en `id_hospital`;
|
||||
- el motivo de consulta y el diagnóstico en texto, solo si el proyecto los pide (`con_textos`, CaCu: T-24b),
|
||||
sin normalizarlos (I-K61);
|
||||
- the catalog results a project reads from the note's texts (`extraidos`, CaMa's clinical stage).
|
||||
sin normalizarlos (I-K61).
|
||||
"""
|
||||
|
||||
from collections.abc import Collection, Mapping
|
||||
|
||||
from webapi.orchestration.silver.extracted import DesdeTexto
|
||||
from webapi.orchestration.silver.values import INTENCION, cie, codigo_de_especialidad, texto_limpio
|
||||
from webapi.orchestration.silver.procedures import DeStaging
|
||||
|
||||
@@ -54,26 +52,22 @@ def orden_de_estudio(staging: type, alias: Mapping[str, str], codigos: Collectio
|
||||
|
||||
|
||||
def nota_medica(
|
||||
staging: type, alias: Mapping[str, str], codigos: Collection[str], *, con_textos: bool = False,
|
||||
extraidos: DesdeTexto | None = None,
|
||||
staging: type, alias: Mapping[str, str], codigos: Collection[str], *, con_textos: bool = False
|
||||
) -> DeStaging:
|
||||
textos = {
|
||||
"motivo": lambda f: texto_limpio(f.nm_motivo_consulta),
|
||||
"diagnostico_texto": lambda f: texto_limpio(f.nm_diagnostico_texto),
|
||||
} if con_textos else {}
|
||||
leidos = extraidos.derivadas if extraidos else {}
|
||||
return DeStaging(
|
||||
staging, "nm_id", "encuentro", estudio_id="nota_medica", fecha="nm_fecha",
|
||||
columnas={"id_hospital": "nm_id_hospital"}, # para ligarla después con sus órdenes (provisional)
|
||||
derivadas={
|
||||
"cie_codigo": lambda f: cie(f.nm_cie_codigo), **especialidad("nm_especialidad", alias, codigos), **textos,
|
||||
**leidos,
|
||||
},
|
||||
resultados={
|
||||
"cie_codigo": "nota_medica.diagnostico",
|
||||
"especialidad": "nota_medica.especialidad",
|
||||
**({f: f"nota_medica.{f}" for f in textos}),
|
||||
**(extraidos.resultados if extraidos else {}),
|
||||
},
|
||||
fuentes={"especialidad": "especialidad_fuente", **(extraidos.fuentes if extraidos else {})},
|
||||
fuentes={"especialidad": "especialidad_fuente"},
|
||||
)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"""A CaCu patient's individual risk: `GET /cacu/pacientes/<pac_id>/riesgo`.
|
||||
"""A CaCu patient's individual risk: `GET /cacu/pacientes/<pac_id>/riesgo`, only in DEV.
|
||||
|
||||
The contract the WebApp's patient record reads (`RiesgoPacienteCacu`): the patient's membership in the surveillance
|
||||
cohort's latest build, with its variables, and its risks in the current batch, the newest one with a confirmed
|
||||
evaluation. Patient data, on simulated data: every response carries `simulado: true`. The route is always registered;
|
||||
who may see it is an access rule still to be defined. `pac_id` is the internal id; whoever calls is already inside the secure environment. A field is never
|
||||
evaluation. Patient data: **registered only in DEV** (`DEV_REVISION`), on simulated data, and every response carries
|
||||
`simulado: true`. `pac_id` is the internal id; whoever calls is already inside the secure environment. A field is never
|
||||
removed or renamed, only added.
|
||||
"""
|
||||
|
||||
@@ -16,7 +16,7 @@ COHORT_VARIABLES = ("tipo_censura", "c", "l", "r", "pap_0", "hpv_0")
|
||||
|
||||
|
||||
def patient_risk_blueprint(repositories) -> Blueprint:
|
||||
"""The blueprint, to register with `url_prefix="/cacu"`. `repositories` is `persistance.cacu`."""
|
||||
"""The blueprint, to register with `url_prefix="/cacu"` only in DEV. `repositories` is `persistance.cacu`."""
|
||||
blueprint = Blueprint("cacu_patient_risk", __name__)
|
||||
|
||||
@blueprint.get("/pacientes/<int:pac_id>/riesgo")
|
||||
|
||||
Reference in New Issue
Block a user