Team Ai
Apppublic

DEVessi/devops_sandbox

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
app.py60 linesDownload Raw Back to server
1# Copyright (c) Meta Platforms, Inc. and affiliates.2# All rights reserved.3#4# This source code is licensed under the BSD-style license found in the5# LICENSE file in the root directory of this source tree.6 7"""8FastAPI application for the Self-Healing DevOps Sandbox Environment.9 10Endpoints:11    - POST /reset: Reset the environment (build & start container)12    - POST /step: Execute a bash command inside the container13    - GET /state: Get current environment state14    - GET /schema: Get action/observation schemas15    - WS /ws: WebSocket endpoint for persistent sessions16 17Usage:18    uvicorn server.app:app --reload --host 0.0.0.0 --port 800019"""20 21try:22    from openenv.core.env_server.http_server import create_app23except Exception as e:  # pragma: no cover24    raise ImportError(25        "openenv is required. Install with:\n    uv sync\n"26    ) from e27 28try:29    from ..models import BashAction, TerminalObservation30    from .devops_sandbox_environment import DevOpsSandbox31except (ImportError, ModuleNotFoundError):32    from models import BashAction, TerminalObservation33    from server.devops_sandbox_environment import DevOpsSandbox34 35 36# Create the app — DevOpsSandbox is passed as a class (factory mode)37app = create_app(38    DevOpsSandbox,39    BashAction,40    TerminalObservation,41    env_name="devops_sandbox",42    max_concurrent_envs=1,43)44 45 46def main(host: str = "0.0.0.0", port: int = 8000):47    """48    Entry point for direct execution.49 50        uv run --project . server51        python -m devops_sandbox.server.app52    """53    import uvicorn54 55    uvicorn.run(app, host=host, port=port)56 57 58if __name__ == "__main__":59    main()60