File size: 1,409 Bytes
1ce31b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2968362
1ce31b0
 
 
2968362
1ce31b0
 
 
 
 
 
 
2968362
1ce31b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
48
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

import os

try:
    from openenv.core.env_server.http_server import create_app
except Exception as e:
    raise ImportError(
        "openenv is required for the web interface. Install dependencies with '\n    uv sync\n'"
    ) from e

try:
    from ..models import BridgeForgeAction, BridgeForgeObservation
    from .bridge_forge_environment import BridgeForgeEnvironment
    from .gradio_app import build_bridge_forge_ui
except (ImportError, ValueError):
    from models import BridgeForgeAction, BridgeForgeObservation
    from server.bridge_forge_environment import BridgeForgeEnvironment
    from server.gradio_app import build_bridge_forge_ui

app = create_app(
    BridgeForgeEnvironment,
    BridgeForgeAction,
    BridgeForgeObservation,
    env_name="bridge_forge",
    max_concurrent_envs=4,
    gradio_builder=build_bridge_forge_ui,
)

STATIC_DIR = "/tmp/bridge_forge_static"
os.makedirs(STATIC_DIR, exist_ok=True)

from starlette.staticfiles import StaticFiles
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")


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


if __name__ == "__main__":
    main()