google-research / ibc

Official implementation of Implicit Behavioral Cloning, as described in our CoRL 2021 paper, see more at https://implicitbc.github.io/
Apache License 2.0
318 stars 34 forks source link

Unit tests fail #15

Open noahcgreen opened 2 years ago

noahcgreen commented 2 years ago

Hi, it seems that the unit tests do not work out of the box. I'm working in a clean conda environment with Python 3.7.13. All of the prerequisites are installed with the versions described in the readme, as well as CUDA and cuDNN (Tensorflow has GPU access).

Here's the complete output from the test script:

Test script output

Here's the last part of that formatted a bit more nicely:

INFO:tensorflow:time(__main__.Blocks2DTest.test_validate_environment): 0.09s
I0629 13:44:15.179256 140609892135296 test_util.py:2189] time(__main__.Blocks2DTest.test_validate_environment): 0.09s
[  FAILED  ] Blocks2DTest.test_validate_environment
======================================================================
FAIL: test_validate_environment (__main__.Blocks2DTest)
Blocks2DTest.test_validate_environment
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/arc/noah/ibc/environments/block_pushing/block_pushing_multimodal_test.py", line 34, in test_validate_environment
    utils.validate_py_environment(env)
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/tf_agents/environments/utils.py", line 75, in validate_py_environment
    time_step = environment.reset()
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/tf_agents/environments/py_environment.py", line 196, in reset
    self._current_time_step = self._reset()
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/tf_agents/environments/wrappers.py", line 111, in _reset
    return self._env.reset()
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/tf_agents/environments/py_environment.py", line 196, in reset
    self._current_time_step = self._reset()
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/tf_agents/environments/gym_wrapper.py", line 193, in _reset
    observation = self._gym_env.reset()
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/gym/wrappers/time_limit.py", line 66, in reset
    return self.env.reset(**kwargs)
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/gym/wrappers/order_enforcing.py", line 42, in reset
    return self.env.reset(**kwargs)
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/gym/wrappers/env_checker.py", line 47, in reset
    return passive_env_reset_check(self.env, **kwargs)
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/gym/utils/passive_env_checker.py", line 247, in passive_env_reset_check
    _check_obs(obs, env.observation_space, "reset")
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/gym/utils/passive_env_checker.py", line 115, in _check_obs
    ), f"{pre} is not contained with the observation space ({observation_space})"
AssertionError: The observation returned by the `reset()` method is not contained with the observation space (Dict(block_translation: Box(-5.0, 5.0, (2,), float32), block_orientation: Box(-6.2831855, 6.2831855, (1,), float32), block2_translation: Box(-5.0, 5.0, (2,), float32), block2_orientation: Box(-6.2831855, 6.2831855, (1,), float32), effector_translation: Box([ 0.05 -0.6 ], [0.8 0.6], (2,), float32), effector_target_translation: Box([ 0.05 -0.6 ], [0.8 0.6], (2,), float32), target_translation: Box(-5.0, 5.0, (2,), float32), target_orientation: Box(-6.2831855, 6.2831855, (1,), float32), target2_translation: Box(-5.0, 5.0, (2,), float32), target2_orientation: Box(-6.2831855, 6.2831855, (1,), float32)))

----------------------------------------------------------------------

The issue seems to be that several fields of the observation returned by BlockPushMultimodal._compute_state() need to be converted to np arrays with dtype np.float32. After doing that and running the test again, I get the following error instead:

INFO:tensorflow:time(__main__.Blocks2DTest.test_validate_environment): 0.1s
I0629 14:04:36.733099 140095945187712 test_util.py:2189] time(__main__.Blocks2DTest.test_validate_environment): 0.1s
[  FAILED  ] Blocks2DTest.test_validate_environment
======================================================================
ERROR: test_validate_environment (__main__.Blocks2DTest)
Blocks2DTest.test_validate_environment
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/arc/noah/ibc/environments/block_pushing/block_pushing_multimodal_test.py", line 34, in test_validate_environment
    utils.validate_py_environment(env)
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/tf_agents/environments/utils.py", line 84, in validate_py_environment
    time_step = environment.step(action)
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/tf_agents/environments/py_environment.py", line 233, in step
    self._current_time_step = self._step(action)
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/tf_agents/environments/wrappers.py", line 117, in _step
    time_step = self._env.step(action)
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/tf_agents/environments/py_environment.py", line 233, in step
    self._current_time_step = self._step(action)
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/tf_agents/environments/gym_wrapper.py", line 215, in _step
    observation, reward, self._done, self._info = self._gym_env.step(action)
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/gym/wrappers/time_limit.py", line 49, in step
    observation, reward, done, info = self.env.step(action)
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/gym/wrappers/order_enforcing.py", line 37, in step
    return self.env.step(action)
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/gym/wrappers/env_checker.py", line 39, in step
    return passive_env_step_check(self.env, action)
  File "/home/arc/miniconda3/envs/ibc-test/lib/python3.7/site-packages/gym/utils/passive_env_checker.py", line 273, in passive_env_step_check
    if np.any(np.isnan(obs)):
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

----------------------------------------------------------------------

This is the same error as in #14 so I'd guess these issues are related.

Any thoughts?

peteflorence commented 2 years ago

Hi there, thanks. Especially, thanks for confirming that all of your package versions match what's in the README.

This issue didn't used to exist, and the code in this repo hasn't changed, so it seems likely due to some dependency shifting underneath us in a way that isn't captured by just the package versions.

peteflorence commented 2 years ago

Hi @noahcgreen, so I just ran a test on my side, and my tests are passing. My computer though had all of these package versions installed from before.

Could you share your output of pip list? I wonder if you are asking for certain pip versions but they are not all getting installed as asked for?