Spaces:
Sleeping
Sleeping
Commit ·
c47ce11
1
Parent(s): 538acd4
Re-enable Gradio web UI at / for friendly browser-facing Space page
Browse filesSwitches server/app.py from create_fastapi_app to create_app, which serves
the OpenEnv Gradio UI at / when ENABLE_WEB_INTERFACE=true (already set in
the Dockerfile). All the standard HTTP API routes (/reset, /step, /state,
etc.) still work the same way — only the root URL changes from 404 to the
project page.
- server/app.py +17 -9
server/app.py
CHANGED
|
@@ -1,25 +1,31 @@
|
|
| 1 |
"""FastAPI application for DispatchPulse.
|
| 2 |
|
| 3 |
-
Uses ``
|
| 4 |
-
openenv-core's HTTP server
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
"""
|
| 7 |
|
| 8 |
from __future__ import annotations
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
# Support both in-repo and standalone imports.
|
| 11 |
try:
|
| 12 |
-
from openenv.core.env_server.http_server import
|
| 13 |
|
| 14 |
from .environment import DispatchPulseEnvironment
|
| 15 |
except ImportError: # pragma: no cover
|
| 16 |
-
from openenv.core.env_server.http_server import
|
| 17 |
from server.environment import DispatchPulseEnvironment
|
| 18 |
|
| 19 |
# Import the typed Action / Observation classes from the project root models.py
|
| 20 |
-
import os
|
| 21 |
-
import sys
|
| 22 |
-
|
| 23 |
_PKG_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
| 24 |
if _PKG_ROOT not in sys.path:
|
| 25 |
sys.path.insert(0, _PKG_ROOT)
|
|
@@ -27,10 +33,12 @@ if _PKG_ROOT not in sys.path:
|
|
| 27 |
from models import DispatchPulseAction, DispatchPulseObservation # noqa: E402
|
| 28 |
|
| 29 |
# Pass the class (factory) so each session gets its own env instance.
|
| 30 |
-
|
|
|
|
| 31 |
DispatchPulseEnvironment,
|
| 32 |
DispatchPulseAction,
|
| 33 |
DispatchPulseObservation,
|
|
|
|
| 34 |
max_concurrent_envs=8,
|
| 35 |
)
|
| 36 |
|
|
|
|
| 1 |
"""FastAPI application for DispatchPulse.
|
| 2 |
|
| 3 |
+
Uses ``create_app(env_factory, ActionCls, ObservationCls)`` from
|
| 4 |
+
openenv-core's HTTP server. This wrapper:
|
| 5 |
+
|
| 6 |
+
- When ``ENABLE_WEB_INTERFACE=true`` (set in the Dockerfile): serves the
|
| 7 |
+
OpenEnv Gradio web UI at ``/`` so judges visiting the Space in a browser
|
| 8 |
+
see a friendly project page.
|
| 9 |
+
- Always registers the standard ``/reset``, ``/step``, ``/state``,
|
| 10 |
+
``/health``, ``/metadata``, ``/schema``, and ``/ws`` routes — these are
|
| 11 |
+
what the hackathon grader actually hits.
|
| 12 |
"""
|
| 13 |
|
| 14 |
from __future__ import annotations
|
| 15 |
|
| 16 |
+
import os
|
| 17 |
+
import sys
|
| 18 |
+
|
| 19 |
# Support both in-repo and standalone imports.
|
| 20 |
try:
|
| 21 |
+
from openenv.core.env_server.http_server import create_app
|
| 22 |
|
| 23 |
from .environment import DispatchPulseEnvironment
|
| 24 |
except ImportError: # pragma: no cover
|
| 25 |
+
from openenv.core.env_server.http_server import create_app
|
| 26 |
from server.environment import DispatchPulseEnvironment
|
| 27 |
|
| 28 |
# Import the typed Action / Observation classes from the project root models.py
|
|
|
|
|
|
|
|
|
|
| 29 |
_PKG_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
| 30 |
if _PKG_ROOT not in sys.path:
|
| 31 |
sys.path.insert(0, _PKG_ROOT)
|
|
|
|
| 33 |
from models import DispatchPulseAction, DispatchPulseObservation # noqa: E402
|
| 34 |
|
| 35 |
# Pass the class (factory) so each session gets its own env instance.
|
| 36 |
+
# ``env_name`` controls the web UI title and README lookup.
|
| 37 |
+
app = create_app(
|
| 38 |
DispatchPulseEnvironment,
|
| 39 |
DispatchPulseAction,
|
| 40 |
DispatchPulseObservation,
|
| 41 |
+
env_name="dispatchpulse",
|
| 42 |
max_concurrent_envs=8,
|
| 43 |
)
|
| 44 |
|