Skip to content

Commit 7cb6153

Browse files
authored
Merge pull request #140 from meta-pytorch/add-browsergym-env-ben
[ENHANCEMENT] Fix browsergym environment
2 parents c34b3c3 + e9c7862 commit 7cb6153

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/envs/browsergym_env/server/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2222
libcairo2 \
2323
libasound2 \
2424
libxshmfence1 \
25+
fonts-unifont \
26+
fonts-noto-color-emoji \
2527
# Additional dependencies
2628
git \
2729
wget \
@@ -33,8 +35,7 @@ RUN pip install --no-cache-dir -r /tmp/browsergym_requirements.txt && \
3335
rm /tmp/browsergym_requirements.txt
3436

3537
# Install Playwright browsers (Chromium by default)
36-
RUN playwright install chromium && \
37-
playwright install-deps chromium
38+
RUN playwright install chromium
3839

3940
# Copy OpenEnv core and browsergym_env code
4041
WORKDIR /app

src/envs/browsergym_env/server/browsergym_environment.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- WorkArena: Enterprise task automation
99
"""
1010

11+
import importlib
1112
from typing import Any, Dict, Optional
1213
from uuid import uuid4
1314

@@ -66,6 +67,25 @@ def __init__(
6667
else:
6768
self.env_id = f"browsergym/{benchmark}"
6869

70+
# force import the benchmark module
71+
benchmark_modules = {
72+
"miniwob": "browsergym.envs.miniwob",
73+
"webarena": "browsergym.envs.webarena",
74+
"visualwebarena": "browsergym.envs.visualwebarena",
75+
"workarena": "browsergym.envs.workarena",
76+
}
77+
module_path = benchmark_modules.get(benchmark)
78+
try:
79+
if module_path:
80+
importlib.import_module(module_path)
81+
else:
82+
importlib.import_module("browsergym")
83+
except ModuleNotFoundError as import_error:
84+
raise ValueError(
85+
f"Failed to import BrowserGym benchmark '{benchmark}': {import_error}\n"
86+
f"Make sure the package browsergym-{benchmark} is installed."
87+
) from import_error
88+
6989
# Create the BrowserGym environment
7090
try:
7191
self.gym_env = gym.make(

0 commit comments

Comments
 (0)