rlworkgroup / garage

A toolkit for reproducible reinforcement learning research.
MIT License
1.88k stars 310 forks source link

GymEnv pickled incorrectly #2095

Closed yeukfu closed 4 years ago

yeukfu commented 4 years ago

In the samplers, we use copy.deepcopy() to copy env_update. This works fine when the environment has default max_episode_length. However, when copying an environment with a customized max_episode_length, the spec is copied wrongly. For example:

import copy
from garage.envs import GymEnv

def copy_env():
    env = GymEnv('InvertedDoublePendulum-v2', max_episode_length=100)
    env_cp = copy.deepcopy(env)
    print(env.spec.max_episode_length)
    print(env_cp.spec.max_episode_length)

copy_env()

This code will output

100
1000