PPOTrainer: missing 1 required positional argument: 'debug'

Hi all,

I am attempting to configure my own MultiAgentEnv, using ray[rllib]==1.6.0. I get the following error when I try to train with a PPOTrainer:

/opt/conda/lib/python3.7/site-packages/ray/_private/services.py:238: UserWarning: Not all Ray Dashboard dependencies were found. To use the dashboard please install Ray using `pip install ray[default]`. To disable this message, set RAY_DISABLE_IMPORT_WARNING env var to '1'.
  warnings.warn(warning_message)
Loading environment football failed: No module named 'gfootball'
2021-09-15 23:17:13,132	INFO trainer.py:714 -- Tip: set framework=tfe or the --eager flag to enable TensorFlow eager execution
2021-09-15 23:17:13,132	INFO ppo.py:159 -- In multi-agent mode, policies will be optimized sequentially by the multi-GPU optimizer. Consider setting simple_optimizer=True if this doesn't work for you.
2021-09-15 23:17:13,133	INFO trainer.py:728 -- Current log_level is WARN. For more information, set 'log_level': 'INFO' / 'DEBUG' or use the -v and -vv flags.
(pid=1462) Loading environment football failed: No module named 'gfootball'
Traceback (most recent call last):
  File "/kaggle/working/LuxPrivate/training.py", line 65, in <module>
    trainer = ppo.PPOTrainer(env=LuxEnv, config=config)
  File "/opt/conda/lib/python3.7/site-packages/ray/rllib/agents/trainer_template.py", line 136, in __init__
    Trainer.__init__(self, config, env, logger_creator)
  File "/opt/conda/lib/python3.7/site-packages/ray/rllib/agents/trainer.py", line 592, in __init__
    super().__init__(config, logger_creator)
  File "/opt/conda/lib/python3.7/site-packages/ray/tune/trainable.py", line 103, in __init__
    self.setup(copy.deepcopy(self.config))
  File "/opt/conda/lib/python3.7/site-packages/ray/rllib/agents/trainer_template.py", line 146, in setup
    super().setup(config)
  File "/opt/conda/lib/python3.7/site-packages/ray/rllib/agents/trainer.py", line 739, in setup
    self._init(self.config, self.env_creator)
  File "/opt/conda/lib/python3.7/site-packages/ray/rllib/agents/trainer_template.py", line 175, in _init
    num_workers=self.config["num_workers"])
  File "/opt/conda/lib/python3.7/site-packages/ray/rllib/agents/trainer.py", line 827, in _make_workers
    logdir=self.logdir)
  File "/opt/conda/lib/python3.7/site-packages/ray/rllib/evaluation/worker_set.py", line 85, in __init__
    lambda p, pid: (pid, p.observation_space, p.action_space)))
  File "/opt/conda/lib/python3.7/site-packages/ray/_private/client_mode_hook.py", line 82, in wrapper
    return func(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/ray/worker.py", line 1623, in get
    raise value
  File "python/ray/_raylet.pyx", line 640, in ray._raylet.task_execution_handler
  File "python/ray/_raylet.pyx", line 488, in ray._raylet.execute_task
  File "python/ray/_raylet.pyx", line 604, in ray._raylet.execute_task
ray.exceptions.RayActorError: The actor died because of an error raised in its creation task, ray::RolloutWorker.__init__() (pid=1462, ip=172.19.2.2)
  File "/opt/conda/lib/python3.7/site-packages/ray/rllib/evaluation/rollout_worker.py", line 401, in __init__
    self.env = env_creator(env_context)
  File "/opt/conda/lib/python3.7/site-packages/ray/rllib/agents/trainer.py", line 1647, in <lambda>
    register_env(name, lambda config: env_object(config))
TypeError: __init__() missing 1 required positional argument: 'debug'
(pid=1463) 2021-09-15 23:17:45,760	ERROR worker.py:428 -- Exception raised in creation task: The actor died because of an error raised in its creation task, ray::RolloutWorker.__init__() (pid=1463, ip=172.19.2.2)
(pid=1463)   File "/opt/conda/lib/python3.7/site-packages/ray/rllib/evaluation/rollout_worker.py", line 401, in __init__
(pid=1463)     self.env = env_creator(env_context)
(pid=1463)   File "/opt/conda/lib/python3.7/site-packages/ray/rllib/agents/trainer.py", line 1647, in <lambda>
(pid=1463)     register_env(name, lambda config: env_object(config))
(pid=1463) TypeError: __init__() missing 1 required positional argument: 'debug'
(pid=1463) Loading environment football failed: No module named 'gfootball'
(pid=1462) 2021-09-15 23:17:45,734	ERROR worker.py:428 -- Exception raised in creation task: The actor died because of an error raised in its creation task, ray::RolloutWorker.__init__() (pid=1462, ip=172.19.2.2)
(pid=1462)   File "/opt/conda/lib/python3.7/site-packages/ray/rllib/evaluation/rollout_worker.py", line 401, in __init__
(pid=1462)     self.env = env_creator(env_context)
(pid=1462)   File "/opt/conda/lib/python3.7/site-packages/ray/rllib/agents/trainer.py", line 1647, in <lambda>
(pid=1462)     register_env(name, lambda config: env_object(config))
(pid=1462) TypeError: __init__() missing 1 required positional argument: 'debug'

The training script:

import sys
sys.path.append('/kaggle/working/LuxPrivate')

from my_multilux_interface import MyInterface
import ray

ray.init()

from ray.tune.registry import register_env
from multilux.lux_env import LuxEnv

def env_creator(env_config):
    # I pass env_config as {} and set defaults here instead
    configuration = env_config.get('configuration', {})
    debugg = env_config.get('debugggg', False)
    interface = env_config.get('interface', MyInterface)
    agents = env_config.get('agents', (None, "simple_agent"))

    return LuxEnv(configuration, debugg,
                  interface=interface,
                  agents=agents)

register_env("multilux", env_creator)

# (3) Instantiate agent ------------------------------------------------------
import random
from ray.rllib.agents import ppo

config = {
    "env_config": {},
    "multiagent": {
        "policies": {
            # the first tuple value is None -> uses default policy
            "unit-1": (None,
                       MyInterface.obs_spaces["unit"],
                       MyInterface.act_spaces["unit"],
                       {"gamma": 0.85}),
            "unit-2": (None,
                       MyInterface.obs_spaces["unit"],
                       MyInterface.act_spaces["unit"],
                       {"gamma": 0.99}),
            "citytile": (None,
                         MyInterface.obs_spaces["citytile"],
                         MyInterface.act_spaces["citytile"],
                         {}),
        },
        "policy_mapping_fn":
            lambda agent_id:
            "citytile"  # Citytiles always have the same policy
            if agent_id.startswith("ct_")
            else random.choice(["unit-1", "unit-2"])  # Randomly choose from unit policies
    },
}

trainer = ppo.PPOTrainer(env=LuxEnv, config=config)    # <---------------- ERROR HERE

# (4) Train away -------------------------------------------------------------
while True:
    print(trainer.train())

Any help or pointers much appreciated!

Hi @RuizSerra

Welcome to the forum.

trainer = ppo.PPOTrainer(env=LuxEnv,

Should be:

trainer = ppo.PPOTrainer(env="multilux" ,

:man_facepalming:t2:I knew that! Thank you so much!!