forked from openai/universe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Revert "remove unused i parameter from WeakUnvectorize" This reverts commit 1825ecf. * Add todo * Add Monitored wrapper * Use MonitorManager * Monitored -> Monitor * Finish Monitored -> Monitor * use gym 0.6.0 * Bump universe version * Bump gym version * bump gym * Remove pyc files * Move Monitor from vectorized to wrappers module * Fix import * Force go_vncdriver * Clean up comments * Move monitor start to configure
- Loading branch information
1 parent
e2d005e
commit f637b07
Showing
11 changed files
with
88 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import logging | ||
|
||
from gym import monitoring | ||
from universe.vectorized import core # Cannot import vectorized directly without inducing a cycle | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
def Monitor(directory, video_callable=None, force=False, resume=False, | ||
write_upon_reset=False, uid=None, mode=None): | ||
class Monitor(core.Wrapper): | ||
def _configure(self, **kwargs): | ||
super(Monitor, self)._configure(**kwargs) | ||
|
||
# We have to wait until configure to set the monitor because we need the number of instances in a vectorized env | ||
self._start_monitor() | ||
|
||
def _start_monitor(self): | ||
# Circular dependencies :( | ||
from universe import wrappers | ||
# We need to maintain pointers to these to avoid them being | ||
# GC'd. They have a weak reference to us to avoid cycles. | ||
self._unvectorized_envs = [wrappers.WeakUnvectorize(self, i) for i in range(self.n)] | ||
|
||
# For now we only monitor the first env | ||
self._monitor = monitoring.MonitorManager(self._unvectorized_envs[0]) | ||
self._monitor.start(directory, video_callable, force, resume, | ||
write_upon_reset, uid, mode) | ||
|
||
def _step(self, action_n): | ||
self._monitor._before_step(action_n[0]) | ||
observation_n, reward_n, done_n, info = self.env.step(action_n) | ||
done_n[0] = self._monitor._after_step(observation_n[0], reward_n[0], done_n[0], info) | ||
return observation_n, reward_n, done_n, info | ||
|
||
def _reset(self): | ||
self._monitor._before_reset() | ||
observation_n = self.env.reset() | ||
self._monitor._after_reset(observation_n[0]) | ||
return observation_n | ||
|
||
def _close(self): | ||
super(Monitor, self)._close() | ||
self._monitor.close() | ||
|
||
def set_monitor_mode(self, mode): | ||
logger.info("Setting the monitor mode is deprecated and will be removed soon") | ||
self._monitor._set_mode(mode) | ||
|
||
return Monitor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters