Skip to content

Commit

Permalink
Temporarily exclude 'dog' domain from control suite due to VFS bug
Browse files Browse the repository at this point in the history
Also moved the tests for the control suite into the root directory and gave them more descriptive names

PiperOrigin-RevId: 318066097
Change-Id: I73c4d707fe8783c47b1a91298244ca3664ed56f1
  • Loading branch information
alimuldal authored and copybara-github committed Jun 24, 2020
1 parent bc93d88 commit 997df74
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _get_fix_seed():
return _FIX_SEED


class DomainTest(parameterized.TestCase):
class ManipulationTest(parameterized.TestCase):
"""Tests run on all the tasks registered."""

def _validate_observation(self, observation, observation_spec):
Expand Down
5 changes: 5 additions & 0 deletions dm_control/suite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ def _get_tasks(tag):
result = []

for domain_name in sorted(_DOMAINS.keys()):

# TODO(b/159786444): Fix VFS-related error affecting dog domain
if domain_name == 'dog':
continue

domain = _DOMAINS[domain_name]

if tag is None:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
from six.moves import zip


_DOMAINS_AND_TASKS = [
dict(domain=domain, task=task) for domain, task in suite.ALL_TASKS
]


def uniform_random_policy(action_spec, random=None):
lower_bounds = action_spec.minimum
upper_bounds = action_spec.maximum
Expand Down Expand Up @@ -64,7 +69,7 @@ def make_trajectory(domain, task, seed, **trajectory_kwargs):
return step_environment(env, policy, **trajectory_kwargs)


class DomainTest(parameterized.TestCase):
class SuiteTest(parameterized.TestCase):
"""Tests run on all the tasks registered."""

def test_constants(self):
Expand Down Expand Up @@ -107,7 +112,7 @@ def _validate_control_range(self, lower_bounds, upper_bounds):
for b in upper_bounds:
self.assertEqual(b, 1.0)

@parameterized.parameters(*suite.ALL_TASKS)
@parameterized.parameters(_DOMAINS_AND_TASKS)
def test_components_have_names(self, domain, task):
env = suite.load(domain, task)
model = env.physics.model
Expand Down Expand Up @@ -138,15 +143,15 @@ def test_components_have_names(self, domain, task):
msg='Model {!r} contains unnamed {!r} with ID {}.'
.format(model.name, object_type, idx))

@parameterized.parameters(*suite.ALL_TASKS)
@parameterized.parameters(_DOMAINS_AND_TASKS)
def test_model_has_at_least_2_cameras(self, domain, task):
env = suite.load(domain, task)
model = env.physics.model
self.assertGreaterEqual(model.ncam, 2,
'Model {!r} should have at least 2 cameras, has {}.'
.format(model.name, model.ncam))

@parameterized.parameters(*suite.ALL_TASKS)
@parameterized.parameters(_DOMAINS_AND_TASKS)
def test_task_conforms_to_spec(self, domain, task):
"""Tests that the environment timesteps conform to specifications."""
is_benchmark = (domain, task) in suite.BENCHMARKING
Expand All @@ -167,7 +172,7 @@ def test_task_conforms_to_spec(self, domain, task):
if is_benchmark:
self._validate_reward_range(time_step)

@parameterized.parameters(*suite.ALL_TASKS)
@parameterized.parameters(_DOMAINS_AND_TASKS)
def test_environment_is_deterministic(self, domain, task):
"""Tests that identical seeds and actions produce identical trajectories."""
seed = 0
Expand Down Expand Up @@ -227,15 +232,15 @@ def test_visualize_reward(self, domain, task):
mock_get_reward.assert_called_with(env.physics)
self.assertCorrectColors(env.physics, reward=mock_get_reward.return_value)

@parameterized.parameters(*suite.ALL_TASKS)
@parameterized.parameters(_DOMAINS_AND_TASKS)
def test_task_supports_environment_kwargs(self, domain, task):
env = suite.load(domain, task,
environment_kwargs=dict(flat_observation=True))
# Check that the kwargs are actually passed through to the environment.
self.assertSetEqual(set(env.observation_spec()),
{control.FLAT_OBSERVATION_KEY})

@parameterized.parameters(*suite.ALL_TASKS)
@parameterized.parameters(_DOMAINS_AND_TASKS)
def test_observation_arrays_dont_share_memory(self, domain, task):
env = suite.load(domain, task)
first_timestep = env.reset()
Expand All @@ -247,7 +252,7 @@ def test_observation_arrays_dont_share_memory(self, domain, task):
np.may_share_memory(first_array, second_array),
msg='Consecutive observations of {!r} may share memory.'.format(name))

@parameterized.parameters(*suite.ALL_TASKS)
@parameterized.parameters(_DOMAINS_AND_TASKS)
def test_observations_dont_contain_constant_elements(self, domain, task):
env = suite.load(domain, task)
trajectory = make_trajectory(domain=domain, task=task, seed=0,
Expand Down Expand Up @@ -278,7 +283,7 @@ def test_observations_dont_contain_constant_elements(self, domain, task):
.format('\n'.join(':\t'.join([name, str(is_constant)])
for (name, is_constant) in failures)))

@parameterized.parameters(*suite.ALL_TASKS)
@parameterized.parameters(_DOMAINS_AND_TASKS)
def test_initial_state_is_randomized(self, domain, task):
env = suite.load(domain, task, task_kwargs={'random': 42})
obs1 = env.reset().observation
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def is_excluded(s):

setup(
name='dm_control',
version='0.0.318049052',
version='0.0.318066097',
description='Continuous control environments and MuJoCo Python bindings.',
author='DeepMind',
license='Apache License, Version 2.0',
Expand Down

0 comments on commit 997df74

Please sign in to comment.