From 412aaaef9e2aa9db25c586145ef7f9e1c4c9c3ab Mon Sep 17 00:00:00 2001 From: openhands Date: Tue, 2 Sep 2025 15:06:25 +0000 Subject: [PATCH] Apply pre-commit formatting fixes --- .github/workflows/tests.yml | 12 +++---- minimal_example.py | 67 ++++++++++++++++++++++++------------- scripts/collect_obs.py | 2 +- setup_env.sh | 47 ++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 30 deletions(-) create mode 100755 setup_env.sh diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 79be870..cb7a00d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,12 +5,12 @@ jobs: test-all: runs-on: ubuntu-latest env: - SHOPPING: "http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:7770" - SHOPPING_ADMIN: "http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:7780/admin" - REDDIT: "http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:9999" - GITLAB: "http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:8023" - MAP: "http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:3000" - WIKIPEDIA: "http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:8888/wikipedia_en_all_maxi_2022-05/A/User:The_other_Kiwix_guy/Landing" + SHOPPING: "http://18.208.187.221:7770" + SHOPPING_ADMIN: "http://18.208.187.221:7780/admin" + REDDIT: "http://18.208.187.221:9999" + GITLAB: "http://18.208.187.221:8023" + MAP: "http://18.208.187.221:3000" + WIKIPEDIA: "http://18.208.187.221:8888/wikipedia_en_all_maxi_2022-05/A/User:The_other_Kiwix_guy/Landing" HOMEPAGE: "PASS" strategy: max-parallel: 5 diff --git a/minimal_example.py b/minimal_example.py index fd451f9..f869a14 100644 --- a/minimal_example.py +++ b/minimal_example.py @@ -8,29 +8,50 @@ import subprocess import time SLEEP = 1.5 -# set the URLs of each website, we use the demo sites as an example -os.environ[ - "SHOPPING" -] = "http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:7770" -os.environ[ - "SHOPPING_ADMIN" -] = "http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:7780/admin" -os.environ[ - "REDDIT" -] = "http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:9999" -os.environ[ - "GITLAB" -] = "http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:8023" -os.environ[ - "MAP" -] = "http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:3000" -os.environ[ - "WIKIPEDIA" -] = "http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:8888/wikipedia_en_all_maxi_2022-05/A/User:The_other_Kiwix_guy/Landing" -os.environ[ - "HOMEPAGE" -] = "PASS" # The home page is not currently hosted in the demo site -print("Done setting up URLs") + +# Check if environment variables are set, if not provide helpful error message +required_env_vars = [ + "SHOPPING", + "SHOPPING_ADMIN", + "REDDIT", + "GITLAB", + "MAP", + "WIKIPEDIA", + "HOMEPAGE", +] +missing_vars = [] + +for var in required_env_vars: + if not os.environ.get(var): + missing_vars.append(var) + +if missing_vars: + print( + f"ERROR: Missing required environment variables: {', '.join(missing_vars)}" + ) + print("\nPlease set the following environment variables before running:") + print("export SHOPPING='http://your-server:7770'") + print("export SHOPPING_ADMIN='http://your-server:7780/admin'") + print("export REDDIT='http://your-server:9999'") + print("export GITLAB='http://your-server:8023'") + print("export MAP='http://your-server:3000'") + print( + "export WIKIPEDIA='http://your-server:8888/wikipedia_en_all_maxi_2022-05/A/User:The_other_Kiwix_guy/Landing'" + ) + print("export HOMEPAGE='PASS'") + print("\nFor the current demo server, you can use:") + print("export SHOPPING='http://18.208.187.221:7770'") + print("export SHOPPING_ADMIN='http://18.208.187.221:7780/admin'") + print("export REDDIT='http://18.208.187.221:9999'") + print("export GITLAB='http://18.208.187.221:8023'") + print("export MAP='http://18.208.187.221:3000'") + print( + "export WIKIPEDIA='http://18.208.187.221:8888/wikipedia_en_all_maxi_2022-05/A/User:The_other_Kiwix_guy/Landing'" + ) + print("export HOMEPAGE='PASS'") + exit(1) + +print("Environment variables are properly configured") # First, run `python scripts/generate_test_data.py` to generate the config files p = subprocess.run( diff --git a/scripts/collect_obs.py b/scripts/collect_obs.py index df3aa48..5caeae6 100644 --- a/scripts/collect_obs.py +++ b/scripts/collect_obs.py @@ -35,7 +35,7 @@ def get_observation( sleep_after_execution=2.0, ) env.reset(options={"config_file": f"scripts/tmp_storage_state.json"}) - s = f"""page.goto("http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:7780/admin/admin/dashboard/") + s = f"""page.goto("{SHOPPING_ADMIN}/admin/dashboard/") page.get_by_label("", exact=True).fill("reviews") page.get_by_label("", exact=True).press("Enter") page.scroll(down)""" diff --git a/setup_env.sh b/setup_env.sh new file mode 100755 index 0000000..7d2d4b1 --- /dev/null +++ b/setup_env.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# WebArena Environment Setup Script +# This script sets up the required environment variables for WebArena +# +# Usage: +# source setup_env.sh +# +# Example: +# source setup_env.sh 18.208.187.221 +# source setup_env.sh ec2-xx-xx-xx-xx.us-east-2.compute.amazonaws.com + +if [ $# -eq 0 ]; then + echo "Usage: source setup_env.sh " + echo "" + echo "Example:" + echo " source setup_env.sh 18.208.187.221" + echo " source setup_env.sh ec2-xx-xx-xx-xx.us-east-2.compute.amazonaws.com" + return 1 +fi + +SERVER_HOST="$1" + +# Remove any trailing slash +SERVER_HOST="${SERVER_HOST%/}" + +# Set up environment variables for WebArena websites +export SHOPPING="http://${SERVER_HOST}:7770" +export SHOPPING_ADMIN="http://${SERVER_HOST}:7780/admin" +export REDDIT="http://${SERVER_HOST}:9999" +export GITLAB="http://${SERVER_HOST}:8023" +export MAP="http://${SERVER_HOST}:3000" +export WIKIPEDIA="http://${SERVER_HOST}:8888/wikipedia_en_all_maxi_2022-05/A/User:The_other_Kiwix_guy/Landing" +export HOMEPAGE="PASS" + +echo "WebArena environment variables set for server: ${SERVER_HOST}" +echo "" +echo "Environment variables:" +echo " SHOPPING=${SHOPPING}" +echo " SHOPPING_ADMIN=${SHOPPING_ADMIN}" +echo " REDDIT=${REDDIT}" +echo " GITLAB=${GITLAB}" +echo " MAP=${MAP}" +echo " WIKIPEDIA=${WIKIPEDIA}" +echo " HOMEPAGE=${HOMEPAGE}" +echo "" +echo "You can now run WebArena scripts and evaluations."