Conectar API: sources, uploads, pipelines, runs, node rows, review; tested end to end
This commit is contained in:
+6
-22
@@ -1,24 +1,18 @@
|
||||
import os
|
||||
|
||||
from dagster_graphql import DagsterGraphQLClient, DagsterGraphQLClientError
|
||||
from fastapi import Depends, FastAPI, HTTPException
|
||||
from fastapi import Depends, FastAPI
|
||||
|
||||
from core.domains import Domain
|
||||
from webapi import ingest, review, runs
|
||||
from webapi.auth import caller
|
||||
|
||||
app = FastAPI(
|
||||
title="ISSSTELEON",
|
||||
version="0.0.0",
|
||||
dependencies=[Depends(caller)],
|
||||
dependencies=[Depends(caller)], # every route; where authentication will go
|
||||
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.include_router(ingest.router)
|
||||
app.include_router(review.router)
|
||||
app.include_router(runs.router)
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
@@ -29,13 +23,3 @@ def health() -> dict[str, str]:
|
||||
@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
|
||||
|
||||
Reference in New Issue
Block a user