Skip to content

Commit

Permalink
refactor multi_server.py and update tests for WebArenaInstanceVars in…
Browse files Browse the repository at this point in the history
…itialization
  • Loading branch information
recursix committed Dec 11, 2024
1 parent 7ae6b82 commit 8949d0c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/agentlab/experiments/multi_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ class BaseServer:
def init(self):
pass

def __str__(self):
return "BaseServer"


@dataclass
class WebArenaInstanceVars(BaseServer):
Expand Down Expand Up @@ -51,6 +48,8 @@ def init(self):
unimport_modules(self.module_name)
for key, value in self.make_env_vars().items():
os.environ[key] = value

# this is just a dynamic check to see that the env vars are set correctly
bgym_instance = WebArenaInstance()
base_url, _ = _split_url(bgym_instance.urls["reddit"])
assert base_url == self.base_url, f"Expected {self.base_url}, got {base_url}"
Expand Down
20 changes: 16 additions & 4 deletions tests/experiments/test_multi_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@


def test_webarena_multiserver():
instance = WebArenaInstanceVars.from_env_vars()
instance_1 = instance.clone()
instance_1.base_url = "http://webarena1.eastus.cloudapp.azure.com"

instance_1 = WebArenaInstanceVars(
base_url="http://webarena1.eastus.cloudapp.azure.com",
shopping="8082/",
shopping_admin="8083/admin",
reddit="8080",
gitlab="9001",
wikipedia="8081/wikipedia_en_all_maxi_2022-05/A/User:The_other_Kiwix_guy/Landing",
map="443",
homepage="80",
full_reset="7565",
module_name="webarena",
prefix="WA_",
)

instance_1.init()

bgym_instance = WebArenaInstance()
base_url_1 = bgym_instance.urls["reddit"].rsplit(":", 1)[0]
assert base_url_1 == instance_1.base_url

instance_2 = instance.clone()
instance_2 = instance_1.clone()
instance_2.base_url = "http://webarena2.eastus.cloudapp.azure.com"
instance_2.init()

Expand Down

0 comments on commit 8949d0c

Please sign in to comment.