making pettingzoo a core dep instead of optional req (#837)

close #831
This commit is contained in:
Jiayi Weng 2023-03-25 22:01:09 -07:00 committed by GitHub
parent d5d521b329
commit 7f8fa241dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 11 additions and 22 deletions

View File

@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, windows-latest]
python-version: [3.7, 3.8]
python-version: [3.8, 3.9]
steps:
- name: Cancel previous run
uses: styfle/cancel-workflow-action@0.11.0

View File

@ -12,10 +12,10 @@ jobs:
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: "3.10"
- name: Upgrade pip
run: |
python -m pip install --upgrade pip setuptools wheel

View File

@ -8,7 +8,7 @@ jobs:
if: "!contains(github.event.head_commit.message, 'ci skip')"
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.8", "3.9", "3.10"]
steps:
- name: Cancel previous run
uses: styfle/cancel-workflow-action@0.11.0

View File

@ -23,6 +23,7 @@ def get_install_requires() -> str:
"numba>=0.51.0",
"h5py>=2.10.0", # to match tensorflow's minimal requirements
"packaging",
"pettingzoo>=1.22",
]
@ -47,7 +48,6 @@ def get_extras_require() -> str:
"doc8",
"scipy",
"pillow",
"pettingzoo>=1.22",
"pygame>=2.1.0", # pettingzoo test cases pistonball
"pymunk>=6.2.1", # pettingzoo test cases pistonball
"nni>=2.3,<3.0", # expect breaking changes at next major version

View File

@ -1,6 +1,6 @@
from tianshou import data, env, exploration, policy, trainer, utils
__version__ = "0.5.0"
__version__ = "0.5.1"
__all__ = [
"env",

View File

@ -5,6 +5,7 @@ from tianshou.env.gym_wrappers import (
MultiDiscreteToDiscrete,
TruncatedAsTerminated,
)
from tianshou.env.pettingzoo_env import PettingZooEnv
from tianshou.env.venv_wrappers import VectorEnvNormObs, VectorEnvWrapper
from tianshou.env.venvs import (
BaseVectorEnv,
@ -14,11 +15,6 @@ from tianshou.env.venvs import (
SubprocVectorEnv,
)
try:
from tianshou.env.pettingzoo_env import PettingZooEnv
except ImportError:
pass
__all__ = [
"BaseVectorEnv",
"DummyVectorEnv",

View File

@ -26,7 +26,7 @@ class ContinuousToDiscrete(gym.ActionWrapper):
dtype=object
)
def action(self, act: np.ndarray) -> np.ndarray: # type: ignore
def action(self, act: np.ndarray) -> np.ndarray:
# modify act
assert len(act.shape) <= 2, f"Unknown action format with shape {act.shape}."
if len(act.shape) == 1:
@ -50,7 +50,7 @@ class MultiDiscreteToDiscrete(gym.ActionWrapper):
self.bases[i] = self.bases[i - 1] * nvec[-i]
self.action_space = gym.spaces.Discrete(np.prod(nvec))
def action(self, act: np.ndarray) -> np.ndarray: # type: ignore
def action(self, act: np.ndarray) -> np.ndarray:
converted_act = []
for b in np.flip(self.bases):
converted_act.append(act // b)

View File

@ -4,10 +4,7 @@ import cloudpickle
import gymnasium
import numpy as np
try:
from tianshou.env.pettingzoo_env import PettingZooEnv
except ImportError:
PettingZooEnv = None # type: ignore
from tianshou.env.pettingzoo_env import PettingZooEnv
if TYPE_CHECKING:
import gym

View File

@ -5,6 +5,7 @@ import gymnasium as gym
import numpy as np
import packaging
from tianshou.env.pettingzoo_env import PettingZooEnv
from tianshou.env.utils import ENV_TYPE, gym_new_venv_step_type
from tianshou.env.worker import (
DummyEnvWorker,
@ -13,11 +14,6 @@ from tianshou.env.worker import (
SubprocEnvWorker,
)
try:
from tianshou.env.pettingzoo_env import PettingZooEnv
except ImportError:
PettingZooEnv = None # type: ignore
try:
import gym as old_gym