Skip to content

Commit

Permalink
Fix: add __init__ to runners
Browse files Browse the repository at this point in the history
  • Loading branch information
laszukdawid committed Aug 24, 2021
1 parent 325db05 commit 7360346
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ai_traineree/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy
import torch

__version__ = "0.3.4"
__version__ = "0.3.5"


# This is expected to be safe, although in PyTorch 1.7 it comes as a warning,
Expand Down
Empty file.
10 changes: 8 additions & 2 deletions ai_traineree/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

try:
import gym
BaseEnv = gym.Env # To satisfy parser on MultiAgentUnityTask import
except ImportError:
logging.warning("Coulnd't import `gym`. Please install `pip install -e .[gym]` if you intend to use it.")

Expand All @@ -19,7 +20,7 @@
from gym_unity.envs import ActionFlattener
from mlagents_envs.base_env import BaseEnv, DecisionSteps, TerminalSteps
except (ImportError, ModuleNotFoundError):
BaseEnv = gym.Env
logging.warning("Couldn't import `gym_unity` and/or `mlagents`. MultiAgentUnityTask won't work.")


GymStepResult = Tuple[np.ndarray, float, bool, Dict]
Expand Down Expand Up @@ -235,7 +236,12 @@ def dones(self):
def last(self, agent_name: Optional[str] = None) -> Tuple[Any, float, bool, Any]:
if agent_name is None:
return self.env.last()
return (self.env.observe(agent_name), self.env.rewards[agent_name], self.env.dones[agent_name], self.env.infos[agent_name])
return (
self.env.observe(agent_name),
self.env.rewards[agent_name],
self.env.dones[agent_name],
self.env.infos[agent_name],
)

def reset(self):
self.env.reset()
Expand Down
1 change: 0 additions & 1 deletion examples/petting_zoo/rps.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@
break

task.step(action)

2 changes: 1 addition & 1 deletion examples/snek_rainbow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sneks # noqa

from ai_traineree.agents.rainbow import RainbowAgent
from ai_traineree.env_runner import EnvRunner
from ai_traineree.runners.env_runner import EnvRunner
from ai_traineree.loggers import TensorboardLogger
from ai_traineree.tasks import GymTask

Expand Down
2 changes: 1 addition & 1 deletion examples/space_invaders_dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections import deque

from ai_traineree.agents.dqn import DQNAgent
from ai_traineree.env_runner import EnvRunner
from ai_traineree.runners.env_runner import EnvRunner
from ai_traineree.loggers import TensorboardLogger
from ai_traineree.networks.heads import NetChainer
from ai_traineree.networks.bodies import ConvNet, FlattenNet, FcNet, ScaleNet
Expand Down
2 changes: 1 addition & 1 deletion examples/space_invaders_pixel_rainbow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ai_traineree.loggers import TensorboardLogger
from ai_traineree.networks.bodies import ConvNet, FcNet
from ai_traineree.networks.heads import NetChainer
from ai_traineree.env_runner import EnvRunner
from ai_traineree.runners.env_runner import EnvRunner
from ai_traineree.tasks import GymTask


Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = ai-traineree
version = 0.3.4
version = 0.3.5
author = Dawid Laszuk
author_email = ai-traineree@dawid.lasz.uk
description = Yet another zoo of (Deep) Reinforcment Learning methods in Python using PyTorch
Expand Down Expand Up @@ -77,6 +77,7 @@ exclude_lines =
ignore = E203,
E226, # I like to group operations. What are you going to do about it, huh?
E252, # Ain't nobody tell me how to type arguments
W293, # Lines within code with whitespace
W503
max_line_length = 120

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 7360346

Please sign in to comment.