Spaces:
Sleeping
Sleeping
File size: 1,483 Bytes
9c4d9c0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | """Shared API schemas for HF Space observability endpoints."""
from __future__ import annotations
from datetime import datetime
from typing import Any, Dict, List
from pydantic import BaseModel, Field
class BuildMetadata(BaseModel):
service: str = "missionctrl"
version: str = "1.0.0"
container_id: str = "unknown"
build_id: str = "unknown"
git_sha: str = "unknown"
runtime: str = "huggingface-space"
started_at: datetime
class HeartbeatResponse(BaseModel):
status: str = "ok"
service: str = "missionctrl"
version: str = "1.0.0"
container_id: str = "unknown"
build_id: str = "unknown"
git_sha: str = "unknown"
runtime: str = "huggingface-space"
host: str = "0.0.0.0"
port: int = 8000
uptime_seconds: float = 0.0
timestamp_utc: datetime
details: Dict[str, Any] = Field(default_factory=dict)
class RequestLogEntry(BaseModel):
timestamp: datetime
method: str
path: str
status_code: int
duration_ms: float
container_id: str = "unknown"
class StateResponse(BaseModel):
status: str = "ok"
build: BuildMetadata
observation: Dict[str, object]
class LogsSummaryResponse(BaseModel):
status: str = "ok"
build: BuildMetadata
totals: Dict[str, int] = Field(default_factory=dict)
statuses: Dict[str, int] = Field(default_factory=dict)
paths: Dict[str, int] = Field(default_factory=dict)
entries: List[RequestLogEntry] = Field(default_factory=list)
|