Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make dm_control an extra dependency #828

Merged
merged 1 commit into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions examples/step_dm_control_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
"""Example of how to load, step, and visualize an environment.

This example requires that garage[dm_control] be installed.
"""
from garage.envs.dm_control import DmControlEnv

# Construct the environment
env = DmControlEnv.from_suite('walker', 'run')

# Reset the environment and launch the viewer
env.reset()
env.render()

# Step randomly until interrupted
try:
print('Press Ctrl-C to stop...')
while True:
env.step(env.action_space.sample())
env.render()
except KeyboardInterrupt:
print('Exiting...')
env.close()
4 changes: 2 additions & 2 deletions examples/step_env.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python3
"""Example of how to load, step, and visualize an environment."""
from garage.envs.dm_control import DmControlEnv
import gym

# Construct the environment
env = DmControlEnv.from_suite('walker', 'run')
env = gym.make('MountainCar-v0')

# Reset the environment and launch the viewer
env.reset()
Expand Down
14 changes: 9 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
'click',
'cloudpickle',
'cma==1.1.06',
# dm_control throws an error during install about not being able to
# find a build dependency (absl-py). Later pip executes the `install`
# command again and the install succeeds because absl-py has been
# installed. This is stupid, but harmless.
'dm_control @ https://api.github.com/repos/deepmind/dm_control/tarball/7a36377879c57777e5d5b4da5aae2cd2a29b607a', # noqa: E501
'dowel==0.0.2',
'gym[all]==0.12.4',
'joblib<0.13,>=0.12',
Expand All @@ -48,6 +43,15 @@

# Dependencies for optional features
extras = {}

extras['dm_control'] = [
# dm_control throws an error during install about not being able to
# find a build dependency (absl-py). Later pip executes the `install`
# command again and the install succeeds because absl-py has been
# installed. This is stupid, but harmless.
'dm_control @ https://api.github.com/repos/deepmind/dm_control/tarball/7a36377879c57777e5d5b4da5aae2cd2a29b607a', # noqa: E501
]

extras['all'] = list(set(sum(extras.values(), [])))

# Intel dependencies not included in all
Expand Down
6 changes: 6 additions & 0 deletions src/garage/envs/dm_control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

See https://github.com/deepmind/dm_control
"""
try:
import dm_control # noqa: F401
except ImportError:
raise ImportError("To use garage's dm_control wrappers, please install "
'garage[dm_control].')

from garage.envs.dm_control.dm_control_viewer import DmControlViewer
from garage.envs.dm_control.dm_control_env import DmControlEnv # noqa: I100

Expand Down