Skip to content

Commit

Permalink
Fix ci (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudo-rnd-thoughts authored Jan 7, 2025
1 parent 3135095 commit a5182a4
Show file tree
Hide file tree
Showing 25 changed files with 43 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-docs-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.11'

- name: Install dependencies for doc
run: pip install -r docs/requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-docs-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.11'

- name: Get tag
id: tag
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.7'
python-version: '3.12'
- name: Install dependencies
run: python -m pip install --upgrade setuptools wheel build
- name: Build wheels
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manual-build-docs-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.11'

- name: Install dependencies for doc
run: pip install -r docs/requirements.txt
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-symlinks
- id: destroyed-symlinks
Expand All @@ -20,17 +20,17 @@ repos:
- id: mixed-line-ending
args: [ "--fix=lf" ]
- repo: https://github.com/python/black
rev: 23.3.0
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
rev: v2.3.0
hooks:
- id: codespell
args:
- --ignore-words-list=reacher
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.1.1
hooks:
- id: flake8
args:
Expand All @@ -40,12 +40,12 @@ repos:
- --show-source
- --statistics
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.2
rev: v3.19.1
hooks:
- id: pyupgrade
args: ["--py38-plus"]
Expand Down
2 changes: 2 additions & 0 deletions bin/dm_lab.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN pip install --upgrade pip

RUN python --version

# Install Shimmy requirements
RUN apt-get -y update \
&& apt-get install --no-install-recommends -y \
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Setups up the Shimmy module."""

from setuptools import find_packages, setup


Expand Down Expand Up @@ -33,8 +34,8 @@ def get_version():
header_count, long_description = get_description()

extras = {
"gym-v21": ["gym>=0.21.0,<0.26", "pyglet==1.5.11"],
"gym-v26": ["gym>=0.26.2"],
"gym-v21": ["gym>=0.21.0,<0.26", "pyglet==1.5.11", "numpy<2.0"],
"gym-v26": ["gym>=0.26.2", "numpy<2.0"],
# "imageio" should be "gymnasium[mujoco]>=0.26" but there are install conflicts
"dm-control": ["dm-control>=1.0.10", "imageio", "h5py>=3.7.0"],
"dm-control-multi-agent": [
Expand Down Expand Up @@ -72,7 +73,7 @@ def get_version():
keywords=["Reinforcement Learning", "game", "RL", "AI"],
python_requires=">=3.8",
packages=find_packages(),
install_requires=["numpy>=1.18.0", "gymnasium>=1.0.0a1"],
install_requires=["numpy>=1.18.0", "gymnasium>=1.0.0"],
tests_require=extras["testing"],
extras_require=extras,
classifiers=[
Expand Down
1 change: 1 addition & 0 deletions shimmy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""API for converting popular non-gymnasium environments to a gymnasium compatible environment."""

from __future__ import annotations

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions shimmy/bsuite_compatibility.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Wrapper to convert a BSuite environment into a gymnasium compatible environment."""

from __future__ import annotations

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions shimmy/dm_control_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
https://github.com/ikostrikov/dmcgym/blob/main/dmcgym/env.py
and modified to modern gymnasium API
"""

from __future__ import annotations

import math
Expand Down
9 changes: 3 additions & 6 deletions shimmy/dm_control_multiagent_compatibility.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Wrapper to convert a dm_env multiagent environment into a pettingzoo compatible environment."""

from __future__ import annotations

import functools
Expand All @@ -19,9 +20,7 @@
from dm_control.locomotion import soccer as dm_soccer


def _unravel_ma_timestep(
timestep: dm_env.TimeStep, agents: list[AgentID]
) -> tuple[
def _unravel_ma_timestep(timestep: dm_env.TimeStep, agents: list[AgentID]) -> tuple[
dict[AgentID, Any],
dict[AgentID, float],
dict[AgentID, bool],
Expand Down Expand Up @@ -247,9 +246,7 @@ def reset(

return observations, info

def step(
self, actions: ActionDict
) -> tuple[
def step(self, actions: ActionDict) -> tuple[
ObsDict,
dict[AgentID, float],
dict[AgentID, bool],
Expand Down
1 change: 1 addition & 0 deletions shimmy/dm_lab_compatibility.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Wrapper to convert a DM Lab environment into a gymnasium compatible environment."""

# pyright: reportOptionalMemberAccess=false
from __future__ import annotations

Expand Down
1 change: 1 addition & 0 deletions shimmy/meltingpot_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
https://github.com/deepmind/meltingpot/blob/main/examples/pettingzoo/utils.py
and modified to modern PettingZoo API
"""

# pyright: reportOptionalSubscript=false
from __future__ import annotations

Expand Down
1 change: 1 addition & 0 deletions shimmy/openai_gym_compatibility.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Compatibility wrappers for OpenAI gym V21 and V26."""

# pyright: reportGeneralTypeIssues=false, reportPrivateImportUsage=false
from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion shimmy/openspiel_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def _choose_next_agent(self):
return
else:
# ignore agents where there are no valid actions
# this will raise assertations with PZ api
# this will raise assertions with PZ api
self.simultaneous_actions[agent] = None
return

Expand Down
13 changes: 7 additions & 6 deletions shimmy/utils/dm_control_multiagent.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for DM Control Multi-Agent."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down Expand Up @@ -35,13 +36,13 @@ def load_dm_control_soccer(
env = dm_soccer.load(
team_size=team_size if team_size is not None else 2,
time_limit=time_limit if time_limit is not None else 10.0,
disable_walker_contacts=disable_walker_contacts
if disable_walker_contacts is not None
else False,
disable_walker_contacts=(
disable_walker_contacts if disable_walker_contacts is not None else False
),
enable_field_box=enable_field_box if enable_field_box is not None else True,
terminate_on_goal=terminate_on_goal if terminate_on_goal is not None else False,
walker_type=walker_type
if walker_type is not None
else dm_soccer.WalkerType.BOXHEAD,
walker_type=(
walker_type if walker_type is not None else dm_soccer.WalkerType.BOXHEAD
),
)
return env
1 change: 1 addition & 0 deletions shimmy/utils/dm_env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for the compatibility wrappers."""

from __future__ import annotations

import copy
Expand Down
1 change: 1 addition & 0 deletions shimmy/utils/dm_lab.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for the compatibility wrappers."""

from __future__ import annotations

from collections import OrderedDict
Expand Down
1 change: 1 addition & 0 deletions shimmy/utils/meltingpot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for Melting Pot."""

# pyright: reportGeneralTypeIssues=false
# flake8: noqa F821
import dm_env
Expand Down
1 change: 1 addition & 0 deletions tests/test_bsuite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests the functionality of the BSuiteCompatibilityV0 on bsuite envs."""

import pickle
import warnings

Expand Down
23 changes: 2 additions & 21 deletions tests/test_dm_control.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests the functionality of the DmControlCompatibility Wrapper on dm_control envs."""

import pickle
import warnings
from typing import Callable
Expand Down Expand Up @@ -37,37 +38,17 @@ def test_dm_control_suite_envs():
assert dm_control.suite.ALL_TASKS == DM_CONTROL_SUITE_ENVS


# todo - gymnasium v27 should remove the need for some of these warnings
CHECK_ENV_IGNORE_WARNINGS = [
f"\x1b[33mWARN: {message}\x1b[0m"
for message in [
"A Box observation space minimum value is -infinity. This is probably too low.",
"A Box observation space maximum value is infinity. This is probably too high.",
"For Box action spaces, we recommend using a symmetric and normalized space (range=[-1, 1] or [0, 1]). See https://stable-baselines3.readthedocs.io/en/master/guide/rl_tips.html for more information.",
"A Box observation space has an unconventional shape (neither an image, nor a 1D vector). We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. Actual observation shape: ()",
"A Box observation space has an unconventional shape (neither an image, nor a 1D vector). We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. Actual observation shape: (8, 2)",
"A Box observation space has an unconventional shape (neither an image, nor a 1D vector). We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. Actual observation shape: (2, 4)",
"A Box observation space has an unconventional shape (neither an image, nor a 1D vector). We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. Actual observation shape: (4, 4)",
"A Box observation space has an unconventional shape (neither an image, nor a 1D vector). We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. Actual observation shape: (1, 3)",
"A Box observation space has an unconventional shape (neither an image, nor a 1D vector). We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. Actual observation shape: (1, 84, 84, 3)",
"A Box observation space has an unconventional shape (neither an image, nor a 1D vector). We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. Actual observation shape: (1, 2)",
"A Box observation space has an unconventional shape (neither an image, nor a 1D vector). We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. Actual observation shape: (1, 6)",
"A Box observation space has an unconventional shape (neither an image, nor a 1D vector). We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. Actual observation shape: (1, 4)",
"A Box observation space has an unconventional shape (neither an image, nor a 1D vector). We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. Actual observation shape: (1, 9)",
"A Box observation space has an unconventional shape (neither an image, nor a 1D vector). We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. Actual observation shape: (1, 5)",
"It seems a Box observation space is an image but the `dtype` is not `np.uint8`, actual type: float64. If the Box observation space is not an image, we recommend flattening the observation to have only a 1D vector.",
"It seems a Box observation space is an image but the upper and lower bounds are not in [0, 255]. Generally, CNN policies assume observations are within that range, so you may encounter an issue if the observation values are not.",
"arrays to stack must be passed as a 'sequence' type such as list or tuple. Support for non-sequence iterables such as generators is deprecated as of NumPy 1.16 and will raise an error in the future.",
"Calling `env.close()` on the closed environment should be allowed, but it raised an exception: _data",
"Calling `env.close()` on the closed environment should be allowed, but it raised an exception: 'Physics' object has no attribute '_data'",
]
]
CHECK_ENV_IGNORE_WARNINGS.append(
'arrays to stack must be passed as a "sequence" type such as list or tuple. Support for non-sequence iterables such as generators is deprecated as of NumPy 1.16 and will raise an error in the future.',
)
CHECK_ENV_IGNORE_WARNINGS.append(
"Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)"
)
CHECK_ENV_IGNORE_WARNINGS.append("`in1d` is deprecated. Use `np.isin` instead.")


@pytest.mark.parametrize("env_id", DM_CONTROL_ENV_IDS)
Expand Down
1 change: 1 addition & 0 deletions tests/test_dm_control_multi_agent.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests the multi-agent dm-control soccer environment."""

import pickle

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/test_dm_lab.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests the multi-agent dm-control soccer environment."""

# pyright: reportUndefinedVariable=false
# flake8: noqa F821
import pickle
Expand Down
1 change: 1 addition & 0 deletions tests/test_meltingpot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests the functionality of the MeltingPotCompatibility wrapper on meltingpot substrates."""

# pyright: reportUndefinedVariable=false
# flake8: noqa F821 E402
# isort: skip_file
Expand Down
1 change: 1 addition & 0 deletions tests/test_openspiel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests the functionality of the OpenSpielCompatibility wrapper on OpenSpiel envs."""

# pyright: reportGeneralTypeIssues=false
import pickle

Expand Down

0 comments on commit a5182a4

Please sign in to comment.