Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- IMPLEMENTATION.md +19 -0
- server/app.py +19 -2
IMPLEMENTATION.md
CHANGED
|
@@ -239,8 +239,27 @@ These are communication channels, not reward. Keeping them out of the training s
|
|
| 239 |
cd landscapeforge
|
| 240 |
uv sync # installs deps
|
| 241 |
uv run python tests/test_episode.py # 3 scripted episodes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
```
|
| 243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
Expected output: three `✓ PASSED` lines, final line `All tests passed.`
|
| 245 |
|
| 246 |
In-process usage (no server needed):
|
|
|
|
| 239 |
cd landscapeforge
|
| 240 |
uv sync # installs deps
|
| 241 |
uv run python tests/test_episode.py # 3 scripted episodes
|
| 242 |
+
|
| 243 |
+
# Local dev server with Gradio at /web:
|
| 244 |
+
uv run uvicorn landscapeforge.server.app:app --host 127.0.0.1 --port 8000
|
| 245 |
+
# → http://localhost:8000/web (Gradio demo)
|
| 246 |
+
# → http://localhost:8000/schema (OpenEnv schema)
|
| 247 |
```
|
| 248 |
|
| 249 |
+
### Pushing to HF Spaces
|
| 250 |
+
|
| 251 |
+
Use `--no-interface` — our custom Gradio mount at `/web` replaces OpenEnv's
|
| 252 |
+
built-in UI (the built-in passes `theme=` to `gr.mount_gradio_app`, which
|
| 253 |
+
Gradio 5.x dropped):
|
| 254 |
+
|
| 255 |
+
```bash
|
| 256 |
+
openenv push . --exclude .hfignore --no-interface
|
| 257 |
+
```
|
| 258 |
+
|
| 259 |
+
Without `--no-interface`, `openenv push` injects `ENV ENABLE_WEB_INTERFACE=true`
|
| 260 |
+
into the Dockerfile → OpenEnv's `create_app` routes through
|
| 261 |
+
`create_web_interface_app` → crashes on Gradio 5 incompatibility.
|
| 262 |
+
|
| 263 |
Expected output: three `✓ PASSED` lines, final line `All tests passed.`
|
| 264 |
|
| 265 |
In-process usage (no server needed):
|
server/app.py
CHANGED
|
@@ -56,11 +56,28 @@ app = create_app(
|
|
| 56 |
max_concurrent_envs=4,
|
| 57 |
)
|
| 58 |
|
| 59 |
-
# Mount Gradio demo at /web
|
|
|
|
|
|
|
|
|
|
| 60 |
try:
|
| 61 |
import gradio as gr
|
| 62 |
_demo = _build_demo_ui()
|
| 63 |
-
app = gr.mount_gradio_app(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
except Exception as _e: # pragma: no cover
|
| 65 |
import logging
|
| 66 |
logging.getLogger(__name__).warning(
|
|
|
|
| 56 |
max_concurrent_envs=4,
|
| 57 |
)
|
| 58 |
|
| 59 |
+
# Mount Gradio demo at /web.
|
| 60 |
+
# SSR mode is disabled because Gradio's Node sidecar tends to 502 under HF
|
| 61 |
+
# Spaces' Docker proxy; client-side rendering is more reliable. root_path is
|
| 62 |
+
# set so relative asset URLs resolve correctly when HF iframes /web.
|
| 63 |
try:
|
| 64 |
import gradio as gr
|
| 65 |
_demo = _build_demo_ui()
|
| 66 |
+
app = gr.mount_gradio_app(
|
| 67 |
+
app, _demo,
|
| 68 |
+
path="/web",
|
| 69 |
+
root_path="/web",
|
| 70 |
+
ssr_mode=False,
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
# Redirect root and /web (no trailing slash) to /web/ so the HF Space
|
| 74 |
+
# iframe works whether base_path is set or not.
|
| 75 |
+
from fastapi.responses import RedirectResponse
|
| 76 |
+
|
| 77 |
+
@app.get("/")
|
| 78 |
+
def _root_redirect():
|
| 79 |
+
return RedirectResponse(url="/web/")
|
| 80 |
+
|
| 81 |
except Exception as _e: # pragma: no cover
|
| 82 |
import logging
|
| 83 |
logging.getLogger(__name__).warning(
|