fix(web): stop presenting an unscored case as a failed analysis, and four smaller things
From clicking through the redesigned UI: - scoring a case without a model registry painted a red failure across a case that had in fact analysed fine. It is now a quiet note saying the model term contributes 0, because scoring is an optional fourth of the rank, not the analysis. - the MLflow default moves to port 5001. On macOS, AirPlay Receiver owns 5000, which is why the registry answered "403" rather than refusing the connection; docker-compose publishes 5001 to match. - a funnel step that kept nothing drew a visible bar. Zero now draws zero. - "1 candidates". - the funnel's fixed grid columns forced a horizontal scrollbar on the report. The report also lists the top undecided candidates now: the first thing anyone opens has no decisions in it, and "Shortlisted (0)" alone said nothing about what the tool found. Tests: api 77, web 32; ruff, mypy, svelte-check clean.
This commit is contained in:
+2
-1
@@ -10,7 +10,8 @@ class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
||||
|
||||
database_url: str = "postgresql+asyncpg://rarelens:rarelens@localhost:5432/rarelens"
|
||||
mlflow_tracking_uri: str = "http://localhost:5000"
|
||||
# docker-compose publishes MLflow on 5001; macOS AirPlay Receiver owns 5000.
|
||||
mlflow_tracking_uri: str = "http://localhost:5001"
|
||||
model_name: str = "rarelens-pathogenicity"
|
||||
# Registry alias set by `rarelens_ml.train --register` (stages are deprecated in MLflow 3).
|
||||
model_alias: str = "production"
|
||||
|
||||
@@ -36,6 +36,8 @@ from app.services.scoring import score_job
|
||||
logger = logging.getLogger(__name__)
|
||||
router = APIRouter()
|
||||
|
||||
REPORT_TOP = 5
|
||||
|
||||
|
||||
async def _case_or_404(session: SessionDep, case_id: uuid.UUID) -> Case:
|
||||
case = await case_view.get_case(session, case_id)
|
||||
@@ -208,6 +210,11 @@ async def report(case_id: uuid.UUID, session: SessionDep) -> ReportOut:
|
||||
]
|
||||
|
||||
shortlisted, dismissed = decided(DecisionState.shortlisted), decided(DecisionState.dismissed)
|
||||
top = [
|
||||
CandidateOut.from_candidate(c, labels)
|
||||
for c in view.candidates
|
||||
if c.variant.decision is None
|
||||
][:REPORT_TOP]
|
||||
prediction = next((c.variant.prediction for c in view.candidates if c.variant.prediction), None)
|
||||
return ReportOut(
|
||||
case=_as_case_out(case, view.job, len(shortlisted)),
|
||||
@@ -222,4 +229,5 @@ async def report(case_id: uuid.UUID, session: SessionDep) -> ReportOut:
|
||||
),
|
||||
shortlisted=shortlisted,
|
||||
dismissed=dismissed,
|
||||
top=top,
|
||||
)
|
||||
|
||||
@@ -170,6 +170,8 @@ class ReportOut(BaseModel):
|
||||
provenance: ProvenanceOut
|
||||
shortlisted: list[CandidateOut]
|
||||
dismissed: list[CandidateOut]
|
||||
# What a reviewer would look at next; a report with no decisions yet still says something.
|
||||
top: list[CandidateOut]
|
||||
|
||||
|
||||
class ScoreOut(BaseModel):
|
||||
|
||||
@@ -113,6 +113,30 @@ async def test_the_report_is_the_decision_trail(client: AsyncClient) -> None:
|
||||
assert report["provenance"]["vep_version"] == "113.0"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("db")
|
||||
async def test_the_report_shows_the_top_candidates_before_anyone_decides(
|
||||
client: AsyncClient,
|
||||
) -> None:
|
||||
"""The first thing anyone opens is a report with no decisions in it; it must still say something."""
|
||||
case_id, _ = await a_case_with_candidates()
|
||||
|
||||
report = (await client.get(f"/api/cases/{case_id}/report")).json()
|
||||
assert report["shortlisted"] == []
|
||||
assert [c["variant"]["gene"] for c in report["top"]] == ["NF2", "CHEK2"]
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("db")
|
||||
async def test_the_report_drops_decided_variants_from_the_top_list(client: AsyncClient) -> None:
|
||||
case_id, _ = await a_case_with_candidates()
|
||||
items = (await client.get(f"/api/cases/{case_id}/candidates")).json()["items"]
|
||||
await client.post(f"/api/variants/{items[0]['variant']['id']}/decision",
|
||||
json={"state": "shortlisted", "reason": "fits"})
|
||||
|
||||
report = (await client.get(f"/api/cases/{case_id}/report")).json()
|
||||
assert [c["variant"]["gene"] for c in report["shortlisted"]] == ["NF2"]
|
||||
assert [c["variant"]["gene"] for c in report["top"]] == ["CHEK2"]
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("db")
|
||||
async def test_candidates_can_still_be_filtered(client: AsyncClient) -> None:
|
||||
case_id, _ = await a_case_with_candidates()
|
||||
|
||||
Reference in New Issue
Block a user