Spaces:
Sleeping
Sleeping
File size: 1,157 Bytes
f15113b | 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 | """
FastAPI application for the Methanol APC Environment.
Exposes the MethanolAPCEnvironment over HTTP and WebSocket endpoints,
compatible with the OpenEnv EnvClient.
"""
try:
from openenv.core.env_server.http_server import create_app
except Exception as e:
raise ImportError(
"openenv is required for the web interface. "
"Install dependencies with: uv sync"
) from e
try:
from models import MethanolAPCAction, MethanolAPCObservation
except ImportError:
from ..models import MethanolAPCAction, MethanolAPCObservation
try:
from methanol_environment import MethanolAPCEnvironment
except ImportError:
from .methanol_environment import MethanolAPCEnvironment
app = create_app(
MethanolAPCEnvironment,
MethanolAPCAction,
MethanolAPCObservation,
env_name="methanol_apc",
max_concurrent_envs=1,
)
def main(host: str = "0.0.0.0", port: int = 8000) -> None:
"""Entry point for ``uv run server`` or ``python -m methanol_apc_env.server.app``."""
import uvicorn
uvicorn.run(app, host=host, port=port)
if __name__ == "__main__":
main()
|