Skip to content

Commit

Permalink
Suppress physics errors in dm_control tests (bp #1877) (#1886)
Browse files Browse the repository at this point in the history
* Suppress physics errors in dm_control tests (#1877)

* Suppress physics errors in dm_control tests

* Update test_dm_control_env.py

* Update test_dm_control_env.py

(cherry picked from commit d27cc8c)

* Update test_dm_control_env.py

Co-authored-by: Ryan Julian <[email protected]>
  • Loading branch information
mergify[bot] and ryanjulian authored Aug 11, 2020
1 parent d6e447a commit fc5ef01
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/garage/envs/dm_control/test_dm_control_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from copy import copy
import pickle

import dm_control.mujoco
import dm_control.suite
import pytest

Expand All @@ -10,6 +11,7 @@


class TestDmControlEnv:

def test_can_step(self):
domain_name, task_name = dm_control.suite.ALL_TASKS[0]
env = DmControlEnv.from_suite(domain_name, task_name)
Expand All @@ -20,7 +22,9 @@ def test_can_step(self):
a = act_space.sample()
assert act_space.contains(a)
# Skip rendering because it causes TravisCI to run out of memory
step_env(env, render=False)
# Sometimes random actions lead to physics errors
with env._env.physics.suppress_physics_errors():
step_env(env, render=False)
env.close()

@pytest.mark.nightly
Expand All @@ -35,7 +39,9 @@ def test_all_can_step(self, domain_name, task_name):
a = act_space.sample()
assert act_space.contains(a)
# Skip rendering because it causes TravisCI to run out of memory
step_env(env, render=False)
# Sometimes random actions lead to physics errors
with env._env.physics.suppress_physics_errors():
step_env(env, render=False)
env.close()

def test_pickleable(self):
Expand All @@ -44,7 +50,9 @@ def test_pickleable(self):
round_trip = pickle.loads(pickle.dumps(env))
assert round_trip
# Skip rendering because it causes TravisCI to run out of memory
step_env(round_trip, render=False)
# Sometimes random actions lead to physics errors
with env._env.physics.suppress_physics_errors():
step_env(env, render=False)
round_trip.close()
env.close()

Expand All @@ -56,7 +64,9 @@ def test_all_pickleable(self, domain_name, task_name):
round_trip = pickle.loads(pickle.dumps(env))
assert round_trip
# Skip rendering because it causes TravisCI to run out of memory
step_env(round_trip, render=False)
# Sometimes random actions lead to physics errors
with env._env.physics.suppress_physics_errors():
step_env(env, render=False)
round_trip.close()
env.close()

Expand Down

0 comments on commit fc5ef01

Please sign in to comment.