From 33c34934742e330d9b51c781487368d7faf33624 Mon Sep 17 00:00:00 2001 From: Ice Pasupat Date: Thu, 22 Feb 2024 08:16:39 -0800 Subject: [PATCH 1/5] Tried updating to gym 1.0.0a1 --- pyproject.toml | 4 ++-- tests/test_api.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6d3a0614..0eeb8d51 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,11 +24,11 @@ classifiers = [ "Topic :: Scientific/Engineering :: Artificial Intelligence", ] dependencies = [ - "Gymnasium==0.29.0", + "Gymnasium==1.0.0a1", "Pillow>=9.0.0", "selenium>=4.5.0", "numpy>=1.18.0", - "farama-notifications >=0.0.1", + "farama-notifications>=0.0.1", ] dynamic = ["version"] diff --git a/tests/test_api.py b/tests/test_api.py index bc682265..37b0733c 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -3,7 +3,7 @@ import pytest from gymnasium import spaces from gymnasium.utils.env_checker import check_env -from gymnasium.wrappers.flatten_observation import FlattenObservation +from gymnasium.wrappers import FlattenObservation from tests.utils import get_all_registered_miniwob_envs From a51e22fb0a8b8d0e914a8741b7e45a2cf016c139 Mon Sep 17 00:00:00 2001 From: Ice Pasupat Date: Wed, 28 Feb 2024 10:35:53 -0800 Subject: [PATCH 2/5] Register environments in __init__.py --- README.md | 3 +++ miniwob/__init__.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index dc9eae25..84fbdbc8 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,11 @@ The following code performs a deterministic action on the ```python import time import gymnasium +import miniwob from miniwob.action import ActionTypes +gymnasium.register_envs(miniwob) + env = gymnasium.make('miniwob/click-test-2-v1', render_mode='human') # Wrap the code in try-finally to ensure proper cleanup. diff --git a/miniwob/__init__.py b/miniwob/__init__.py index 646e43fe..19e1e285 100644 --- a/miniwob/__init__.py +++ b/miniwob/__init__.py @@ -1,9 +1,13 @@ """Root `__init__` of the miniwob module.""" import sys +from miniwob.registration import register_miniwob_envs + __version__ = "1.0" +register_miniwob_envs() + try: from farama_notifications import notifications From d41edc47fce573e76bf3b804037835eff05f8b74 Mon Sep 17 00:00:00 2001 From: Ice Pasupat Date: Wed, 28 Feb 2024 10:47:04 -0800 Subject: [PATCH 3/5] Updated the doc to be compatible with gym1.0.0a1 --- docs/_scripts/gen_env_list.py | 2 ++ docs/_scripts/gen_mds.py | 2 ++ docs/content/basic_usage.md | 3 +++ docs/content/custom_environment.md | 1 + docs/index.md | 2 ++ 5 files changed, 10 insertions(+) diff --git a/docs/_scripts/gen_env_list.py b/docs/_scripts/gen_env_list.py index 06e604dc..234d31ed 100644 --- a/docs/_scripts/gen_env_list.py +++ b/docs/_scripts/gen_env_list.py @@ -4,9 +4,11 @@ import gymnasium as gym import pandas as pd +import miniwob from utils import extract_description_from_docstring, get_all_registered_miniwob_envs +gym.register_envs(miniwob) gym.logger.set_level(gym.logger.DISABLED) ENV_TYPES = [ diff --git a/docs/_scripts/gen_mds.py b/docs/_scripts/gen_mds.py index ad8227f5..a86d53da 100644 --- a/docs/_scripts/gen_mds.py +++ b/docs/_scripts/gen_mds.py @@ -4,11 +4,13 @@ import gymnasium as gym +import miniwob from utils import get_all_registered_miniwob_envs, trim_docstring LAYOUT = "env" +gym.register_envs(miniwob) gym.logger.set_level(gym.logger.DISABLED) diff --git a/docs/content/basic_usage.md b/docs/content/basic_usage.md index 7fe0d2ab..5d4e796e 100644 --- a/docs/content/basic_usage.md +++ b/docs/content/basic_usage.md @@ -8,8 +8,11 @@ The following code performs a deterministic action on the ```python import time import gymnasium +import miniwob from miniwob.action import ActionTypes +gymnasium.register_envs(miniwob) + env = gymnasium.make('miniwob/click-test-2-v1', render_mode='human') # Wrap the code in try-finally to ensure proper cleanup. diff --git a/docs/content/custom_environment.md b/docs/content/custom_environment.md index 6b2a777e..aa76ed05 100644 --- a/docs/content/custom_environment.md +++ b/docs/content/custom_environment.md @@ -125,6 +125,7 @@ from miniwob.fields import field_lookup # Import `custom_registry.py` above to register the task. import custom_registry +gymnasium.register_envs(custom_registry) # Create an environment. env = gymnasium.make('miniwob/custom-v0', render_mode='human') diff --git a/docs/index.md b/docs/index.md index af5c21d1..b85b967a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -29,6 +29,8 @@ Exploration](https://arxiv.org/abs/1802.08802). The Gymnasium interface allows an agent to initialize and interact with a MiniWoB++ environment as follows: ```python import gymnasium +import miniwob +gymnasium.register_envs(miniwob) env = gymnasium.make('miniwob/click-test-2-v1', render_mode='human') try: observation, info = env.reset(seed=42) From e83ab0f0201d1195fc8af2a7ce4ab42898729f18 Mon Sep 17 00:00:00 2001 From: Ice Pasupat Date: Wed, 28 Feb 2024 10:50:16 -0800 Subject: [PATCH 4/5] Bumped the version number --- miniwob/__init__.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/miniwob/__init__.py b/miniwob/__init__.py index 19e1e285..57f21a0f 100644 --- a/miniwob/__init__.py +++ b/miniwob/__init__.py @@ -4,7 +4,7 @@ from miniwob.registration import register_miniwob_envs -__version__ = "1.0" +__version__ = "1.0.1" register_miniwob_envs() diff --git a/pyproject.toml b/pyproject.toml index 0eeb8d51..cc691390 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ "Topic :: Scientific/Engineering :: Artificial Intelligence", ] dependencies = [ - "Gymnasium==1.0.0a1", + "Gymnasium>=1.0.0a1", "Pillow>=9.0.0", "selenium>=4.5.0", "numpy>=1.18.0", From c7496ab728c5a9d482775045ab9f19b0d383e6d6 Mon Sep 17 00:00:00 2001 From: Ice Pasupat Date: Wed, 28 Feb 2024 11:07:05 -0800 Subject: [PATCH 5/5] Force pre-commit to use Python 3 --- .github/workflows/pre-commit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 1943ae45..ff114595 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -16,6 +16,8 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 + with: + python-version: '3.10' - run: pip install pre-commit - run: pre-commit --version - run: pre-commit install