1
$\begingroup$

I am building my a custom Gym environment and so far everything worked well following the guides spread all over the internet. However, I am now in a phase when frequent changes to the environment class (inheriting gym.Env) are happening and need to be tested. After the latest coding changes to reset() and step() method, it turns out that now gym.make() returns an environment object which executes old code which was valid before.

So my question is: How to overcome that issue? I am not a friend of increasing the version id to e.g. v1, as the originating v0 is still under development.

The __init__.py file on package level contains that:

from importlib.metadata import version
from gym.envs.registration import register

__version__ = version("wksim")
register(id="WkEnv-v0", entry_point="wksim.wkenv:WkEnv")

Note: class WkEnv is located in the file wkenv.py

In the following executable file I am testing the following way

import gym
from wksim.wkenv import WkEnv

if __name__ == "__main__":
    env_config = {
        "cli_mode": True,
        "cache_trace": True,
        "instance": "minimal",
        "UNIFORM_TIME_SLOT_LENGTH": 0.05,
    }

    env = gym.make("WkEnv-v0", config=env_config)
    initial_state = env.reset()

Note: I learnt that the custom environment class must be imported, otherwise gym.make() will not find the env id.

$\endgroup$
3
  • $\begingroup$ What version of gym are you using? $\endgroup$ Aug 29, 2022 at 14:19
  • $\begingroup$ Your issue might be due to the gym version. If I don't know the gym version, it could be impossible to detect the source of the problem. $\endgroup$ Aug 30, 2022 at 19:37
  • $\begingroup$ I use gym version 0.21.0 in order to have compatibility with ray-rllib. $\endgroup$
    – PWillms
    Sep 2, 2022 at 18:39

1 Answer 1

0
$\begingroup$

This topic was solved even with gym 0.21.0, but also now after the upgrade to gymnasium. The root cause was sitting in the way of how the overall package was installed. Using pip install -e solved the point.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.