[core] Disable OrderEnforced wrapper class.
@@ -16,6 +16,25 @@ def make(id: str, **kwargs):
return gym.make(id, **kwargs)
-def register(id: str, **kwargs):
+def _parse_version_string(version):
+ """Quick and dirty <major>.<minor>.<micro> parser. Very hacky."""
+ components = version.split(".")
+ if len(components) != 3:
+ return None
+ try:
+ return tuple([int(x) for x in components])
+ except (TypeError, ValueError):
+ return None
+
+
+def register(id: str, order_enforce: bool = False, **kwargs):
COMPILER_GYM_ENVS.append(id)
+
+ # As of gym==0.21.0 a new OrderEforce wrapper is enabled by default. Turn
+ # this off as CompilerEnv already enforces this and the wrapper obscures the
+ # docstrings of the base class.
+ gym_version = _parse_version_string(gym.__version__)
+ if gym_version and gym_version >= (0, 21):
+ kwargs["order_enforce"] = order_enforce
+
gym_register(id=id, **kwargs)
