-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
KeyError occurs when loading custom dataset #131
Comments
Thanks for the report! We'll look into this. |
@JustinS6626 I think we will also need the code used to create the dataset in order to debug this. |
Thanks for getting back to me so soon! Posting the code would be difficult, since it includes some proprietary elements. However, if there is any chance that you would be able to post a worked example of creating a dataset using a Minigrid environment, I think that would solve the problem. |
Just a quick update, I tried creating a dataset with the empty minigrid environment, just to see if the problem was with my custom environment. When I tried to create the dataset for the 8x8 empty minigrid, I got the following error:
I tried to resolve the issue by using an
I am not sure if this is because the current Minari implementation is not setup to handle minigrid environments, or because I am doing something wrong. |
Here is a toy example of what I am trying to do:
I would really appreciate if from that, you would be able to provide some guidance on how to save and load a dataset successfully. |
This error comes because there is no serialization method for MissionSpace. You can write a custom serialization method and register the functions to Or, a simpler fix is to overwrite the observation space when creating the DataCollectorV0 and replace the mission with a Text space. |
@younik Thank you very much for getting back to me about that! Are there any examples of how to overwrite the observation space for the DataCollector and replace the mission space with a Text space? |
Here an example: import gymnasium as gym
import minigrid
import minari
from minari import DataCollectorV0
from gymnasium.spaces.text import alphanumeric
env = gym.make("MiniGrid-Fetch-5x5-N2-v0")
max_len = len("you must fetch a purple ball")
obs_space = gym.spaces.Dict({
"direction": env.observation_space["direction"],
"image": env.observation_space["image"],
"mission": gym.spaces.Text(
max_length=max_len,
charset=str(alphanumeric) + ' '
)
})
env = DataCollectorV0(env, record_infos=True, max_buffer_steps=1_000_000, observation_space=obs_space) |
Thank you very much! I think that part of the code might be fixed. My implementation now looks like this
Now, however, I am getting a different error:
Based on that, I am wondering where the version should be specified. My Minari version is 0.4.1. |
So our dataset ID parser was fussing because it expects the format: "<env name>-<dataset name>-<version number>". you can use "MinigridEmpty-random-v0" |
Thank you very much! That fixes the problem, except for one small issue. I am also trying to save and load the timestep number of each step the agent takes, as you probably noticed in the
When I use that approach, however, I get the following error:
What would be the correct way to add timestep numbering to my dataset? |
unfortunately our |
I am trying load a dataset created from a Minigrid-type environment using the following code:
When I run the code, I get this error:
When I created the dataset, I used an
ImgObsWrapper
for the environment. Could that be the source of the problem?The text was updated successfully, but these errors were encountered: