Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- core/env_server/http_server.py +5 -5
- server/app.py +5 -5
core/env_server/http_server.py
CHANGED
|
@@ -15,7 +15,7 @@ from __future__ import annotations
|
|
| 15 |
|
| 16 |
import os
|
| 17 |
from dataclasses import asdict
|
| 18 |
-
from typing import Any, Dict, Type
|
| 19 |
|
| 20 |
from .interfaces import Environment
|
| 21 |
from .types import Action, Observation
|
|
@@ -167,16 +167,16 @@ def create_app(
|
|
| 167 |
) -> Any:
|
| 168 |
"""
|
| 169 |
Create a FastAPI application with or without web interface.
|
| 170 |
-
|
| 171 |
This function creates a FastAPI app with the web interface enabled by default,
|
| 172 |
including README integration for better user experience.
|
| 173 |
-
|
| 174 |
Args:
|
| 175 |
env: The Environment instance to serve
|
| 176 |
action_cls: The Action subclass this environment expects
|
| 177 |
observation_cls: The Observation subclass this environment returns
|
| 178 |
env_name: Optional environment name for README loading
|
| 179 |
-
|
| 180 |
Returns:
|
| 181 |
FastAPI application instance with or without web interface and README integration
|
| 182 |
"""
|
|
@@ -193,7 +193,7 @@ def create_app(
|
|
| 193 |
else:
|
| 194 |
# Use standard FastAPI app without web interface
|
| 195 |
return create_fastapi_app(env, action_cls, observation_cls)
|
| 196 |
-
|
| 197 |
|
| 198 |
def create_fastapi_app(
|
| 199 |
env: Environment,
|
|
|
|
| 15 |
|
| 16 |
import os
|
| 17 |
from dataclasses import asdict
|
| 18 |
+
from typing import Any, Dict, Optional, Type
|
| 19 |
|
| 20 |
from .interfaces import Environment
|
| 21 |
from .types import Action, Observation
|
|
|
|
| 167 |
) -> Any:
|
| 168 |
"""
|
| 169 |
Create a FastAPI application with or without web interface.
|
| 170 |
+
|
| 171 |
This function creates a FastAPI app with the web interface enabled by default,
|
| 172 |
including README integration for better user experience.
|
| 173 |
+
|
| 174 |
Args:
|
| 175 |
env: The Environment instance to serve
|
| 176 |
action_cls: The Action subclass this environment expects
|
| 177 |
observation_cls: The Observation subclass this environment returns
|
| 178 |
env_name: Optional environment name for README loading
|
| 179 |
+
|
| 180 |
Returns:
|
| 181 |
FastAPI application instance with or without web interface and README integration
|
| 182 |
"""
|
|
|
|
| 193 |
else:
|
| 194 |
# Use standard FastAPI app without web interface
|
| 195 |
return create_fastapi_app(env, action_cls, observation_cls)
|
| 196 |
+
|
| 197 |
|
| 198 |
def create_fastapi_app(
|
| 199 |
env: Environment,
|
server/app.py
CHANGED
|
@@ -7,7 +7,7 @@ via REST API endpoints.
|
|
| 7 |
|
| 8 |
import os
|
| 9 |
|
| 10 |
-
from core.env_server import
|
| 11 |
from envs.warehouse_env.models import WarehouseAction, WarehouseObservation
|
| 12 |
from envs.warehouse_env.server.warehouse_environment import WarehouseEnvironment
|
| 13 |
from fastapi import FastAPI
|
|
@@ -34,8 +34,8 @@ warehouse_env = WarehouseEnvironment(
|
|
| 34 |
)
|
| 35 |
|
| 36 |
|
| 37 |
-
# Create FastAPI app using OpenEnv's helper
|
| 38 |
-
app =
|
| 39 |
|
| 40 |
|
| 41 |
# Add custom render endpoint
|
|
@@ -74,8 +74,8 @@ def main():
|
|
| 74 |
"""Entry point for warehouse-server command."""
|
| 75 |
import uvicorn
|
| 76 |
import os
|
| 77 |
-
|
| 78 |
port = int(os.getenv("PORT", "8000"))
|
| 79 |
host = os.getenv("HOST", "0.0.0.0")
|
| 80 |
-
|
| 81 |
uvicorn.run(app, host=host, port=port)
|
|
|
|
| 7 |
|
| 8 |
import os
|
| 9 |
|
| 10 |
+
from core.env_server import create_app
|
| 11 |
from envs.warehouse_env.models import WarehouseAction, WarehouseObservation
|
| 12 |
from envs.warehouse_env.server.warehouse_environment import WarehouseEnvironment
|
| 13 |
from fastapi import FastAPI
|
|
|
|
| 34 |
)
|
| 35 |
|
| 36 |
|
| 37 |
+
# Create FastAPI app using OpenEnv's helper (with web interface if enabled)
|
| 38 |
+
app = create_app(warehouse_env, WarehouseAction, WarehouseObservation, env_name="warehouse_env")
|
| 39 |
|
| 40 |
|
| 41 |
# Add custom render endpoint
|
|
|
|
| 74 |
"""Entry point for warehouse-server command."""
|
| 75 |
import uvicorn
|
| 76 |
import os
|
| 77 |
+
|
| 78 |
port = int(os.getenv("PORT", "8000"))
|
| 79 |
host = os.getenv("HOST", "0.0.0.0")
|
| 80 |
+
|
| 81 |
uvicorn.run(app, host=host, port=port)
|