File size: 1,372 Bytes
048f186
 
 
5c6ca01
95a7814
048f186
 
 
 
 
 
 
95a7814
 
 
 
 
 
 
5c6ca01
 
048f186
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5c6ca01
 
5c3c008
 
 
 
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
33
34
35
36
37
38
39
40
41
42
43
44
import os
from pathlib import Path

from openenv.core.env_server import create_fastapi_app

try:
    from dotenv import load_dotenv as _load_dotenv
except ImportError:
    def _load_dotenv(_path: str) -> bool:  # type: ignore[misc]
        return False


try:
    from .ShopManagerEng_environment import JewelryShopEnvironment
    from ..models import JewelryAction, JewelryObservation
except ImportError:
    from server.ShopManagerEng_environment import JewelryShopEnvironment
    from models import JewelryAction, JewelryObservation

import uvicorn

# Load .env from this package (ShopManagerEng/.env) for FRED/keys when running the server
_env = Path(__file__).resolve().parent.parent / ".env"
if _env.is_file():
    _load_dotenv(_env)

# RL trainers (TRL GRPO, etc.) open one WebSocket per parallel rollout. With
# num_generations=8 + per_device_train_batch_size>=8 you can easily need 8-16
# concurrent envs. Default max is 1, so we bump it. Override via env var
# SHOPMANAGER_MAX_CONCURRENT_ENVS for hosted Spaces with tighter budgets.
_MAX_CONCURRENT_ENVS = int(os.environ.get("SHOPMANAGER_MAX_CONCURRENT_ENVS", "16"))

app = create_fastapi_app(
    JewelryShopEnvironment,
    JewelryAction,
    JewelryObservation,
    max_concurrent_envs=_MAX_CONCURRENT_ENVS,
)

def main():
    uvicorn.run(app, host="0.0.0.0", port=8000)

if __name__ == "__main__":
    main()