Farama-Foundation / Minigrid

Simple and easily configurable grid world environments for reinforcement learning
https://minigrid.farama.org/
Other
2.09k stars 604 forks source link

[Bug Report] BabyAI not working #217

Closed Valaybundele closed 2 years ago

Valaybundele commented 2 years ago

Hi, I am trying to install BabyAI on Linux 64-bit system. I followed the instructions mentioned in the BabyAI repo for installing the environment. The BabyAI environment file specifies Python 3.6 as the dependency while the latest version of gym-minigrid is incompatible with that. So, I modified it to Python 3.7.3 and then ran the following code.

git clone https://github.com/mila-iqia/babyai.git cd babyai conda env create -f environment.yaml source activate babyai

cd .. git clone https://github.com/maximecb/gym-minigrid.git cd gym-minigrid pip install --editable .

cd ../babyai pip install --editable .

Although, I was able to successfully run this code and install the dependencies, I am getting this error when I am trying to import babyai.

`Python 3.7.3 (default, Mar 27 2019, 22:11:17) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information.

import gym /home/biplab/.local/lib/python3.7/site-packages/matplotlib/init.py:152: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. if LooseVersion(module.version) < minver: /home/biplab/anaconda3/envs/babyai/lib/python3.7/site-packages/setuptools/_distutils/version.py:351: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. other = LooseVersion(other) import babyai Traceback (most recent call last): File "", line 1, in File "/home/biplab/Valay/babyai/babyai/init.py", line 3, in from . import levels File "/home/biplab/Valay/babyai/babyai/levels/init.py", line 4, in from . import bonus_levels File "/home/biplab/Valay/babyai/babyai/levels/bonus_levels.py", line 2, in from gym_minigrid.envs import Key, Ball, Box ImportError: cannot import name 'Key' from 'gym_minigrid.envs' (/home/biplab/anaconda3/envs/babyai/lib/python3.7/site-packages/gym_minigrid/envs/init.py)

Can something be done here or can I find the older repo somewhere since the latest version doesn't seem to work with BabyAI?

Thanks

pseudo-rnd-thoughts commented 2 years ago

Thanks for the issue, I have contacted one of the devs for BabyAI and they are going to make a release to fix this. Uncertain of the timeline for the fix but they are aware

Valaybundele commented 2 years ago

Hi @pseudo-rnd-thoughts,

Thanks for the quick reply. I understand that it might take time and so I was just wondering if I could get the older version of gym-minigrid repo somewhere so that I could continue with my experimentation. Please let me know if this is possible.

Thanks

pseudo-rnd-thoughts commented 2 years ago

The easiest way is to probably clone this repo, and add to the envs/__init__.py to import from gym_minigrid.minigrid import Ball, Key, Box and this should work now

Valaybundele commented 2 years ago

Hi @pseudo-rnd-thoughts, Thanks for the quick fix. I added the line from gym_minigrid.minigrid import Ball, Key, Box in babyai/babyai/levels/bonus_levels.py and I was able to import babyai successfully. But now when I am trying to make a new BabyAI environment, I am getting this error:

import babyai from gym_minigrid.wrappers import RGBImgPartialObsWrapper, ImgObsWrapper env = gym.make('BabyAI-GoToLocal-v0') Traceback (most recent call last): File "", line 1, in File "/home/biplab/anaconda3/envs/babyai/lib/python3.7/site-packages/gym/envs/registration.py", line 674, in make raise e File "/home/biplab/anaconda3/envs/babyai/lib/python3.7/site-packages/gym/envs/registration.py", line 662, in make env = env_creator(_kwargs) File "/home/biplab/Valay/babyai/babyai/levels/iclr19_levels.py", line 116, in init seed=seed File "/home/biplab/Valay/babyai/babyai/levels/levelgen.py", line 32, in init kwargs File "/home/biplab/anaconda3/envs/babyai/lib/python3.7/site-packages/gym_minigrid/roomgrid.py", line 96, in init **kwargs, TypeError: init() missing 1 required positional argument: 'mission_space'

I also tried adding mission_space='GoToLocal' in anaconda3/envs/babyai/lib/python3.7/site-packages/gym_minigrid/roomgrid.py" but I am still getting this error :

env = gym.make('BabyAI-GoToLocal-v0') Traceback (most recent call last): File "", line 1, in File "/home/biplab/anaconda3/envs/babyai/lib/python3.7/site-packages/gym/envs/registration.py", line 674, in make raise e File "/home/biplab/anaconda3/envs/babyai/lib/python3.7/site-packages/gym/envs/registration.py", line 662, in make env = env_creator(_kwargs) File "/home/biplab/Valay/babyai/babyai/levels/iclr19_levels.py", line 116, in init seed=seed File "/home/biplab/Valay/babyai/babyai/levels/levelgen.py", line 32, in init kwargs File "/home/biplab/anaconda3/envs/babyai/lib/python3.7/site-packages/gym_minigrid/roomgrid.py", line 96, in init mission_space='GoToLocal', TypeError: init() missing 1 required positional argument: 'mission_space'

Could you please suggest something to resolve this issue?

Thanks

pseudo-rnd-thoughts commented 2 years ago

I have downgrade the minigrid version, and hopefully babyAI will be fixed soon pip uninstall gym-minigrid then pip install gym-minigrid==1.0.3

Valaybundele commented 2 years ago

Hi, Thanks for downgrading the version. So these are the instructions to install BabyAI given in the repo:

git clone https://github.com/mila-iqia/babyai.git cd babyai conda env create -f environment.yaml source activate babyai

cd .. git clone https://github.com/maximecb/gym-minigrid.git cd gym-minigrid pip install --editable .

cd ../babyai pip install --editable .

Since gym-minigrid repo has been updated, I didn't clone it and created a new environment and ran the following code :

git clone https://github.com/mila-iqia/babyai.git cd babyai conda env create -f environment.yaml source activate babyai

pip install gym-minigrid==1.0.3

So now I am able to load the BabyAI environment but when I tried to reset the environment, I got the following error: Python 3.6.13 |Anaconda, Inc.| (default, Jun 4 2021, 14:25:59) [GCC 7.5.0] on linux Type "help", "copyright", "credits" or "license" for more information.

import gym /home/jupyter/miniconda3/envs/babyai-1/lib/python3.6/site-packages/gym/core.py:26: UserWarning: WARN: Gym minimally supports python 3.6 as the python foundation not longer supports the version, please update your version to 3.7+ "Gym minimally supports python 3.6 as the python foundation not longer supports the version, please update your version to 3.7+" import babyai env = gym.make('BabyAI-GoToRedBall-v0') /home/jupyter/miniconda3/envs/babyai-1/lib/python3.6/site-packages/gym/utils/seeding.py:64: DeprecationWarning: WARN: Function rng.randint(low, [high, size, dtype]) is marked as deprecated and will be removed in the future. Please use rng.integers(low, [high, size, dtype]) instead. "Function rng.randint(low, [high, size, dtype]) is marked as deprecated " /home/jupyter/miniconda3/envs/babyai-1/lib/python3.6/site-packages/gym/core.py:330: DeprecationWarning: WARN: Initializing wrapper in old step API which returns one bool instead of two. It is recommended to set new_step_api=True to use new step API. This will be the default behaviour in future. "Initializing wrapper in old step API which returns one bool instead of two. It is recommended to set new_step_api=True to use new step API. This will be the default behaviour in future." /home/jupyter/miniconda3/envs/babyai-1/lib/python3.6/site-packages/gym/wrappers/step_api_compatibility.py:40: DeprecationWarning: WARN: Initializing environment in old step API which returns one bool instead of two. It is recommended to set new_step_api=True to use new step API. This will be the default behaviour in future. "Initializing environment in old step API which returns one bool instead of two. It is recommended to set new_step_api=True to use new step API. This will be the default behaviour in future." env.reset() Traceback (most recent call last): File "", line 1, in File "/home/jupyter/miniconda3/envs/babyai-1/lib/python3.6/site-packages/gym/wrappers/order_enforcing.py", line 42, in reset return self.env.reset(kwargs) File "/home/jupyter/miniconda3/envs/babyai-1/lib/python3.6/site-packages/gym/core.py", line 427, in reset return self.env.reset(kwargs) File "/home/jupyter/miniconda3/envs/babyai-1/lib/python3.6/site-packages/gym/wrappers/env_checker.py", line 45, in reset return env_reset_passive_checker(self.env, **kwargs) File "/home/jupyter/miniconda3/envs/babyai-1/lib/python3.6/site-packages/gym/utils/passive_env_checker.py", line 215, in env_reset_passive_checker check_obs(obs, env.observation_space, "reset") File "/home/jupyter/miniconda3/envs/babyai-1/lib/python3.6/site-packages/gym/utils/passive_env_checker.py", line 159, in check_obs ), f"{pre} observation keys is not same as the observation space keys, obs keys: {list(obs.keys())}, space keys: {list(observation_space.spaces.keys())}" AssertionError: The obs returned by the reset() method observation keys is not same as the observation space keys, obs keys: ['image', 'direction', 'mission'], space keys: ['image']

Is this because gym-minigrid repo has been updated and I didn't install it by cloning the repo or is the issue something else?

Thanks

pseudo-rnd-thoughts commented 2 years ago

Hopefully all of these issues will be fixed by BabyAI soon, but in the meantime, you can use env = gym.make('BabyAI-GoToRedBall-v0', disable_env_checker=True) which should fix your issue

Valaybundele commented 2 years ago

Hi,

That worked. Thanks a lot for the help!