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

Poetry 1.2 #271

Merged
merged 18 commits into from
Oct 3, 2022
46 changes: 23 additions & 23 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.8]
poetry-version: [1.1.11]
poetry-version: [1.2]
os: [ubuntu-18.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -31,19 +31,19 @@ jobs:

# classic control tests
- name: Install core dependencies
run: poetry install -E pytest
run: poetry install --with pytest
- name: Downgrade setuptools
run: poetry run pip install setuptools==59.5.0
- name: Run core tests
run: poetry run pytest tests/test_classic_control.py
- name: Install jax
if: runner.os == 'Linux' || runner.os == 'macOS'
run: poetry install -E jax
run: poetry install --with jax
- name: Run core tests with jax
if: runner.os == 'Linux' || runner.os == 'macOS'
run: poetry run pytest tests/test_classic_control_jax.py
- name: Install tuner dependencies
run: poetry install -E optuna
run: poetry install --with optuna
- name: Run tuner tests
run: poetry run pytest tests/test_tuner.py

Expand All @@ -52,7 +52,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.8]
poetry-version: [1.1.11]
poetry-version: [1.2]
os: [ubuntu-18.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -67,14 +67,14 @@ jobs:

# atari tests
- name: Install atari dependencies
run: poetry install -E "pytest atari"
run: poetry install --with pytest,atari
- name: Downgrade setuptools
run: poetry run pip install setuptools==59.5.0
- name: Run atari tests
run: poetry run pytest tests/test_atari.py
- name: Install jax
if: runner.os == 'Linux' || runner.os == 'macOS'
run: poetry install -E jax
run: poetry install --with jax
- name: Run core tests with jax
if: runner.os == 'Linux' || runner.os == 'macOS'
run: poetry run pytest tests/test_atari_jax.py
Expand All @@ -84,7 +84,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.8]
poetry-version: [1.1.11]
poetry-version: [1.2]
os: [ubuntu-18.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -99,9 +99,9 @@ jobs:

# pybullet tests
- name: Install core dependencies
run: poetry install -E pytest
run: poetry install --with pytest
- name: Install pybullet dependencies
run: poetry install -E pybullet
run: poetry install --with pybullet
- name: Downgrade setuptools
run: poetry run pip install setuptools==59.5.0
- name: Run pybullet tests
Expand All @@ -112,7 +112,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.8]
poetry-version: [1.1.11]
poetry-version: [1.2]
os: [ubuntu-18.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -127,7 +127,7 @@ jobs:

# procgen tests
- name: Install core dependencies
run: poetry install -E "pytest procgen"
run: poetry install --with pytest,procgen
- name: Downgrade setuptools
run: poetry run pip install setuptools==59.5.0
- name: Run pybullet tests
Expand All @@ -139,7 +139,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.8]
poetry-version: [1.1.11]
poetry-version: [1.2]
os: [ubuntu-18.04]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -154,13 +154,13 @@ jobs:

# mujoco tests
- name: Install core dependencies
run: poetry install -E pytest
run: poetry install --with pytest
- name: Install pybullet dependencies
run: poetry install -E pybullet
run: poetry install --with pybullet
- name: Install mujoco dependencies
run: poetry install -E mujoco
run: poetry install --with mujoco
- name: Install jax dependencies
run: poetry install -E jax
run: poetry install --with jax
- name: Downgrade setuptools
run: poetry run pip install setuptools==59.5.0
- name: install mujoco dependencies
Expand All @@ -178,7 +178,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.8]
poetry-version: [1.1.11]
poetry-version: [1.2]
os: [ubuntu-18.04]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -193,7 +193,7 @@ jobs:

# envpool tests
- name: Install envpool dependencies
run: poetry install -E "pytest envpool"
run: poetry install --with pytest,envpool
- name: Downgrade setuptools
run: poetry run pip install setuptools==59.5.0
- name: Run envpool tests
Expand All @@ -204,7 +204,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.8]
poetry-version: [1.1.11]
poetry-version: [1.2]
os: [ubuntu-18.04]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -219,7 +219,7 @@ jobs:

# atari multigpu tests
- name: Install atari dependencies
run: poetry install -E "pytest atari"
run: poetry install --with pytest,atari
- name: Downgrade setuptools
run: poetry run pip install setuptools==59.5.0
- name: Run atari tests
Expand All @@ -230,7 +230,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.8]
poetry-version: [1.1.11]
poetry-version: [1.2]
os: [ubuntu-18.04, macos-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -245,7 +245,7 @@ jobs:

# pettingzoo tests
- name: Install pettingzoo dependencies
run: poetry install -E "pytest pettingzoo atari"
run: poetry install --with pytest,pettingzoo,atari
- name: Downgrade setuptools
run: poetry run pip install setuptools==59.5.0
- name: Install ROMs
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/utils_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.8]
poetry-version: [1.1.11]
poetry-version: [1.2]
os: [ubuntu-18.04]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -25,9 +25,9 @@ jobs:
poetry-version: ${{ matrix.poetry-version }}

- name: Install test dependencies
run: poetry install -E pytest
run: poetry install --with pytest
- name: Install cloud dependencies
run: poetry install -E cloud
run: poetry install --with cloud
- name: Downgrade setuptools
run: poetry run pip install setuptools==59.5.0
- name: Run utils tests
Expand Down
29 changes: 20 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,45 @@ repos:
- --ignore-words-list=nd,reacher,thist,ths,magent
- --skip=docs/css/termynal.css,docs/js/termynal.js
- repo: https://github.com/python-poetry/poetry
rev: 1.2.0b1
rev: 1.2.1
hooks:
- id: poetry-export
name: poetry-export requirements.txt
args: ["-f", "requirements.txt", "--without-hashes", "-o", "requirements/requirements.txt"]
args: ["--without-hashes", "-o", "requirements/requirements.txt"]
stages: [manual]
- id: poetry-export
name: poetry-export requirements-atari.txt
args: ["-f", "requirements.txt", "--without-hashes", "-o", "requirements/requirements-atari.txt", "-E", "atari"]
args: ["--without-hashes", "-o", "requirements/requirements-atari.txt", "--with", "atari"]
stages: [manual]
- id: poetry-export
name: poetry-export requirements-pybullet.txt
args: ["-f", "requirements.txt", "--without-hashes", "-o", "requirements/requirements-pybullet.txt", "-E", "pybullet"]
args: ["--without-hashes", "-o", "requirements/requirements-pybullet.txt", "--with", "pybullet"]
stages: [manual]
- id: poetry-export
name: poetry-export requirements-mujoco.txt
args: ["-f", "requirements.txt", "--without-hashes", "-o", "requirements/requirements-mujoco.txt", "-E", "mujoco"]
args: ["--without-hashes", "-o", "requirements/requirements-mujoco.txt", "--with", "mujoco"]
stages: [manual]
- id: poetry-export
name: poetry-export requirements-procgen.txt
args: ["-f", "requirements.txt", "--without-hashes", "-o", "requirements/requirements-procgen.txt", "-E", "procgen"]
args: ["--without-hashes", "-o", "requirements/requirements-procgen.txt", "--with", "procgen"]
stages: [manual]
- id: poetry-export
name: poetry-export requirements-envpool.txt
args: ["-f", "requirements.txt", "--without-hashes", "-o", "requirements/requirements-envpool.txt", "-E", "envpool"]
args: ["--without-hashes", "-o", "requirements/requirements-envpool.txt", "--with", "envpool"]
stages: [manual]
- id: poetry-export
name: poetry-export requirements-pettingzoo.txt
args: ["-f", "requirements.txt", "--without-hashes", "-o", "requirements/requirements-pettingzoo.txt", "-E", "pettingzoo"]
args: ["--without-hashes", "-o", "requirements/requirements-pettingzoo.txt", "--with", "pettingzoo"]
stages: [manual]
- id: poetry-export
name: poetry-export requirements-jax.txt
args: ["--without-hashes", "-o", "requirements/requirements-jax.txt", "--with", "jax"]
stages: [manual]
- id: poetry-export
name: poetry-export requirements-docs.txt
args: ["--without-hashes", "-o", "requirements/requirements-docs.txt", "--with", "docs"]
stages: [manual]
- id: poetry-export
name: poetry-export requirements-cloud.txt
args: ["--without-hashes", "-o", "requirements/requirements-cloud.txt", "--with", "cloud"]
stages: [manual]

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Good luck and have fun!

```bash
poetry install
poetry install -E atari
poetry install -E pybullet
poetry install --with atari
poetry install --with pybullet
```

Then you can run the scripts under the poetry environment in two ways: `poetry run` or `poetry shell`.
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ RUN pip install poetry
COPY pyproject.toml pyproject.toml
COPY poetry.lock poetry.lock
RUN poetry install
RUN poetry install -E atari
RUN poetry install -E pybullet
RUN poetry install --with atari
RUN poetry install --with pybullet

# install mujoco
RUN apt-get -y install wget unzip software-properties-common \
libgl1-mesa-dev \
libgl1-mesa-glx \
libglew-dev \
libosmesa6-dev patchelf
RUN poetry install -E mujoco
RUN poetry install --with mujoco
RUN poetry run python -c "import mujoco_py"

COPY entrypoint.sh /usr/local/bin/
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ Good luck have fun :rocket:
## Get started

Prerequisites:
* >=3.7.1,<3.10 (not yet 3.10)
* [Poetry](https://python-poetry.org)
* Python >=3.7.1,<3.10 (not yet 3.10)
* [Poetry 1.2.1+](https://python-poetry.org)

To run experiments locally, give the following a try:

Expand Down Expand Up @@ -75,26 +75,26 @@ python cleanrl/ppo.py --env-id CartPole-v1
python cleanrl/c51.py --env-id CartPole-v1

# atari
poetry install -E atari
poetry install --with atari
python cleanrl/dqn_atari.py --env-id BreakoutNoFrameskip-v4
python cleanrl/c51_atari.py --env-id BreakoutNoFrameskip-v4
python cleanrl/ppo_atari.py --env-id BreakoutNoFrameskip-v4

# NEW: 3-4x side-effects free speed up with envpool's atari (only available to linux)
poetry install -E envpool
poetry install --with envpool
python cleanrl/ppo_atari_envpool.py --env-id BreakoutNoFrameskip-v4
# Learn Pong-v5 in ~5-10 mins
# Side effects such as lower sample efficiency might occur
poetry run python ppo_atari_envpool.py --clip-coef=0.2 --num-envs=16 --num-minibatches=8 --num-steps=128 --update-epochs=3

# pybullet
poetry install -E pybullet
poetry install --with pybullet
python cleanrl/td3_continuous_action.py --env-id MinitaurBulletDuckEnv-v0
python cleanrl/ddpg_continuous_action.py --env-id MinitaurBulletDuckEnv-v0
python cleanrl/sac_continuous_action.py --env-id MinitaurBulletDuckEnv-v0

# procgen
poetry install -E procgen
poetry install --with procgen
python cleanrl/ppo_procgen.py --env-id starpilot
python cleanrl/ppg_procgen.py --env-id starpilot

Expand Down
2 changes: 1 addition & 1 deletion benchmark/c51.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ OMP_NUM_THREADS=1 xvfb-run -a poetry run python -m cleanrl_utils.benchmark \
--num-seeds 3 \
--workers 9

poetry install -E atari
poetry install --with atari
OMP_NUM_THREADS=1 xvfb-run -a poetry run python -m cleanrl_utils.benchmark \
--env-ids PongNoFrameskip-v4 BeamRiderNoFrameskip-v4 BreakoutNoFrameskip-v4 \
--command "poetry run python cleanrl/c51_atari.py --track --capture-video" \
Expand Down
4 changes: 2 additions & 2 deletions benchmark/ddpg.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
poetry install -E "mujoco pybullet"
poetry install --with mujoco,pybullet
python -c "import mujoco_py"
OMP_NUM_THREADS=1 xvfb-run -a python -m cleanrl_utils.benchmark \
--env-ids HalfCheetah-v2 Walker2d-v2 Hopper-v2 InvertedPendulum-v2 Humanoid-v2 Pusher-v2 \
--command "poetry run python cleanrl/ddpg_continuous_action.py --track --capture-video" \
--num-seeds 3 \
--workers 3

poetry install -E "mujoco jax"
poetry install --with mujoco,jax
poetry run pip install --upgrade "jax[cuda]==0.3.14" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
poetry run python -c "import mujoco_py"
OMP_NUM_THREADS=1 xvfb-run -a poetry run python -m cleanrl_utils.benchmark \
Expand Down
6 changes: 3 additions & 3 deletions benchmark/dqn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ OMP_NUM_THREADS=1 xvfb-run -a poetry run python -m cleanrl_utils.benchmark \
--num-seeds 3 \
--workers 9

poetry install -E atari
poetry install --with atari
OMP_NUM_THREADS=1 xvfb-run -a poetry run python -m cleanrl_utils.benchmark \
--env-ids PongNoFrameskip-v4 BeamRiderNoFrameskip-v4 BreakoutNoFrameskip-v4 \
--command "poetry run python cleanrl/dqn_atari.py --track --capture-video" \
--num-seeds 3 \
--workers 1

poetry install -E "jax"
poetry install --with jax
poetry run pip install --upgrade "jax[cuda]==0.3.14" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
xvfb-run -a python -m cleanrl_utils.benchmark \
--env-ids CartPole-v1 Acrobot-v1 MountainCar-v0 \
--command "poetry run python cleanrl/dqn_jax.py --track --capture-video" \
--num-seeds 3 \
--workers 1

poetry install -E "atari jax"
poetry install --with atari,jax
poetry run pip install --upgrade "jax[cuda]==0.3.14" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
xvfb-run -a python -m cleanrl_utils.benchmark \
--env-ids PongNoFrameskip-v4 BeamRiderNoFrameskip-v4 BreakoutNoFrameskip-v4 \
Expand Down
2 changes: 1 addition & 1 deletion benchmark/ppg.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# export WANDB_ENTITY=openrlbenchmark

poetry install -E procgen
poetry install --with procgen
xvfb-run -a poetry run python -m cleanrl_utils.benchmark \
--env-ids starpilot bossfight bigfish \
--command "poetry run python cleanrl/ppg_procgen.py --track --capture-video" \
Expand Down
Loading