Upload folder using huggingface_hub
Browse files- Dockerfile +1 -1
- server/app.py +12 -0
Dockerfile
CHANGED
|
@@ -70,6 +70,7 @@ ENV PATH="/app/.venv/bin:$PATH"
|
|
| 70 |
|
| 71 |
# Set PYTHONPATH so imports work correctly
|
| 72 |
ENV PYTHONPATH="/app/env:$PYTHONPATH"
|
|
|
|
| 73 |
|
| 74 |
# Health check
|
| 75 |
# Use Python stdlib instead of curl so the probe works even if curl is absent.
|
|
@@ -78,5 +79,4 @@ HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=5 \
|
|
| 78 |
|
| 79 |
# Run the FastAPI server
|
| 80 |
# Respect PORT if the platform injects one; default to 8000.
|
| 81 |
-
ENV ENABLE_WEB_INTERFACE=true
|
| 82 |
CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port ${PORT:-8000}"]
|
|
|
|
| 70 |
|
| 71 |
# Set PYTHONPATH so imports work correctly
|
| 72 |
ENV PYTHONPATH="/app/env:$PYTHONPATH"
|
| 73 |
+
ENV ENABLE_WEB_INTERFACE="true"
|
| 74 |
|
| 75 |
# Health check
|
| 76 |
# Use Python stdlib instead of curl so the probe works even if curl is absent.
|
|
|
|
| 79 |
|
| 80 |
# Run the FastAPI server
|
| 81 |
# Respect PORT if the platform injects one; default to 8000.
|
|
|
|
| 82 |
CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port ${PORT:-8000}"]
|
server/app.py
CHANGED
|
@@ -38,6 +38,12 @@ except Exception as e: # pragma: no cover
|
|
| 38 |
# Import from local models.py (PYTHONPATH includes /app/env in Docker)
|
| 39 |
from models import BasicOpenenvAction, BasicOpenenvObservation
|
| 40 |
from .basic_openenv_environment import BasicOpenenvEnvironment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
# Create the app with web interface and README integration
|
|
@@ -50,6 +56,12 @@ app = create_app(
|
|
| 50 |
)
|
| 51 |
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
def main():
|
| 54 |
"""
|
| 55 |
Entry point for direct execution via uv run or python -m.
|
|
|
|
| 38 |
# Import from local models.py (PYTHONPATH includes /app/env in Docker)
|
| 39 |
from models import BasicOpenenvAction, BasicOpenenvObservation
|
| 40 |
from .basic_openenv_environment import BasicOpenenvEnvironment
|
| 41 |
+
from fastapi.responses import RedirectResponse
|
| 42 |
+
import os
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
# Required for OpenEnv to mount the HF-style web UI at /web.
|
| 46 |
+
os.environ.setdefault("ENABLE_WEB_INTERFACE", "true")
|
| 47 |
|
| 48 |
|
| 49 |
# Create the app with web interface and README integration
|
|
|
|
| 56 |
)
|
| 57 |
|
| 58 |
|
| 59 |
+
@app.get("/", include_in_schema=False)
|
| 60 |
+
def root_redirect():
|
| 61 |
+
"""Match HF Space UX: open app at /web UI."""
|
| 62 |
+
return RedirectResponse(url="/web")
|
| 63 |
+
|
| 64 |
+
|
| 65 |
def main():
|
| 66 |
"""
|
| 67 |
Entry point for direct execution via uv run or python -m.
|