Automático: draw-only option; end-to-end test covers biopsies, treatments and deaths

This commit is contained in:
Roberto Treviño
2026-12-03 15:22:15 -06:00
parent 70c88c54dd
commit 05d0e4c278
2 changed files with 9 additions and 6 deletions
+5 -2
View File
@@ -9,6 +9,8 @@ import json
from test_conectar import ok, wait_for from test_conectar import ok, wait_for
SOURCE = "resultados" SOURCE = "resultados"
# Studies whose every record the operator's drawing places, the draft must place too.
DRAWN = ("cervical_cytology", "mammography", "cervical_biopsy", "breast_biopsy")
HOURS = 3600 # with a model answering, it reads every document: an hour or more per run HOURS = 3600 # with a model answering, it reads every document: an hour or more per run
@@ -39,7 +41,8 @@ def test_automatico_drafts_a_sites_pipeline_and_runs_it(api, platform, site):
kinds = [n["kind"] for n in saved["pipeline"]["nodes"]] kinds = [n["kind"] for n in saved["pipeline"]["nodes"]]
assert {"read", "route", "extract", "link", "target"} <= set(kinds) assert {"read", "route", "extract", "link", "target"} <= set(kinds)
studies = {n["entity"] for n in saved["pipeline"]["nodes"] if n["kind"] == "target"} studies = {n["entity"] for n in saved["pipeline"]["nodes"] if n["kind"] == "target"}
assert {"cervical_cytology", "mammography"} <= studies, studies # One layout may report several studies: pathology by organ, notes by what they record.
assert set(DRAWN) | {"breast_treatment", "death"} <= studies, studies
# Documents no route claims wait for a reviewer, as with a drawn pipeline. # Documents no route claims wait for a reviewer, as with a drawn pipeline.
assert any(n.get("otherwise") for n in saved["pipeline"]["nodes"]) assert any(n.get("otherwise") for n in saved["pipeline"]["nodes"])
@@ -51,7 +54,7 @@ def test_automatico_drafts_a_sites_pipeline_and_runs_it(api, platform, site):
both = set(mine) & set(theirs) both = set(mine) & set(theirs)
differ = {k: (mine[k], theirs[k]) for k in both if str(mine[k]) != str(theirs[k])} differ = {k: (mine[k], theirs[k]) for k in both if str(mine[k]) != str(theirs[k])}
assert both and not differ, differ assert both and not differ, differ
for study in ("cervical_cytology", "mammography"): for study in DRAWN:
drawn_records = {r for s, r, _ in theirs if s == study} drawn_records = {r for s, r, _ in theirs if s == study}
assert drawn_records <= {r for s, r, _ in mine if s == study}, study assert drawn_records <= {r for s, r, _ in mine if s == study}, study
+4 -4
View File
@@ -156,11 +156,11 @@ def language_model() -> LanguageModel:
@router.post("/pipelines/{pipeline_id}/draft") @router.post("/pipelines/{pipeline_id}/draft")
def start_draft( def start_draft(
pipeline_id: PipelineId, client: DagsterGraphQLClient = Depends(dagster) pipeline_id: PipelineId, run: bool = True, client: DagsterGraphQLClient = Depends(dagster)
) -> dict[str, str]: ) -> dict[str, str]:
"""Automático: starts the `draft` job, which draws the whole pipeline from its saved """Automático: starts the `draft` job, which draws the whole pipeline from its saved
sources (the only nodes it may hold), saves it as a new version and runs it; follow it sources (the only nodes it may hold), saves it as a new version and runs it (`run`
at /runs/{run_id}.""" false: drawn and saved only); follow it at /runs/{run_id}."""
if not config_log.latest_version(pipeline_id): if not config_log.latest_version(pipeline_id):
raise HTTPException(404, detail=f"no pipeline {pipeline_id}") raise HTTPException(404, detail=f"no pipeline {pipeline_id}")
_, saved = config_log.get(pipeline_id) _, saved = config_log.get(pipeline_id)
@@ -169,7 +169,7 @@ def start_draft(
"fuentes: guárdela solo con ellas.") # fmt: skip "fuentes: guárdela solo con ellas.") # fmt: skip
if not (found := llm.status())["available"]: if not (found := llm.status())["available"]:
raise HTTPException(503, detail=f"El modelo de lenguaje no responde: {found['reason']}") raise HTTPException(503, detail=f"El modelo de lenguaje no responde: {found['reason']}")
config = {"ops": {"draft_pipeline": {"config": {"pipeline": pipeline_id}}}} config = {"ops": {"draft_pipeline": {"config": {"pipeline": pipeline_id, "run": run}}}}
try: try:
return {"run_id": client.submit_job_execution("draft", run_config=config)} return {"run_id": client.submit_job_execution("draft", run_config=config)}
except DagsterGraphQLClientError as e: except DagsterGraphQLClientError as e: