Models are listed with their titles
This commit is contained in:
+1
-1
@@ -129,7 +129,7 @@ def test_cacu_from_the_hospital_to_indicators_and_risks(api, platform, tmp_path)
|
|||||||
# Models: one training run gives a version of each, with its two generated reports;
|
# Models: one training run gives a version of each, with its two generated reports;
|
||||||
# none is promoted without the clinical validation.
|
# none is promoted without the clinical validation.
|
||||||
wait_for(api, ok(api.post("/models/cacu/train", json={"as_of": REFERENCE_CUTOFF}))["run_id"])
|
wait_for(api, ok(api.post("/models/cacu/train", json={"as_of": REFERENCE_CUTOFF}))["run_id"])
|
||||||
names = ok(api.get("/models/cacu"))
|
names = [m["name"] for m in ok(api.get("/models/cacu"))]
|
||||||
assert set(names) == set(current)
|
assert set(names) == set(current)
|
||||||
for name in names:
|
for name in names:
|
||||||
(version,) = ok(api.get(f"/models/cacu/{name}/versions"))
|
(version,) = ok(api.get(f"/models/cacu/{name}/versions"))
|
||||||
|
|||||||
+1
-1
@@ -165,7 +165,7 @@ def test_cama_from_the_hospital_to_indicators(api, platform, tmp_path):
|
|||||||
# none is promoted without the clinical validation.
|
# none is promoted without the clinical validation.
|
||||||
current = json.loads((REFERENCE / "models.json").read_text())
|
current = json.loads((REFERENCE / "models.json").read_text())
|
||||||
wait_for(api, ok(api.post("/models/cama/train", json={"as_of": TRAINED_ON}))["run_id"])
|
wait_for(api, ok(api.post("/models/cama/train", json={"as_of": TRAINED_ON}))["run_id"])
|
||||||
names = ok(api.get("/models/cama"))
|
names = [m["name"] for m in ok(api.get("/models/cama"))]
|
||||||
assert set(names) == {n for n, m in current.items() if m["status"] == "ok"}
|
assert set(names) == {n for n, m in current.items() if m["status"] == "ok"}
|
||||||
for name in names:
|
for name in names:
|
||||||
(version,) = ok(api.get(f"/models/cama/{name}/versions"))
|
(version,) = ok(api.get(f"/models/cama/{name}/versions"))
|
||||||
|
|||||||
+1
-1
@@ -213,7 +213,7 @@ def test_tea_from_the_hospital_to_indicators(api, platform, tmp_path):
|
|||||||
group = platform_eeg(platform).ruled_out(date.today())
|
group = platform_eeg(platform).ruled_out(date.today())
|
||||||
assert len(group) >= 5, "the hospital needs children with TEA ruled out and a good EEG"
|
assert len(group) >= 5, "the hospital needs children with TEA ruled out and a good EEG"
|
||||||
wait_for(api, ok(api.post("/models/tea/train", json={}))["run_id"], 3600)
|
wait_for(api, ok(api.post("/models/tea/train", json={}))["run_id"], 3600)
|
||||||
names = ok(api.get("/models/tea"))
|
names = [m["name"] for m in ok(api.get("/models/tea"))]
|
||||||
assert set(names) >= set(curves.SCENARIOS)
|
assert set(names) >= set(curves.SCENARIOS)
|
||||||
files = {"file": ("validacion.pdf", b"%PDF-1.4 clinical validation", "application/pdf")}
|
files = {"file": ("validacion.pdf", b"%PDF-1.4 clinical validation", "application/pdf")}
|
||||||
for name in curves.SCENARIOS:
|
for name in curves.SCENARIOS:
|
||||||
|
|||||||
+9
-2
@@ -10,6 +10,7 @@ from fastapi.responses import Response
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from core.domains import Domain
|
from core.domains import Domain
|
||||||
|
from core.models import title
|
||||||
from persistance import registry
|
from persistance import registry
|
||||||
from webapi.runs import dagster
|
from webapi.runs import dagster
|
||||||
|
|
||||||
@@ -25,10 +26,16 @@ class Version(BaseModel):
|
|||||||
reports: list[str]
|
reports: list[str]
|
||||||
|
|
||||||
|
|
||||||
|
class Model(BaseModel):
|
||||||
|
name: str
|
||||||
|
title: str # as the pages name it
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{domain}")
|
@router.get("/{domain}")
|
||||||
def models(domain: Domain) -> list[str]:
|
def models(domain: Domain) -> list[Model]:
|
||||||
|
"""The domain's registered models, with their names on screen."""
|
||||||
prefix = f"{domain.value}."
|
prefix = f"{domain.value}."
|
||||||
return [n.removeprefix(prefix) for n in registry.names(prefix)]
|
return [Model(name=n.removeprefix(prefix), title=title(n)) for n in registry.names(prefix)]
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{domain}/{name}/versions")
|
@router.get("/{domain}/{name}/versions")
|
||||||
|
|||||||
Reference in New Issue
Block a user