Cleanup of the TEA parity work: no prose in code, no hacks, everything in its place
1. No prose in code - Remove parity-added Python comments and docstrings across the EEG, FHIR, execution, preview, training and run code and tests. Preserve endpoint descriptions as explicit FastAPI schema metadata. 2. No hacks, no glued code - Read the declared TEA patient filters and training inputs directly and use the same TEA check for exposing and validating reference options. - Give the Dagster GraphQL request one helper. Keep lock backoff and cancellation polling because their timing and error behavior are covered by run tests and they handle different Dagster states. - Use the renamed FHIR report ID helper in the hospital test. Keep TEA_GATE_SLOW local to that test and preserve the test assertions. 3. Everything in its place - Keep endpoint and run handling in WebApi and reuse Core and Persistance for domain rules and reads. Leave tests in the existing testpaths.
This commit is contained in:
+5
-7
@@ -12,7 +12,7 @@ from fastapi import APIRouter, Depends, File, HTTPException, Query, UploadFile
|
||||
from fastapi.responses import Response
|
||||
from pydantic import BaseModel, Field, WithJsonSchema
|
||||
|
||||
from core import domains
|
||||
from core import tea
|
||||
from core.domains import Domain, InputSpec
|
||||
from persistance import bundle, cluster, inputs, registry
|
||||
from persistance.cluster import Execution, Reference
|
||||
@@ -176,7 +176,7 @@ def lineage(domain: Domain, name: str, version: int) -> dict:
|
||||
|
||||
|
||||
def _training_inputs(domain: Domain, name: str) -> tuple[InputSpec, Path]:
|
||||
declared = getattr(domains.part(domain), "TRAINING_INPUTS", {})
|
||||
declared = tea.TRAINING_INPUTS if domain == Domain.TEA else {}
|
||||
spec = declared.get(name, declared.get("*"))
|
||||
if spec is None:
|
||||
raise HTTPException(404, detail=f"no training inputs for {domain.value}.{name}")
|
||||
@@ -233,7 +233,7 @@ class TrainingForm(BaseModel):
|
||||
|
||||
|
||||
class Training(TrainingForm):
|
||||
models: list[str] = [] # which (default: all but the slow ones, like CaMa's recurrence)
|
||||
models: list[str] = []
|
||||
|
||||
|
||||
class TrainingConfig(BaseModel):
|
||||
@@ -247,7 +247,7 @@ class TrainingConfig(BaseModel):
|
||||
def training_config(domain: Domain, name: str) -> TrainingConfig:
|
||||
json_schema = TrainingForm.model_json_schema()
|
||||
defaults = {"execution": {"mode": cluster.default_mode(), "scheduler": None}}
|
||||
if "reference" in getattr(domains.part(domain), "TRAINING_OPTIONS", ()):
|
||||
if domain == Domain.TEA:
|
||||
defaults["reference"] = {"line_hz": 50}
|
||||
else:
|
||||
del json_schema["properties"]["reference"]
|
||||
@@ -265,9 +265,7 @@ class Analyze(BaseModel):
|
||||
def train(domain: Domain, request: Training,
|
||||
client: DagsterGraphQLClient = Depends(dagster)) -> dict[str, str]: # fmt: skip
|
||||
"""Starts training a new version of every model of the domain; follow it at /runs."""
|
||||
if request.reference is not None and "reference" not in getattr(
|
||||
domains.part(domain), "TRAINING_OPTIONS", ()
|
||||
):
|
||||
if request.reference is not None and domain != Domain.TEA:
|
||||
raise HTTPException(422, f"{domain.value} models take no reference cohort")
|
||||
config: dict = {"domain": domain.value, "execution": execution_config(request.execution)}
|
||||
if request.as_of:
|
||||
|
||||
Reference in New Issue
Block a user