File size: 1,365 Bytes
1fa95ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
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()