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

Vectorized environments #1513

Merged
merged 29 commits into from
Jun 21, 2019
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
076c0c2
Initial version of vectorized environments
tristandeleu Jun 1, 2019
9b9bcdf
Raise an exception in the main process if child process raises an exc…
tristandeleu Jun 1, 2019
7e2b853
Add list of exposed functions in vector module
tristandeleu Jun 1, 2019
48b7018
Use deepcopy instead of np.copy
tristandeleu Jun 1, 2019
2fe514d
Add documentation for vector utils
tristandeleu Jun 1, 2019
ad6b83e
Add tests for copy in AsyncVectorEnv
tristandeleu Jun 1, 2019
a1f214d
Add example in documentation for batch_space
tristandeleu Jun 1, 2019
4107861
Add cloudpickle dependency in setup.py
tristandeleu Jun 2, 2019
0184353
Fix __del__ in VectorEnv
tristandeleu Jun 2, 2019
2350b43
Check if all observation spaces are equal in AsyncVectorEnv
tristandeleu Jun 5, 2019
b0f50ef
Check if all observation spaces are equal in SyncVectorEnv
tristandeleu Jun 5, 2019
2d4b314
Fix spaces non equality in SyncVectorEnv for Python 2
tristandeleu Jun 6, 2019
71c1166
Handle None parameter in create_empty_array
tristandeleu Jun 6, 2019
5d53cc5
Fix check_observation_space with spaces equality
tristandeleu Jun 8, 2019
10bfb50
Raise an exception when operations are out of order in AsyncVectorEnv
tristandeleu Jun 8, 2019
c0edbcd
Add version requirement for cloudpickle
tristandeleu Jun 8, 2019
8d504c9
Use a state instead of binary flags in AsyncVectorEnv
tristandeleu Jun 8, 2019
55793cd
Use numpy.zeros when initializing observations in vectorized environm…
tristandeleu Jun 8, 2019
2bdfb4f
Remove poll from public API in AsyncVectorEnv
tristandeleu Jun 8, 2019
7904f20
Remove close_extras from VectorEnv
tristandeleu Jun 8, 2019
6c187dc
Add test between AsyncVectorEnv and SyncVectorEnv
tristandeleu Jun 8, 2019
3d7c3f3
Remove close in check_observation_space
tristandeleu Jun 8, 2019
c904b37
Add documentation for seed and close
tristandeleu Jun 8, 2019
aa3681b
Refactor exceptions for AsyncVectorEnv
tristandeleu Jun 18, 2019
c181a94
Close pipes if the environment raises an error
tristandeleu Jun 13, 2019
81b1bbc
Add tests for out of order operations
tristandeleu Jun 13, 2019
21685ed
Change default argument in create_empty_array to np.zeros
tristandeleu Jun 13, 2019
7db9028
Add get_attr and set_attr methods to VectorEnv
tristandeleu Jun 13, 2019
7a4efe4
Improve consistency in SyncVectorEnv
tristandeleu Jun 14, 2019
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
Prev Previous commit
Next Next commit
Remove close_extras from VectorEnv
tristandeleu committed Jun 15, 2019

Verified

This commit was signed with the committer’s verified signature.
moodysalem Moody Salem
commit 7904f203ff5f6e4f608fd966af6fb39e06645a5f
10 changes: 9 additions & 1 deletion gym/vector/async_vector_env.py
Original file line number Diff line number Diff line change
@@ -228,7 +228,13 @@ def step_wait(self, timeout=None):
return (deepcopy(self.observations) if self.copy else self.observations,
np.array(rewards), np.array(dones, dtype=np.bool_), infos)

def close_extras(self, timeout=None, terminate=False):
def close(self, timeout=None, terminate=False):
if self.closed:
return

if self.viewer is not None:
self.viewer.close()

timeout = 0 if terminate else timeout
try:
if self._state == AsyncState.WAITING_RESET:
@@ -258,6 +264,8 @@ def close_extras(self, timeout=None, terminate=False):
for process in self.processes:
process.join()

self.closed = True

def _poll(self, timeout=None):
self._assert_is_running()
if timeout is not None:
9 changes: 8 additions & 1 deletion gym/vector/sync_vector_env.py
Original file line number Diff line number Diff line change
@@ -67,10 +67,17 @@ def step(self, actions):
return (np.copy(self.observations) if self.copy else self.observations,
np.copy(self._rewards), np.copy(self._dones), infos)

def close_extras(self):
def close(self):
if self.closed:
return
if self.viewer is not None:
self.viewer.close()

for env in self.envs:
env.close()

self.closed = True

def _check_observation_spaces(self):
for env in self.envs:
if not (env.observation_space == self.single_observation_space):
11 changes: 0 additions & 11 deletions gym/vector/vector_env.py
Original file line number Diff line number Diff line change
@@ -53,17 +53,6 @@ def step(self, actions):
self.step_async(actions)
return self.step_wait()

def close_extras(self):
pass

def close(self, **kwargs):
if self.closed:
return
if self.viewer is not None:
self.viewer.close()
self.close_extras(**kwargs)
self.closed = True

def __del__(self):
if hasattr(self, 'closed'):
if not self.closed: