Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark.prepare_backends() fixes #209

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def full_reset(self):
# Send the GET request to trigger the reset script
logger.info(f"VisualWebArena full instance reset in progress.")

# 5 minutes timeout (takes 2-3 minutes in practice)
# 10 minutes timeout (takes about 4 minutes in practice)
# https://requests.readthedocs.io/en/stable/user/advanced/#timeouts
response = requests.get(reset_url, timeout=(3.05, 5 * 60))
response = requests.get(reset_url, timeout=(3.05, 10 * 60))

# Print the response from the server
logger.info(f"Reset status code: {response.status_code}")
Expand All @@ -76,24 +76,38 @@ def full_reset(self):
f"Full instance reset failed ({response.status_code}): {response.status_code}"
)

# warm-start the instance (navigate to every domain)
retries_left = 3
while retries_left:
retries_left -= 1
try:
self._check_is_reachable(timeout=60) # 60 seconds, cold starting might be slow
break
except Exception as e:
if not retries_left:
raise
logger.info(
f"Instance unresponsive after reset, retrying ({retries_left} retries left)\n{e}"
)

def check_status(self):
"""
Check the status of the instance. Raises an error if the instance is not ready to be used.

"""
self._check_is_reachable()
self._check_is_reachable(timeout=10) # 10 seconds

def _check_is_reachable(self):
def _check_is_reachable(self, timeout: int):
"""
Test that every website is reachable.

"""
for site, url in self.urls.items():
try:
requests.get(url, timeout=5000) # 5 secs
requests.get(url, timeout=timeout)
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):
raise RuntimeError(
f'VisualWebArena site "{site}" ({url}) is not reacheable. Please check the URL.'
f'WebArena site "{site}" ({url}) is not reacheable. Please check the URL.'
)

def ui_login(self, site: str, page: playwright.sync_api.Page):
Expand Down
4 changes: 2 additions & 2 deletions browsergym/webarena/src/browsergym/webarena/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def full_reset(self):
# Send the GET request to trigger the reset script
logger.info(f"WebArena full instance reset in progress.")

# 5 minutes timeout (takes 2-3 minutes in practice)
# 10 minutes timeout (takes about 4 minutes in practice)
# https://requests.readthedocs.io/en/stable/user/advanced/#timeouts
response = requests.get(reset_url, timeout=(3.05, 5 * 60))
response = requests.get(reset_url, timeout=(3.05, 10 * 60))

# Print the response from the server
logger.info(f"Reset status code: {response.status_code}")
Expand Down