initial commit
This commit is contained in:
commit
88c14b627e
224 files changed
+17204
No files matched your search
@@ -0,0 +1 @@
|
||||
"""HTTP endpoints for the ML service."""
|
||||
@@ -0,0 +1,33 @@
|
||||
from fastapi import APIRouter, Response, status
|
||||
|
||||
from lincodex_ml.api.models import MLHealthResponse, MLReadinessResponse
|
||||
|
||||
router = APIRouter(tags=["health"])
|
||||
|
||||
|
||||
@router.get(
|
||||
"/healthz",
|
||||
operation_id="GetMLHealthz",
|
||||
response_model=MLHealthResponse,
|
||||
status_code=status.HTTP_200_OK,
|
||||
summary="Check whether the ML process is responding.",
|
||||
)
|
||||
async def get_healthz() -> MLHealthResponse:
|
||||
return MLHealthResponse(status="ok")
|
||||
|
||||
|
||||
@router.get(
|
||||
"/readyz",
|
||||
operation_id="GetMLReadyz",
|
||||
response_model=MLReadinessResponse,
|
||||
responses={
|
||||
status.HTTP_503_SERVICE_UNAVAILABLE: {
|
||||
"model": MLReadinessResponse,
|
||||
"description": "No inference runtime is available.",
|
||||
}
|
||||
},
|
||||
summary="Check whether an inference runtime is available.",
|
||||
)
|
||||
async def get_readyz(response: Response) -> MLReadinessResponse:
|
||||
response.status_code = status.HTTP_503_SERVICE_UNAVAILABLE
|
||||
return MLReadinessResponse(status="not_ready")
|
||||
@@ -0,0 +1,20 @@
|
||||
# generated by datamodel-codegen:
|
||||
# filename: openapi.bundle.yml
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
|
||||
class MLHealthResponse(BaseModel):
|
||||
model_config = ConfigDict(
|
||||
extra="forbid",
|
||||
)
|
||||
status: Literal["ok"]
|
||||
|
||||
|
||||
class MLReadinessResponse(BaseModel):
|
||||
model_config = ConfigDict(
|
||||
extra="forbid",
|
||||
)
|
||||
status: Literal["ready", "not_ready"]
|
||||
Reference in new issue
Block a user