Runs API: a run's state, steps, live progress, info and warnings apart, the failure's own message; cancel; history by job and domain; execution options and health; POST /tea/eegs/analyze
test_runs.py: 17 passed on SQLite and Postgres (compose test stack). test_conectar.py fails on an identity-merge count, as it does on tea/parity without this change.
This commit is contained in:
+16
-1
@@ -1,10 +1,13 @@
|
||||
"""TEA's EEGs for model governance: every study with its analysis verdict, and one study's
|
||||
metrics with their age curves' scores."""
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
from persistance import eeg
|
||||
from persistance.cluster import Execution
|
||||
from persistance.eeg import Scope
|
||||
from webapi.runs import dagster, execution_config, submit
|
||||
|
||||
router = APIRouter(prefix="/tea/eegs", tags=["eeg"])
|
||||
|
||||
@@ -35,11 +38,23 @@ class Analysis(BaseModel):
|
||||
metrics: list[Metric]
|
||||
|
||||
|
||||
class AnalyzeRequest(BaseModel):
|
||||
scope: Scope = Scope()
|
||||
execution: Execution | None = None
|
||||
|
||||
|
||||
@router.get("")
|
||||
def studies() -> list[Study]:
|
||||
return [Study(**s) for s in eeg.studies()]
|
||||
|
||||
|
||||
@router.post("/analyze")
|
||||
def analyze_eegs(request: AnalyzeRequest, client=Depends(dagster)) -> dict[str, str]:
|
||||
"""Starts `tea_eeg`: analyse the EEGs in scope, score the curves, rebuild gold."""
|
||||
config = {"scope": request.scope.model_dump(), "execution": execution_config(request.execution)}
|
||||
return submit(client, "tea_eeg", "tea_analyze_studies", config, domain="tea")
|
||||
|
||||
|
||||
@router.get("/{eeg_id}")
|
||||
def study(eeg_id: str) -> Analysis:
|
||||
if (found := eeg.study(eeg_id)) is None:
|
||||
|
||||
Reference in New Issue
Block a user