Farama-Foundation / Arcade-Learning-Environment

The Arcade Learning Environment (ALE) -- a platform for AI research.
GNU General Public License v2.0
2.12k stars 420 forks source link

Recording video no longer works when using Gym with ALE #475

Closed SebastianHurubaru closed 1 year ago

SebastianHurubaru commented 1 year ago

Hello,

since the change in Gym 0.26.0 of the render_mode flag, the gym.wrappers.RecordVideo does not work anymore with ALE!

When recording the video we are getting the following log message:

.../lib/python3.8/site-packages/gym/wrappers/monitoring/video_recorder.py:59: UserWarning: WARN: Disabling video recorder because environment <OrderEnforcing<PassiveEnvChecker<AtariEnv<ALE/Pong-v5>>>> was not initialized with any compatible video mode between rgb_array and rgb_array_list

We are setting the render_mode when creating the environment, as showed in the blog for the Gym 0.26.0 release, but the render_mode flag doesn't get set in the AtariEnv, as the class uses an internal variable self._render_mode instead, leading to the warning and videos not being recorded.

Here is a code sample that can help with the issue replication:

` import gym

env = gym.make("ALE/Pong-v5", render_mode="rgb_array")

env = gym.wrappers.RecordVideo( env, video_folder='video', step_trigger=lambda x: x % 100 == 0 )

env.reset() for t in range(100): action = env.action_space.sample() observation, reward, terminated, truncated, info = env.step(action)

env.close() `

We are using Python 3.8.10 with Gym 0.26.2 and ale-py 0.8.0

JesseFarebro commented 1 year ago

The fix has now been merged and will be released with v0.8.1.