-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RLlib] Issue 39453: PettingZoo wrappers should use correct multi-agent dict action- and observation spaces. #39459
Conversation
Thanks @sven1977 for responding so quickly to #39453! I have a suggestion: can we make RLLib's For example, here's what the class ParallelPettingZooEnv(MultiAgentEnv):
def __init__(self, env):
super().__init__()
self.par_env = env
self.par_env.reset()
self._agent_ids = set(self.par_env.agents)
self.observation_space = gym.spaces.Dict(self.par_env.observation_spaces)
self.action_space = gym.spaces.Dict(self.par_env.action_spaces) |
…e_39453_pettingzoo_wrappers_should_use_correct_ma_dict_spaces
Hey @chrisyeh96 , thanks for the hint. Changed this to be even more flexible now for both parallel and non-parallel env wrappers. |
rllib/env/wrappers/pettingzoo_env.py
Outdated
first_obs_space | ||
) | ||
self.action_space = convert_old_gym_space_to_gymnasium_space(first_action_space) | ||
|
||
self._agent_ids = self.env.agents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._agent_ids
should be a set, so this line should be changed to:
self._agent_ids = set(self.env.agents)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
rllib/env/wrappers/pettingzoo_env.py
Outdated
@@ -188,37 +154,10 @@ def __init__(self, env): | |||
super().__init__() | |||
self.par_env = env | |||
self.par_env.reset() | |||
self._agent_ids = self.par_env.agents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._agent_ids
should be a set, so this line should be changed to:
self._agent_ids = set(self.par_env.agents)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Thanks @sven1977 for the changes! I've suggested 2 minor changes in my code review. There's also one other place that should be updated. The docstring for ray/rllib/env/wrappers/pettingzoo_env.py Lines 23 to 27 in 5a4389b
Thanks for your work on this! |
Thanks @sven1977! Looking forward to seeing this change merged. Do you know if it will be included in the next release of RLLib? |
Hey @chrisyeh96 , yes, it'll be part of Ray 2.8, though, and won't make it into the upcoming 2.7 anymore. |
Understood. Any idea on what the timeline for Ray 2.8 will be? For me, this issue is quite important. I have a project called SustainGym where I've made 5 RL environments related to energy / sustainability applications. 3 of the 5 environments are multi-agent RL environments following the PettingZoo API. Currently, I include RLLib as a dependency of SustainGym, because I have special versions of my environments to fit the RLLib |
2.8 will be released a few weeks after the Ray Summit (which is next week). So roughly beginning to mid October. |
…nt dict action- and observation spaces. (ray-project#39459) Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
…nt dict action- and observation spaces. (ray-project#39459) Signed-off-by: Victor <vctr.y.m@example.com>
See issue: #39453
Solution:
Change both PettingZoo adapters of RLlib to abide to RLlib's multi-agent action- and observation space convention (gym.spaces.Dict mapping agent Ids to individual spaces).
Closes: #39453 and #32889
Why are these changes needed?
Related issue number
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.