Skip to content

armgit / burr

Public Imported from GitHub
0

Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.

Adds a ready API for deploying burr telemetry

elijahbenizzyfa210d3d7fae
diff --git a/burr/tracking/server/run.py b/burr/tracking/server/run.py
index 51d3a940..ea1a4255 100644
--- a/burr/tracking/server/run.py
+++ b/burr/tracking/server/run.py
@@ -51,7 +51,6 @@ SERVE_STATIC = os.getenv("BURR_SERVE_STATIC", "true").lower() == "true"
SENTINEL_PARTITION_KEY = "__none__"
-
backend = BackendBase.create_from_env()
@@ -92,6 +91,9 @@ async def save_snapshot():
logger.info("Saved snapshot of DB for recovery")
+initialized = False
+
+
@asynccontextmanager
async def lifespan(app: FastAPI):
# Download if it does it
@@ -101,6 +103,8 @@ async def lifespan(app: FastAPI):
await backend.lifespan(app).__anext__()
await sync_index() # this will trigger the repeat every N seconds
await save_snapshot() # this will trigger the repeat every N seconds
+ global initialized
+ initialized = True
yield
await backend.lifespan(app).__anext__()
@@ -108,6 +112,15 @@ async def lifespan(app: FastAPI):
app = FastAPI(lifespan=lifespan)
+def is_ready():
+ if not initialized:
+ raise HTTPException(
+ status_code=status.HTTP_503_SERVICE_UNAVAILABLE, detail="Backend is not ready yet."
+ )
+ return {"ready": True}
+
+
@app.get("/api/v0/metadata/app_spec", response_model=BackendSpec)
def get_app_spec():
is_indexing_backend = isinstance(backend, IndexingBackendMixin)