[RLlib] PyBullet Env native support via env str-specifier (if installed). (#12209)

This commit is contained in:
Sven Mika
2020-11-30 12:41:24 +01:00
committed by GitHub
parent b85c6abc3e
commit bb03e2499b
5 changed files with 47 additions and 5 deletions
+15 -4
View File
@@ -553,11 +553,22 @@ class Trainer(Trainable):
elif "." in env:
self.env_creator = \
lambda env_context: from_config(env, env_context)
# Try gym.
# Try gym/PyBullet.
else:
import gym # soft dependency
self.env_creator = \
lambda env_context: gym.make(env, **env_context)
def _creator(env_context):
import gym
# Allow for PyBullet envs to be used as well (via string).
# This allows for doing things like
# `env=CartPoleContinuousBulletEnv-v0`.
try:
import pybullet_envs
pybullet_envs.getList()
except (ModuleNotFoundError, ImportError):
pass
return gym.make(env, **env_context)
self.env_creator = _creator
else:
self.env_creator = lambda env_config: None