Skip to content

Commit e9c7862

Browse files
committed
force benchmark imports
1 parent 4cea8c3 commit e9c7862

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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)