Skip to content

Commit

Permalink
Fix CI (#886)
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudo-rnd-thoughts authored Feb 22, 2023
1 parent 29ee2d6 commit b4fc9ad
Show file tree
Hide file tree
Showing 32 changed files with 11 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-tutorials-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.7', '3.8', '3.9', '3.10'] # '3.11' - broken due to numba
tutorial: ['CleanRL', 'Tianshou', 'EnvironmentCreation']
steps:
- uses: actions/checkout@v3
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
repos:
- repo: https://github.com/python/black
rev: 22.8.0
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
rev: v2.2.1
rev: v2.2.2
hooks:
- id: codespell
args:
- --skip=*.css,*.js,*.map,*.scss,*svg
- --ignore-words-list=magent
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
rev: 6.0.0
hooks:
- id: flake8
args:
Expand All @@ -23,23 +23,23 @@ repos:
- --show-source
- --statistics
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/asottile/pyupgrade
rev: v2.38.0
rev: v3.3.1
hooks:
- id: pyupgrade
# TODO: remove `--keep-runtime-typing` option
args: ["--py37-plus", "--keep-runtime-typing"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1
rev: 6.3.0
hooks:
- id: pydocstyle
args:
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# DSP is far more benign (and should probably be the default in SDL anyways)

if sys.platform.startswith("linux"):

os.environ["SDL_AUDIODRIVER"] = "dsp"

os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide"
Expand Down
2 changes: 1 addition & 1 deletion pettingzoo/atari/space_invaders/space_invaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def raw_env(
zigzaging_bombs=False,
fast_bomb=False,
invisible_invaders=False,
**kwargs
**kwargs,
):
mode = 33 + (
moving_shields * 1
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/butterfly/cooperative_pong/manual_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

class ManualPolicy:
def __init__(self, env, agent_id: int = 0, show_obs: bool = False):

self.env = env
self.agent_id = agent_id
self.agent = self.env.agents[self.agent_id]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ def env(**kwargs):


class raw_env(AECEnv, EzPickle):

metadata = {
"render_modes": ["human", "rgb_array"],
"name": "knights_archers_zombies_v10",
Expand Down Expand Up @@ -700,7 +699,6 @@ def step(self, action):

# Do these things once per cycle
if self._agent_selector.is_last():

# Update the weapons
self.update_weapons()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

class ManualPolicy:
def __init__(self, env, agent_id: int = 0, show_obs: bool = False):

self.env = env
self.agent_id = agent_id
self.agent = self.env.agents[self.agent_id]
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/butterfly/pistonball/manual_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class ManualPolicy:
def __init__(self, env, agent_id: int = 0, show_obs: bool = False):

self.env = env
self.agent_id = agent_id
self.agent = self.env.agents[self.agent_id]
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/butterfly/pistonball/pistonball.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def env(**kwargs):


class raw_env(AECEnv, EzPickle):

metadata = {
"render_modes": ["human", "rgb_array"],
"name": "pistonball_v6",
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/classic/chess/chess.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def env(render_mode=None):


class raw_env(AECEnv):

metadata = {
"render_modes": ["human", "ansi", "rgb_array"],
"name": "chess_v5",
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/classic/go/go.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def env(**kwargs):


class raw_env(AECEnv):

metadata = {
"render_modes": ["human", "rgb_array"],
"name": "go_v5",
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/classic/hanabi/hanabi.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ def _raise_error_if_config_values_out_of_range(
observation_type,
random_start_player,
):

if not (2 <= colors <= 5):
raise ValueError(
f"Config parameter {colors} is out of bounds. See description in hanabi.py."
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/classic/rlcard_envs/gin_rummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def env(**kwargs):


class raw_env(RLCardBase, EzPickle):

metadata = {
"render_modes": ["human"],
"name": "gin_rummy_v4",
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/classic/rlcard_envs/leduc_holdem.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def env(**kwargs):


class raw_env(RLCardBase):

metadata = {
"render_modes": ["human"],
"name": "leduc_holdem_v4",
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/classic/rlcard_envs/texas_holdem.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def env(**kwargs):


class raw_env(RLCardBase):

metadata = {
"render_modes": ["human", "rgb_array"],
"name": "texas_holdem_v4",
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/classic/rlcard_envs/texas_holdem_no_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def env(**kwargs):


class raw_env(RLCardBase):

metadata = {
"render_modes": ["human", "rgb_array"],
"name": "texas_holdem_no_limit_v6",
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/classic/rps/rps.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ def step(self, action):

# collect reward if it is the last agent to act
if self._agent_selector.is_last():

# same action => 0 reward each agent
if self.state[self.agents[0]] == self.state[self.agents[1]]:
rewards = (0, 0)
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/sisl/multiwalker/multiwalker.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ def env(**kwargs):


class raw_env(AECEnv, EzPickle):

metadata = {
"render_modes": ["human", "rgb_array"],
"name": "multiwalker_v9",
Expand Down
2 changes: 0 additions & 2 deletions pettingzoo/sisl/multiwalker/multiwalker_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ def ReportFixture(self, fixture, point, normal, fraction):
self.lidar = [LidarCallback() for _ in range(10)]

def apply_action(self, action):

self.joints[0].motorSpeed = float(SPEED_HIP * np.sign(action[0]))
self.joints[0].maxMotorTorque = float(
MOTORS_TORQUE * np.clip(np.abs(action[0]), 0, 1)
Expand Down Expand Up @@ -288,7 +287,6 @@ def action_space(self):


class MultiWalkerEnv:

metadata = {"render_modes": ["human", "rgb_array"], "render_fps": FPS}

hardcore = False
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/sisl/pursuit/manual_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

class ManualPolicy:
def __init__(self, env, agent_id: int = 0, show_obs: bool = False):

self.env = env
self.agent_id = agent_id
self.agent = self.env.agents[self.agent_id]
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/sisl/pursuit/pursuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def env(**kwargs):


class raw_env(AECEnv, EzPickle):

metadata = {
"render_modes": ["human", "rgb_array"],
"name": "pursuit_v4",
Expand Down
4 changes: 2 additions & 2 deletions pettingzoo/sisl/pursuit/pursuit_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def draw_agent_counts(self):
x, y = self.pursuer_layer.get_position(i)
agent_positions[(x, y)] += 1

for (x, y) in evader_positions:
for x, y in evader_positions:
(pos_x, pos_y) = (
self.pixel_scale * x + self.pixel_scale // 2,
self.pixel_scale * y + self.pixel_scale // 2,
Expand All @@ -366,7 +366,7 @@ def draw_agent_counts(self):

self.screen.blit(text, (pos_x, pos_y))

for (x, y) in agent_positions:
for x, y in agent_positions:
(pos_x, pos_y) = (
self.pixel_scale * x + self.pixel_scale // 2,
self.pixel_scale * y + self.pixel_scale // 2,
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/sisl/pursuit/utils/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def act(self, state: np.ndarray) -> int:


class RandomPolicy(PursuitPolicy):

# constructor
def __init__(self, n_actions, rng):
self.rng = rng
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/sisl/pursuit/utils/discrete_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


class DiscreteAgent(Agent):

# constructor
def __init__(
self,
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/sisl/waterworld/waterworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ def env(**kwargs):


class raw_env(AECEnv):

metadata = {
"render_modes": ["human", "rgb_array"],
"name": "waterworld_v4",
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/test/example_envs/generated_agents_env_v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def get_type(agent):


class raw_env(AECEnv):

metadata = {"render_modes": ["human"], "name": "generated_agents_env_v0"}

def __init__(self, max_cycles=100, render_mode=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def get_type(agent):


class parallel_env(ParallelEnv):

metadata = {"render_modes": ["human"], "name": "generated_agents_parallel_v0"}

def __init__(self, max_cycles=100, render_mode=None):
Expand Down
1 change: 0 additions & 1 deletion pettingzoo/test/state_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def test_state(env, num_cycles):


def test_parallel_env(parallel_env):

parallel_env.reset()

assert isinstance(
Expand Down
1 change: 0 additions & 1 deletion test/unwrapped_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def discrete_observation(env, agents):

@pytest.mark.parametrize(("name", "env_module"), list(all_environments.items()))
def test_unwrapped(name, env_module):

env = env_module.env(render_mode="human")
base_env = env.unwrapped

Expand Down
4 changes: 0 additions & 4 deletions tutorials/CleanRL/cleanrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def unbatchify(x, env):


if __name__ == "__main__":

"""ALGO PARAMS"""
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
ent_coef = 0.1
Expand Down Expand Up @@ -126,18 +125,15 @@ def unbatchify(x, env):
""" TRAINING LOGIC """
# train for n number of episodes
for episode in range(total_episodes):

# collect an episode
with torch.no_grad():

# collect observations and convert to batch of torch tensors
next_obs = env.reset(seed=None)
# reset the episodic return
total_episodic_return = 0

# each episode has num_steps
for step in range(0, max_cycles):

# rollover the observation
obs = batchify_obs(next_obs, device)

Expand Down
1 change: 0 additions & 1 deletion tutorials/Ray/rllib_pistonball.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def env_creator(args):


if __name__ == "__main__":

env_name = "pistonball_v6"

register_env(env_name, lambda config: ParallelPettingZooEnv(env_creator(config)))
Expand Down
1 change: 0 additions & 1 deletion tutorials/Tianshou/2_training_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def _get_env():


if __name__ == "__main__":

# ======== Step 1: Environment setup =========
train_envs = DummyVectorEnv([_get_env for _ in range(10)])
test_envs = DummyVectorEnv([_get_env for _ in range(10)])
Expand Down

0 comments on commit b4fc9ad

Please sign in to comment.