Rebuild: FastAPI skeleton with health, domains, run status and the auth seam

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rockdrigo
2026-11-24 11:18:08 -06:00
commit df921f13cd
7 changed files with 106 additions and 0 deletions
View File
+12
View File
@@ -0,0 +1,12 @@
"""The one dependency every route goes through. Open for now; this is where auth will go."""
from dataclasses import dataclass
@dataclass(frozen=True)
class Caller:
id: str = "anonymous"
def caller() -> Caller:
return Caller()
+41
View File
@@ -0,0 +1,41 @@
import os
from dagster_graphql import DagsterGraphQLClient, DagsterGraphQLClientError
from fastapi import Depends, FastAPI, HTTPException
from core.domains import Domain
from webapi.auth import caller
app = FastAPI(
title="ISSSTELEON",
version="0.0.0",
dependencies=[Depends(caller)],
generate_unique_id_function=lambda route: route.name, # clean names in the generated client
)
def dagster() -> DagsterGraphQLClient:
return DagsterGraphQLClient(
os.environ.get("DAGSTER_HOST", "localhost"),
port_number=int(os.environ.get("DAGSTER_PORT", "3000")),
)
@app.get("/health")
def health() -> dict[str, str]:
return {"status": "ok"}
@app.get("/domains")
def domains() -> list[Domain]:
return list(Domain)
@app.get("/runs/{run_id}")
def run_status(run_id: str, client: DagsterGraphQLClient = Depends(dagster)) -> dict[str, str]:
try:
return {"id": run_id, "status": client.get_run_status(run_id).value}
except DagsterGraphQLClientError as e:
raise HTTPException(
status_code=404 if "RunNotFound" in str(e) else 502, detail=str(e)
) from e
+8
View File
@@ -0,0 +1,8 @@
"""Print the OpenAPI document; the WebApp generates its client from it."""
import json
from webapi.main import app
if __name__ == "__main__":
print(json.dumps(app.openapi(), indent=1, sort_keys=True))