Skip to content

Commit

Permalink
Procgen Integration (#197)
Browse files Browse the repository at this point in the history
Procgen library change in https://github.com/Trinkle23897/procgen
- Fix Qt library include error
- Fix globalGameRegistry == nullptr issue by adding another explicit make_* function (thanks to Yukun!)
- Disable auto-reset because envpool has already handled this feature

Changes:
- Add new dependency `qtdeclarative5-dev`, rebuild docker image
- Update pypi wheel from manylinux_2_17_x86_64 to manylinux_2_24_x86_64 because of libstdc++.so.6 symbol
- Add 42 procgen envs
- Refactor `base_path`

Co-authored-by: Jiayi Weng <[email protected]>
Co-authored-by: Leo Guo <[email protected]>
  • Loading branch information
3 people authored Jan 3, 2023
1 parent 60459ad commit d44c541
Show file tree
Hide file tree
Showing 34 changed files with 818 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
release:
runs-on: ubuntu-latest
container: trinkle23897/envpool-release:2022-12-29-03c3d95
container: trinkle23897/envpool-release:2023-01-02-5f1a5fd
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
Expand All @@ -27,7 +27,7 @@ jobs:
- name: Build
run: |
make pypi-wheel
pip3 install wheelhouse/*.whl --force-reinstall
pip3 install dist/*.whl --force-reinstall
- name: Test
run: |
make release-test
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ docker-release-launch: docker-release
docker run --network=host -v /:/host --shm-size=4gb -it $(PROJECT_NAME)-release:$(DOCKER_TAG) bash

pypi-wheel: auditwheel-install bazel-release
ls dist/*.whl -Art | tail -n 1 | xargs auditwheel repair --plat manylinux_2_17_x86_64
ls dist/*.whl -Art | tail -n 1 | xargs auditwheel repair --plat manylinux_2_24_x86_64

release-test1:
cd envpool && python3 make_test.py
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- [x] [ViZDoom single player](https://envpool.readthedocs.io/en/latest/env/vizdoom.html)
- [x] [DeepMind Control Suite](https://envpool.readthedocs.io/en/latest/env/dm_control.html)
- [x] [Box2D](https://envpool.readthedocs.io/en/latest/env/box2d.html)
- [ ] Procgen
- [x] [Procgen](https://envpool.readthedocs.io/en/latest/env/procgen.html)
- [ ] Minigrid

Here are EnvPool's several highlights:
Expand Down
14 changes: 14 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ load("//envpool:workspace1.bzl", workspace1 = "workspace")

workspace1()

# QT special, cannot move to workspace2.bzl, not sure why

load("@local_config_qt//:local_qt.bzl", "local_qt_path")

new_local_repository(
name = "qt",
build_file = "@com_justbuchanan_rules_qt//:qt.BUILD",
path = local_qt_path(),
)

load("@com_justbuchanan_rules_qt//tools:qt_toolchain.bzl", "register_qt_toolchains")

register_qt_toolchains()

load("//envpool:pip.bzl", pip_workspace = "workspace")

pip_workspace()
2 changes: 1 addition & 1 deletion docker/dev-cn.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG HOME=/root
ARG PATH=$PATH:$HOME/go/bin

RUN apt-get update \
&& apt-get install -y python3-pip python3-dev golang-1.18 clang-format-11 git wget swig tmux clang-tidy vim \
&& apt-get install -y python3-pip python3-dev golang-1.18 clang-format-11 git wget swig tmux clang-tidy vim qtdeclarative5-dev \
&& rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN ln -sf /usr/lib/go-1.18/bin/go /usr/bin/go
Expand Down
2 changes: 1 addition & 1 deletion docker/dev.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG HOME=/root
ARG PATH=$PATH:$HOME/go/bin

RUN apt-get update \
&& apt-get install -y python3-pip python3-dev golang-1.18 clang-format-11 git wget swig tmux clang-tidy vim \
&& apt-get install -y python3-pip python3-dev golang-1.18 clang-format-11 git wget swig tmux clang-tidy vim qtdeclarative5-dev \
&& rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN ln -sf /usr/lib/go-1.18/bin/go /usr/bin/go
Expand Down
3 changes: 2 additions & 1 deletion docker/release.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ RUN apt-get update && apt-get install -y software-properties-common && add-apt-r
RUN apt-get update \
&& apt-get install -y git curl wget gcc-9 g++-9 build-essential swig make \
zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libncursesw5-dev libffi-dev liblzma-dev \
llvm xz-utils tk-dev libxml2-dev libxmlsec1-dev
llvm xz-utils tk-dev libxml2-dev libxmlsec1-dev qtdeclarative5-dev \
&& rm -rf /var/lib/apt/lists/*
# use self-compiled openssl instead of system provided (1.0.2)
RUN apt-get remove -y libssl-dev

Expand Down
97 changes: 97 additions & 0 deletions docs/env/procgen.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
Procgen
=======

We use ``procgen==0.10.7`` as the codebase.
See https://github.com/openai/procgen/tree/0.10.7


Options
-------

* ``task_id (str)``: see available tasks below;
* ``num_envs (int)``: how many environments you would like to create;
* ``batch_size (int)``: the expected batch size for return result, default to
``num_envs``;
* ``num_threads (int)``: the maximum thread number for executing the actual
``env.step``, default to ``batch_size``;
* ``seed (int)``: the environment seed, default to ``42``;
* ``max_episode_steps (int)``: the maximum number of steps for one episode,
each procgen game has different timeout value;
* ``env_name (str)``: one of 16 procgen env name;
* ``num_levels (int)``: default to ``0``;
* ``start_level (int)``: default to ``0``;
* ``use_sequential_levels (bool)``: default to ``False``;
* ``center_agent (bool)``: default to ``True``;
* ``use_backgrounds (bool)``: default to ``True``;
* ``use_monochrome_assets (bool)``: default to ``False``;
* ``restrict_themes (bool)``: default to ``False``;
* ``use_generated_assets (bool)``: default to ``False``;
* ``paint_vel_info (bool)``: default to ``False``;
* ``use_easy_jump (bool)``: default to ``False``;
* ``distribution_mode (int)``: one of ``(0, 1, 2, 10)``; ``0`` stands for easy
mode, ``1`` stands for hard mode, ``2`` stands for extreme mode, ``10``
stands for memory mode. The default value is determined by ``task_id``.

Note: arguments after ``env_name`` are provided by procgen environment itself.
We keep the default value as-is. We haven't tested the setting of
``use_sequential_levels == True``, and have no promise it is aligned with the
original version of procgen (PRs for fixing this issue are highly welcome).


Observation Space
-----------------

The observation image size is ``(64, 64, 3)``.


Action Space
------------

15 action buttons in total, ranging from 0 to 14.


Available Tasks
---------------

* ``BigfishEasy-v0``
* ``BigfishHard-v0``
* ``BossfightEasy-v0``
* ``BossfightHard-v0``
* ``CaveflyerEasy-v0``
* ``CaveflyerHard-v0``
* ``CaveflyerMemory-v0``
* ``ChaserEasy-v0``
* ``ChaserHard-v0``
* ``ChaserExtreme-v0``
* ``ClimberEasy-v0``
* ``ClimberHard-v0``
* ``CoinrunEasy-v0``
* ``CoinrunHard-v0``
* ``DodgeballEasy-v0``
* ``DodgeballHard-v0``
* ``DodgeballExtreme-v0``
* ``DodgeballMemory-v0``
* ``FruitbotEasy-v0``
* ``FruitbotHard-v0``
* ``HeistEasy-v0``
* ``HeistHard-v0``
* ``HeistMemory-v0``
* ``JumperEasy-v0``
* ``JumperHard-v0``
* ``JumperMemory-v0``
* ``LeaperEasy-v0``
* ``LeaperHard-v0``
* ``LeaperExtreme-v0``
* ``MazeEasy-v0``
* ``MazeHard-v0``
* ``MazeMemory-v0``
* ``MinerEasy-v0``
* ``MinerHard-v0``
* ``MinerMemory-v0``
* ``NinjaEasy-v0``
* ``NinjaHard-v0``
* ``PlunderEasy-v0``
* ``PlunderHard-v0``
* ``StarpilotEasy-v0``
* ``StarpilotHard-v0``
* ``StarpilotExtreme-v0``
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ stable version through `envpool.readthedocs.io/en/stable/
env/classic_control
env/dm_control
env/mujoco_gym
env/procgen
env/toy_text
env/vizdoom

Expand Down
1 change: 1 addition & 0 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ api
jit
mins
lidar
procgen
2 changes: 2 additions & 0 deletions envpool/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ py_library(
"//envpool/classic_control:classic_control_registration",
"//envpool/mujoco:mujoco_dmc_registration",
"//envpool/mujoco:mujoco_gym_registration",
"//envpool/procgen:procgen_registration",
"//envpool/toy_text:toy_text_registration",
"//envpool/vizdoom:vizdoom_registration",
],
Expand All @@ -51,6 +52,7 @@ py_library(
"//envpool/classic_control",
"//envpool/mujoco:mujoco_dmc",
"//envpool/mujoco:mujoco_gym",
"//envpool/procgen",
"//envpool/python",
"//envpool/toy_text",
"//envpool/vizdoom",
Expand Down
2 changes: 1 addition & 1 deletion envpool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
register,
)

__version__ = "0.7.1"
__version__ = "0.8.0"
__all__ = [
"register",
"make",
Expand Down
5 changes: 1 addition & 4 deletions envpool/atari/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

import os

from envpool.registration import register

base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
from envpool.registration import base_path, register

atari_rom_path = os.path.join(base_path, "atari", "roms")
atari_game_list = sorted(
Expand All @@ -34,6 +32,5 @@
gym_cls="AtariGymEnvPool",
gymnasium_cls="AtariGymnasiumEnvPool",
task=game,
base_path=base_path,
max_episode_steps=108000,
)
1 change: 1 addition & 0 deletions envpool/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
import envpool.classic_control.registration # noqa: F401
import envpool.mujoco.dmc.registration # noqa: F401
import envpool.mujoco.gym.registration # noqa: F401
import envpool.procgen.registration # noqa: F401
import envpool.toy_text.registration # noqa: F401
import envpool.vizdoom.registration # noqa: F401
48 changes: 48 additions & 0 deletions envpool/make_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,54 @@ def test_make_mujoco_dmc(self) -> None:
]
)

def test_make_procgen(self) -> None:
self.check_step(
[
"BigfishEasy-v0",
"BigfishHard-v0",
"BossfightEasy-v0",
"BossfightHard-v0",
"CaveflyerEasy-v0",
"CaveflyerHard-v0",
"CaveflyerMemory-v0",
"ChaserEasy-v0",
"ChaserHard-v0",
"ChaserExtreme-v0",
"ClimberEasy-v0",
"ClimberHard-v0",
"CoinrunEasy-v0",
"CoinrunHard-v0",
"DodgeballEasy-v0",
"DodgeballHard-v0",
"DodgeballExtreme-v0",
"DodgeballMemory-v0",
"FruitbotEasy-v0",
"FruitbotHard-v0",
"HeistEasy-v0",
"HeistHard-v0",
"HeistMemory-v0",
"JumperEasy-v0",
"JumperHard-v0",
"JumperMemory-v0",
"LeaperEasy-v0",
"LeaperHard-v0",
"LeaperExtreme-v0",
"MazeEasy-v0",
"MazeHard-v0",
"MazeMemory-v0",
"MinerEasy-v0",
"MinerHard-v0",
"MinerMemory-v0",
"NinjaEasy-v0",
"NinjaHard-v0",
"PlunderEasy-v0",
"PlunderHard-v0",
"StarpilotEasy-v0",
"StarpilotHard-v0",
"StarpilotExtreme-v0",
]
)


if __name__ == "__main__":
absltest.main()
7 changes: 0 additions & 7 deletions envpool/mujoco/dmc/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@
# limitations under the License.
"""Mujoco dm_control suite env registration."""

import os

from envpool.registration import register

base_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), "..", "..")
)

# from suite.BENCHMARKING
dmc_mujoco_envs = [
("acrobot", "swingup", 1000),
Expand Down Expand Up @@ -72,7 +66,6 @@
dm_cls=f"Dmc{domain_name}DMEnvPool",
gym_cls=f"Dmc{domain_name}GymEnvPool",
gymnasium_cls=f"Dmc{domain_name}GymnasiumEnvPool",
base_path=base_path,
task_name=task,
max_episode_steps=max_episode_steps,
)
7 changes: 0 additions & 7 deletions envpool/mujoco/gym/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@
# limitations under the License.
"""Mujoco gym env registration."""

import os

from envpool.registration import register

base_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), "..", "..")
)

gym_mujoco_envs = [
("Ant", "v3", False, 1000),
("Ant", "v4", True, 1000),
Expand Down Expand Up @@ -57,7 +51,6 @@
dm_cls=f"Gym{task}DMEnvPool",
gym_cls=f"Gym{task}GymEnvPool",
gymnasium_cls=f"Gym{task}GymnasiumEnvPool",
base_path=base_path,
post_constraint=post_constraint,
max_episode_steps=max_episode_steps,
**extra_args,
Expand Down
Loading

0 comments on commit d44c541

Please sign in to comment.