fixed minor back with __getattr__

This commit is contained in:
ottofabian 2021-07-02 18:18:11 +02:00
parent 4fafe86764
commit 92f1f409f3
3 changed files with 12 additions and 8 deletions

View File

@ -87,16 +87,16 @@ def example_async(env_id="alr_envs:HoleReacher-v0", n_cpu=4, seed=int('533D', 16
if __name__ == '__main__':
# Basic gym task
# example_general("Pendulum-v0", seed=10, iterations=200, render=True)
example_general("Pendulum-v0", seed=10, iterations=200, render=True)
#
# # Basis task from framework
# example_general("alr_envs:HoleReacher-v0", seed=10, iterations=200, render=True)
example_general("alr_envs:HoleReacher-v0", seed=10, iterations=200, render=True)
#
# # OpenAI Mujoco task
# example_general("HalfCheetah-v2", seed=10, render=True)
example_general("HalfCheetah-v2", seed=10, render=True)
#
# # Mujoco task from framework
# example_general("alr_envs:ALRReacher-v0", seed=10, iterations=200, render=True)
example_general("alr_envs:ALRReacher-v0", seed=10, iterations=200, render=True)
# Vectorized multiprocessing environments
example_async(env_id="alr_envs:HoleReacher-v0", n_cpu=2, seed=int('533D', 16), n_samples=2 * 200)

View File

@ -91,9 +91,13 @@ class DMCWrapper(core.Env):
# set seed
self.seed(seed=task_kwargs.get('random', 1))
def __getattr__(self, name):
"""Delegate attribute access to underlying environment."""
return getattr(self._env, name)
def __getattr__(self, item):
"""Propagate only non-existent properties to wrapped env."""
if item.startswith('_'):
raise AttributeError("attempted to get missing private attribute '{}'".format(item))
if item in self.__dict__:
return getattr(self, item)
return getattr(self._env, item)
def _get_obs(self, time_step):
if self._from_pixels:

View File

@ -9,7 +9,7 @@ setup(
'gym',
'PyQt5',
'matplotlib',
'mp_env_api @ git+ssh://git@github.com/ALRhub/motion_primitive_env_api.git',
# 'mp_env_api @ git+ssh://git@github.com/ALRhub/motion_primitive_env_api.git',
'mujoco_py'
],