File size: 1,206 Bytes
812398b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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()