learnables / learn2learn

A PyTorch Library for Meta-learning Research
http://learn2learn.net
MIT License
2.59k stars 348 forks source link

A bug when creating the mujoco environment #411

Closed SliverySky closed 1 year ago

SliverySky commented 1 year ago

When I create a mujoco environment: env = gym.make('HalfCheetahForwardBackward-v1') An error is raised in the line 34 of "/learn2learn/gym/envs/meta_env,py": TypeError: init() missing 2 required positional arguments: 'model_path' and 'frame_skip'

Then, I found the reason why this error happens. In the meta_env.py file,

class MetaEnv(Env):
def __init__(self, task=None):
        super(MetaEnv, self).__init__()
        if task is None:
            task = self.sample_tasks(1)[0]
        self.set_task(task)

I think the intention of super(MetaEnv, self).__init__() is to call the initialization method of Env Class. However, actually this line calls the initialization method of MujocoEnv class which leads to the error. This is because of MujocoEnvis the next class of MetaEnv in the list of HalfCheetahForwardBackwardEnv.__mro__.

To fix this problem, super(MetaEnv, self).__init__() should be changed to Env.__init__(self)

seba-1511 commented 1 year ago

Hello @SliverySky,

Thanks for pointing this out and for providing a path to a fix. Would you like to open a PR to contribute the solution?

SliverySky commented 1 year ago

@seba-1511 OK, I have opened a PR to contribute this solution.