Spaces:
Running
Running
Download server/app.py from openenv/grid_world_env: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/openenv/grid_world_env/resolve/main/server/app.py
- Command line
-
hf download hf://spaces/openenv/grid_world_env/server/app.py
-
curl -L -o app.py https://huggingface.co/spaces/openenv/grid_world_env/resolve/main/server/app.py
1.21 kB
| # Copyright (c) Meta Platforms, Inc. and affiliates. | |
| # All rights reserved. | |
| # | |
| # This source code is licensed under the BSD-style license found in the | |
| # LICENSE file in the root directory of this source tree. | |
| """ | |
| Application entry point for the Grid World Environment. | |
| This module exposes the GridWorldEnvironment via the OpenEnv WebSocket API. | |
| """ | |
| import os | |
| # Import the correct app creation function from the core library | |
| try: | |
| from openenv.core.env_server import create_app | |
| except ImportError: | |
| from core.env_server import create_app | |
| # Import our models and environment classes using relative paths | |
| from ..models import GridWorldAction, GridWorldObservation | |
| from .grid_world_environment import GridWorldEnvironment | |
| # Create single environment instance | |
| # This is reused for all HTTP requests. | |
| # env = GridWorldEnvironment() | |
| # Create the FastAPI app | |
| app = create_app( | |
| GridWorldEnvironment, | |
| GridWorldAction, | |
| GridWorldObservation, | |
| env_name="grid_world_env", | |
| max_concurrent_envs=int(os.getenv("MAX_CONCURRENT_ENVS", "8")), | |
| ) | |
| # --- 3. Add Entry Point --- | |
| def main(): | |
| import uvicorn | |
| uvicorn.run(app, host="0.0.0.0", port=8000) | |
| if __name__ == "__main__": | |
| main() | |