mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-22 07:02:19 +00:00
Revert wrappers to having their own monitor
Otherwise you end up with multiple calls to the same monitor at each step.
This commit is contained in:
16
gym/core.py
16
gym/core.py
@@ -86,7 +86,6 @@ class Env(object):
|
||||
def _seed(self, seed=None): return []
|
||||
|
||||
# Do not override
|
||||
_owns_monitor = True
|
||||
_owns_render = True
|
||||
|
||||
@property
|
||||
@@ -203,10 +202,9 @@ class Env(object):
|
||||
if not hasattr(self, '_closed') or self._closed:
|
||||
return
|
||||
|
||||
if self._owns_monitor:
|
||||
# Automatically close the monitor and any render window.
|
||||
if hasattr(self, '_monitor'):
|
||||
self.monitor.close()
|
||||
# Automatically close the monitor and any render window.
|
||||
if hasattr(self, '_monitor'):
|
||||
self.monitor.close()
|
||||
if self._owns_render:
|
||||
self.render(close=True)
|
||||
|
||||
@@ -310,7 +308,6 @@ class Space(object):
|
||||
return sample_n
|
||||
|
||||
class Wrapper(Env):
|
||||
_owns_monitor = False
|
||||
_owns_render = False
|
||||
|
||||
# Make sure self.env is always defined, even if things break
|
||||
@@ -330,13 +327,6 @@ class Wrapper(Env):
|
||||
self._spec = self.env.spec
|
||||
self._unwrapped = self.env.unwrapped
|
||||
|
||||
@property
|
||||
def monitor(self):
|
||||
if self._owns_monitor:
|
||||
return super(Wrapper, self).monitor
|
||||
else:
|
||||
return self.unwrapped.monitor
|
||||
|
||||
def _step(self, action):
|
||||
return self.env.step(action)
|
||||
|
||||
|
Reference in New Issue
Block a user