Spaces:
Sleeping
Sleeping
File size: 1,115 Bytes
7f61e7c | 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 | """
Smart Factory Scheduling β OpenEnv Server
==========================================
Routes (HTTP + WebSocket):
GET / β Gradio UI (set ENABLE_WEB_INTERFACE=1) or redirect to /web
GET /health β {"status": "healthy"}
POST /reset β reset episode, returns observation
POST /step β execute action, returns observation + reward + done
GET /state β current environment state
GET /schema β action / observation JSON schemas
WS /ws β persistent WebSocket session (used by FactoryEnvClient)
Set ENABLE_WEB_INTERFACE=1 to enable the built-in Gradio UI at /web.
"""
import os
from openenv.core import create_app
from factory_env.env import FactoryEnv
from factory_env.models import FactoryAction, FactoryObservation
TASK = os.getenv("FACTORY_TASK", "easy")
app = create_app(
env=lambda: FactoryEnv(task=TASK, seed=42),
action_cls=FactoryAction,
observation_cls=FactoryObservation,
env_name="factory_env",
)
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", 7860)))
|