env-ssl-wrapper 0.4.6__tar.gz → 0.4.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/PKG-INFO +2 -2
  2. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/README.md +1 -1
  3. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/action_chunk.py +12 -1
  4. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/pyproject.toml +1 -1
  5. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/.gitignore +0 -0
  6. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/LICENSE +0 -0
  7. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/__init__.py +0 -0
  8. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/memory_trace.py +0 -0
  9. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/__init__.py +0 -0
  10. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/action_transform_wrapper.py +0 -0
  11. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/adapters.py +0 -0
  12. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/auto_batched_wrapper.py +0 -0
  13. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/done_tracker_wrapper.py +0 -0
  14. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/episode_padding_wrapper.py +0 -0
  15. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/flatten_obs_wrapper.py +0 -0
  16. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/helpers.py +0 -0
  17. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/image_wrapper.py +0 -0
  18. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/mocks.py +0 -0
  19. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/spaces.py +0 -0
  20. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/standardize_env_wrapper.py +0 -0
  21. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/standardize_wrapper.py +0 -0
  22. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/tensor_wrapper.py +0 -0
  23. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/time_limit_wrapper.py +0 -0
  24. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/utils.py +0 -0
  25. {env_ssl_wrapper-0.4.6 → env_ssl_wrapper-0.4.7}/env_ssl_wrapper/standardize/vector.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: env-ssl-wrapper
3
- Version: 0.4.6
3
+ Version: 0.4.7
4
4
  Summary: One torch-native interface for any MDP environment
5
5
  Project-URL: Homepage, https://pypi.org/project/env-ssl-wrapper/
6
6
  Project-URL: Repository, https://codeberg.org/lucidrains/env-ssl-wrapper
@@ -161,7 +161,7 @@ while True:
161
161
  obs, info = env.reset()
162
162
  ```
163
163
 
164
- Chunks are shaped `(num_envs, chunk_len, *action_shape)` (`(num_envs, chunk_len)` for discrete actions).
164
+ Chunks are shaped `(num_envs, chunk_len, *action_shape)` (`(num_envs, chunk_len)` for discrete actions). The wrapper can also be applied directly to raw gymnasium environments, single or vectorized — torch action chunks are converted to numpy for the underlying simulator.
165
165
 
166
166
  Execution stops early the moment any env terminates or truncates mid-chunk — the terminal state and done flags of that substep are returned and the rest of the chunk is dropped, so a new episode is never silently advanced.
167
167
 
@@ -98,7 +98,7 @@ while True:
98
98
  obs, info = env.reset()
99
99
  ```
100
100
 
101
- Chunks are shaped `(num_envs, chunk_len, *action_shape)` (`(num_envs, chunk_len)` for discrete actions).
101
+ Chunks are shaped `(num_envs, chunk_len, *action_shape)` (`(num_envs, chunk_len)` for discrete actions). The wrapper can also be applied directly to raw gymnasium environments, single or vectorized — torch action chunks are converted to numpy for the underlying simulator.
102
102
 
103
103
  Execution stops early the moment any env terminates or truncates mid-chunk — the terminal state and done flags of that substep are returned and the rest of the chunk is dropped, so a new episode is never silently advanced.
104
104
 
@@ -11,8 +11,10 @@ from .standardize.helpers import (
11
11
  default,
12
12
  any_true,
13
13
  dones_of,
14
+ first_existing,
14
15
  get_attr,
15
16
  is_vectorized,
17
+ to_numpy,
16
18
  )
17
19
 
18
20
  # helpers
@@ -62,9 +64,13 @@ class ActionChunkWrapper(EnvWrapper):
62
64
  self.gamma = float(gamma)
63
65
  self.reward_mode = reward_mode
64
66
 
65
- action_space = get_attr(env, 'action_space')
67
+ # vectorized gym envs expose a batched action space - the single env space defines the chunk layout
68
+
69
+ action_space = first_existing(env, 'single_action_space', 'action_space')
66
70
  self.action_shape = tuple(get_attr(action_space, 'shape', ()) or ())
71
+
67
72
  self.expects_batch = is_vectorized(env)
73
+ self.raw_env = not isinstance(env, EnvWrapper)
68
74
 
69
75
  @property
70
76
  def chunk_action_shape(self):
@@ -80,6 +86,11 @@ class ActionChunkWrapper(EnvWrapper):
80
86
  if not (is_tensor(actions) or isinstance(actions, np.ndarray)):
81
87
  actions = np.asarray(actions)
82
88
 
89
+ # raw simulators only understand numpy - wrapper chains from this package handle torch actions
90
+
91
+ if self.raw_env and is_tensor(actions):
92
+ actions = to_numpy(actions)
93
+
83
94
  chunk_axis = actions.ndim - 1 - len(self.action_shape)
84
95
 
85
96
  assert chunk_axis >= 1, (
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "env-ssl-wrapper"
3
- version = "0.4.6"
3
+ version = "0.4.7"
4
4
  description = "One torch-native interface for any MDP environment"
5
5
  authors = [
6
6
  { name = "Phil Wang", email = "lucidrains@gmail.com" }
File without changes