Skip to content
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

Render mode attribute is erased by ss wrappers #241

Closed
Butanium opened this issue Jan 9, 2024 · 2 comments
Closed

Render mode attribute is erased by ss wrappers #241

Butanium opened this issue Jan 9, 2024 · 2 comments

Comments

@Butanium
Copy link
Contributor

Butanium commented Jan 9, 2024

This makes it impossible to use the sb3 video recorder on the fly for example:

from pettingzoo.atari import pong_v3
import supersuit as ss
from stable_baselines3.common.vec_env import VecVideoRecorder
def get_env():
    env = pong_v3.parallel_env(render_mode="rgb_array")
    env = ss.pettingzoo_env_to_vec_env_v1(env)
    envs = ss.concat_vec_envs_v1(
        env, 1 , num_cpus=0, base_class="stable_baselines3"
    )
    envs.render_mode = "rgb_array"
    envs = VecVideoRecorder(envs, f"videos/", capped_cubic_video_schedule)
    envs.single_observation_space = envs.observation_space
    envs.single_action_space = envs.action_space
    return envs

Without the envs.render_mode = "rgb_array" line, I get this error:

[<ipython-input-72-90f28677e07d>](https://localhost:8080/#) in get_env()
      6     )
      7     # envs.render_mode = "rgb_array"
----> 8     envs = VecVideoRecorder(envs, f"videos/", capped_cubic_video_schedule)
      9     envs.single_observation_space = envs.observation_space
     10     envs.single_action_space = envs.action_space

[/usr/local/lib/python3.10/dist-packages/stable_baselines3/common/vec_env/vec_video_recorder.py](https://localhost:8080/#) in __init__(self, venv, video_folder, record_video_trigger, video_length, name_prefix)
     50 
     51         self.env.metadata = metadata
---> 52         assert self.env.render_mode == "rgb_array", f"The render_mode must be 'rgb_array', not {self.env.render_mode}"
@Butanium
Copy link
Contributor Author

I used

!pip install git+https://github.com/Farama-Foundation/PettingZoo/
!pip install git+https://github.com/Farama-Foundation/SuperSuit/

In this colab if you want to reproduce:
https://colab.research.google.com/drive/14YWTsEtQk4oluCf-W9RXj077LZIyrkn4?usp=sharing

@elliottower
Copy link
Contributor

Fixed in #243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants