Skip to content

Commit

Permalink
fully move dmc to gymnasium
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEimer committed Dec 11, 2023
1 parent 4a15397 commit fb22b25
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion carl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def check_spec(spec_name: str) -> bool:
)
return found

# Environment loading
found = check_spec("Box2D")
if found:
for e in envs.gymnasium.box2d.__all__:
Expand All @@ -67,6 +66,14 @@ def check_spec(spec_name: str) -> bool:
entry_point=f"carl.envs.gymnasium.box2d:{e}",
)

found = check_spec("dm_control")
if found:
for e in envs.dmc.__all__:
register(
id=f"carl/{e}-v0",
entry_point=f"carl.envs.dmc:{e}",
)

found = check_spec("py4j")
if found:
register(
Expand Down
4 changes: 2 additions & 2 deletions carl/envs/dmc/wrappers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Any, Optional, Tuple, TypeVar, Union

import dm_env # type: ignore
import gym
import gymnasium as gym
import numpy as np
from dm_env import StepType
from gym import spaces
from gymnasium import spaces

ObsType = TypeVar("ObsType")
ActType = TypeVar("ActType")
Expand Down
4 changes: 2 additions & 2 deletions test/test_gymnasium_envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class TestGymnasiumRegistration(unittest.TestCase):
def test_registration(self):
registered_envs = gym.envs.registration.registry.keys()
for e in carl.envs.__all__:
if "RNA" not in e and "Brax" not in e and "Dmc" not in e:
if "RNA" not in e and "Brax" not in e:
env_name = f"carl/{e}-v0"
self.assertTrue(env_name in registered_envs)

def test_make(self):
for e in carl.envs.__all__:
if "RNA" not in e and "Brax" not in e and "Dmc" not in e:
if "RNA" not in e and "Brax" not in e:
env_name = f"carl/{e}-v0"
env = gym.make(env_name)
self.assertTrue(isinstance(env, gym.Env))
Expand Down

0 comments on commit fb22b25

Please sign in to comment.