You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The check_env() function of gym is failing after converting the environment using the GymEnv class. The check_env function calls
check_reset_return_type() gives the output
200 result = env.reset()
--> 201 assert isinstance(
202 result, tuple
203 ), f"The result returned by `env.reset()` was not a tuple of the form `(obs, info)`, where `obs` is a observation and `info` is a dictionary containing additional information. Actual type: `{type(result)}`"
204 assert (
205 len(result) == 2
206 ), f"Calling the reset method did not return a 2-tuple, actual length: {len(result)}"
208 obs, info = result
AssertionError: The result returned by `env.reset()` was not a tuple of the form `(obs, info)`, where `obs` is a observation and `info` is a dictionary containing additional information. Actual type: `<class 'collections.OrderedDict'>``
299 check_reset_options(env)
-check_reset_seed() gives
ValueError Traceback (most recent call last)
Cell In [5], line 1
----> 1 check_reset_seed(gym_env)
File ~/........../L2PRN/lib/python3.10/site-packages/gym/utils/env_checker.py:78, in check_reset_seed(env)
73 if "seed" in signature.parameters or (
74 "kwargs" in signature.parameters
75 and signature.parameters["kwargs"].kind is inspect.Parameter.VAR_KEYWORD
76 ):
77 try:
---> 78 obs_1, info = env.reset(seed=123)
79 assert (
80 obs_1 in env.observation_space
81 ), "The observation returned by `env.reset(seed=123)` is not within the observation space."
82 assert (
83 env.unwrapped._np_random # pyright: ignore [reportPrivateUsage]
84 is not None
85 ), "Expects the random number generator to have been generated given a seed was passed to reset. Mostly likely the environment reset function does not call `super().reset(seed=seed)`."
ValueError: too many values to unpack (expected 2)
How to reproduce
from grid2op.gym_compat import GymEnv
import grid2op
from gym import Env
from gym.utils.env_checker import check_env, check_reset_return_type, check_reset_options, check_reset_seed
from grid2op.Backend import PandaPowerBackend
bk_cls = PandaPowerBackend
env_name = "l2rpn_case14_sandbox"
training_env = grid2op.make(env_name, test=True, backend=bk_cls())
gym_env = GymEnv(training_env)
check_reset_return_type(gym_env)
check_reset_seed(gym_env)
You are facing this issue because grid2op is not totally compatible with recent gym versions.
I'm currently (did that this afternoon) working toward it but it takes a bit of time as gym changed a lot recently.
For now I guess using gum 0.21 is probably the best thing to do. In gym 0.26 they enforce their new api for reset, seed etc which I had no time to work on (it's just simple glue code but it should be done regardless)
Thanks for the script provided, I will add it in the tests tomorrow or the day after when i will have time to finish the integration.
Environment
1.7.2
macos 12.6.1
Bug description
The check_env() function of gym is failing after converting the environment using the GymEnv class. The check_env function calls
-check_reset_seed() gives
How to reproduce
Temporary Solution
By Navigating to
/......../L2PRN/lib/python3.10/site-packages/grid2op/gym_compat/gymenv.py
I temporarily fixed it by setting return_info=True and adding super().reset(seed=seed) in the reset function https://github.com/rte-france/Grid2Op/blob/51854262d02d96c1ee1798a78a86661d1ff971a1/grid2op/gym_compat/gymenv.py#L59The text was updated successfully, but these errors were encountered: