| """ |
| FastAPI application for the SRE Incident Investigation Environment. |
| |
| Endpoints: |
| POST /reset β Reset environment (returns initial observation) |
| POST /step β Execute an action |
| GET /state β Current episode state |
| GET /schema β Action / observation / state schemas |
| WS /ws β Persistent WebSocket session |
| GET /health β Health check |
| GET /web β Interactive web UI |
| """ |
|
|
| try: |
| from openenv.core.env_server.http_server import create_app |
| except Exception as e: |
| raise ImportError( |
| "openenv is required. Install with: pip install openenv-core" |
| ) from e |
|
|
| try: |
| from ..models import SREAction, SREObservation |
| from .sre_environment import SREEnvironment |
| except (ImportError, ModuleNotFoundError): |
| from models import SREAction, SREObservation |
| from server.sre_environment import SREEnvironment |
|
|
|
|
| app = create_app( |
| SREEnvironment, |
| SREAction, |
| SREObservation, |
| env_name="sre_env", |
| max_concurrent_envs=50, |
| ) |
|
|
|
|
| def main(host: str = "0.0.0.0", port: int = 8000): |
| import uvicorn |
| uvicorn.run(app, host=host, port=port) |
|
|
|
|
| if __name__ == "__main__": |
| import argparse |
| parser = argparse.ArgumentParser() |
| parser.add_argument("--port", type=int, default=8000) |
| parser.add_argument("--host", type=str, default="0.0.0.0") |
| args = parser.parse_args() |
| main() |
|
|