unienv 0.0.1b5__tar.gz → 0.0.1b7__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 (110) hide show
  1. {unienv-0.0.1b5/unienv.egg-info → unienv-0.0.1b7}/PKG-INFO +3 -2
  2. {unienv-0.0.1b5 → unienv-0.0.1b7}/pyproject.toml +3 -2
  3. {unienv-0.0.1b5 → unienv-0.0.1b7/unienv.egg-info}/PKG-INFO +3 -2
  4. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv.egg-info/SOURCES.txt +9 -0
  5. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv.egg-info/requires.txt +2 -1
  6. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/base/common.py +25 -10
  7. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/batches/backend_compat.py +1 -1
  8. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/batches/combined_batch.py +1 -1
  9. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/replay_buffer/replay_buffer.py +51 -8
  10. unienv-0.0.1b7/unienv_data/storages/_episode_storage.py +438 -0
  11. unienv-0.0.1b7/unienv_data/storages/_list_storage.py +136 -0
  12. unienv-0.0.1b7/unienv_data/storages/backend_compat.py +268 -0
  13. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/storages/flattened.py +3 -3
  14. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/storages/hdf5.py +7 -2
  15. unienv-0.0.1b7/unienv_data/storages/image_storage.py +144 -0
  16. unienv-0.0.1b7/unienv_data/storages/npz_storage.py +135 -0
  17. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/storages/pytorch.py +16 -9
  18. unienv-0.0.1b7/unienv_data/storages/video_storage.py +297 -0
  19. unienv-0.0.1b7/unienv_data/third_party/tensordict/memmap_tensor.py +1174 -0
  20. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/transformations/image_compress.py +81 -18
  21. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/space_utils/batch_utils.py +5 -1
  22. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/spaces/dict.py +6 -0
  23. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/transformations/__init__.py +3 -1
  24. unienv-0.0.1b7/unienv_interface/transformations/batch_and_unbatch.py +75 -0
  25. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/transformations/chained_transform.py +9 -8
  26. unienv-0.0.1b7/unienv_interface/transformations/crop.py +69 -0
  27. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/transformations/dict_transform.py +8 -2
  28. unienv-0.0.1b7/unienv_interface/transformations/identity.py +16 -0
  29. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/transformations/rescale.py +24 -5
  30. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/wrapper/backend_compat.py +1 -1
  31. unienv-0.0.1b5/unienv_interface/transformations/batch_and_unbatch.py +0 -36
  32. {unienv-0.0.1b5 → unienv-0.0.1b7}/LICENSE +0 -0
  33. {unienv-0.0.1b5 → unienv-0.0.1b7}/README.md +0 -0
  34. {unienv-0.0.1b5 → unienv-0.0.1b7}/setup.cfg +0 -0
  35. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv.egg-info/dependency_links.txt +0 -0
  36. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv.egg-info/top_level.txt +0 -0
  37. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/__init__.py +0 -0
  38. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/base/__init__.py +0 -0
  39. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/base/storage.py +0 -0
  40. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/batches/__init__.py +0 -0
  41. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/batches/framestack_batch.py +0 -0
  42. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/batches/slicestack_batch.py +0 -0
  43. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/batches/transformations.py +0 -0
  44. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/integrations/pytorch.py +0 -0
  45. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/replay_buffer/__init__.py +0 -0
  46. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/replay_buffer/trajectory_replay_buffer.py +0 -0
  47. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/samplers/__init__.py +0 -0
  48. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/samplers/multiprocessing_sampler.py +0 -0
  49. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/samplers/step_sampler.py +0 -0
  50. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/storages/dict_storage.py +0 -0
  51. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_data/storages/transformation.py +0 -0
  52. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/__init__.py +0 -0
  53. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/backends/__init__.py +0 -0
  54. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/backends/base.py +0 -0
  55. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/backends/jax.py +0 -0
  56. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/backends/numpy.py +0 -0
  57. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/backends/pytorch.py +0 -0
  58. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/backends/serialization.py +0 -0
  59. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/env_base/__init__.py +0 -0
  60. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/env_base/env.py +0 -0
  61. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/env_base/funcenv.py +0 -0
  62. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/env_base/funcenv_wrapper.py +0 -0
  63. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/env_base/vec_env.py +0 -0
  64. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/env_base/wrapper.py +0 -0
  65. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/func_wrapper/__init__.py +0 -0
  66. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/func_wrapper/frame_stack.py +0 -0
  67. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/func_wrapper/transformation.py +0 -0
  68. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/__init__.py +0 -0
  69. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/space.py +0 -0
  70. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/space_utils/__init__.py +0 -0
  71. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/space_utils/construct_utils.py +0 -0
  72. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/space_utils/flatten_utils.py +0 -0
  73. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/space_utils/gym_utils.py +0 -0
  74. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/space_utils/serialization_utils.py +0 -0
  75. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/spaces/__init__.py +0 -0
  76. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/spaces/batched.py +0 -0
  77. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/spaces/binary.py +0 -0
  78. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/spaces/box.py +0 -0
  79. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/spaces/dynamic_box.py +0 -0
  80. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/spaces/graph.py +0 -0
  81. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/spaces/text.py +0 -0
  82. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/spaces/tuple.py +0 -0
  83. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/space/spaces/union.py +0 -0
  84. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/transformations/filter_dict.py +0 -0
  85. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/transformations/image_resize.py +0 -0
  86. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/transformations/iter_transform.py +0 -0
  87. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/transformations/transformation.py +0 -0
  88. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/utils/control_util.py +0 -0
  89. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/utils/framestack_queue.py +0 -0
  90. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/utils/seed_util.py +0 -0
  91. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/utils/stateclass.py +0 -0
  92. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/utils/symbol_util.py +0 -0
  93. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/utils/vec_util.py +0 -0
  94. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/world/__init__.py +0 -0
  95. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/world/combined_funcnode.py +0 -0
  96. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/world/combined_node.py +0 -0
  97. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/world/funcnode.py +0 -0
  98. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/world/funcworld.py +0 -0
  99. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/world/node.py +0 -0
  100. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/world/world.py +0 -0
  101. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/wrapper/__init__.py +0 -0
  102. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/wrapper/action_rescale.py +0 -0
  103. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/wrapper/batch_and_unbatch.py +0 -0
  104. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/wrapper/control_frequency_limit.py +0 -0
  105. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/wrapper/flatten.py +0 -0
  106. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/wrapper/frame_stack.py +0 -0
  107. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/wrapper/gym_compat.py +0 -0
  108. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/wrapper/time_limit.py +0 -0
  109. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/wrapper/transformation.py +0 -0
  110. {unienv-0.0.1b5 → unienv-0.0.1b7}/unienv_interface/wrapper/video_record.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unienv
3
- Version: 0.0.1b5
3
+ Version: 0.0.1b7
4
4
  Summary: Unified robot environment framework supporting multiple tensor and simulation backends
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://github.com/UniEnvOrg/UniEnv
@@ -12,9 +12,10 @@ Requires-Python: >=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: numpy
15
- Requires-Dist: xbarray>=0.0.1a8
15
+ Requires-Dist: xbarray>=0.0.1a13
16
16
  Requires-Dist: pillow
17
17
  Requires-Dist: cloudpickle
18
+ Requires-Dist: pyvers
18
19
  Provides-Extra: dev
19
20
  Requires-Dist: pytest; extra == "dev"
20
21
  Provides-Extra: gymnasium
@@ -3,13 +3,14 @@ name = "unienv"
3
3
  description = "Unified robot environment framework supporting multiple tensor and simulation backends"
4
4
  readme = "README.md"
5
5
  license = "MIT"
6
- version = "0.0.1b5"
6
+ version = "0.0.1b7"
7
7
  requires-python = ">= 3.10"
8
8
  dependencies = [
9
9
  "numpy",
10
- "xbarray>=0.0.1a8",
10
+ "xbarray>=0.0.1a13",
11
11
  "pillow",
12
12
  "cloudpickle",
13
+ "pyvers",
13
14
  ]
14
15
 
15
16
  [project.optional-dependencies]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unienv
3
- Version: 0.0.1b5
3
+ Version: 0.0.1b7
4
4
  Summary: Unified robot environment framework supporting multiple tensor and simulation backends
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://github.com/UniEnvOrg/UniEnv
@@ -12,9 +12,10 @@ Requires-Python: >=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: numpy
15
- Requires-Dist: xbarray>=0.0.1a8
15
+ Requires-Dist: xbarray>=0.0.1a13
16
16
  Requires-Dist: pillow
17
17
  Requires-Dist: cloudpickle
18
+ Requires-Dist: pyvers
18
19
  Provides-Extra: dev
19
20
  Requires-Dist: pytest; extra == "dev"
20
21
  Provides-Extra: gymnasium
@@ -23,11 +23,18 @@ unienv_data/replay_buffer/trajectory_replay_buffer.py
23
23
  unienv_data/samplers/__init__.py
24
24
  unienv_data/samplers/multiprocessing_sampler.py
25
25
  unienv_data/samplers/step_sampler.py
26
+ unienv_data/storages/_episode_storage.py
27
+ unienv_data/storages/_list_storage.py
28
+ unienv_data/storages/backend_compat.py
26
29
  unienv_data/storages/dict_storage.py
27
30
  unienv_data/storages/flattened.py
28
31
  unienv_data/storages/hdf5.py
32
+ unienv_data/storages/image_storage.py
33
+ unienv_data/storages/npz_storage.py
29
34
  unienv_data/storages/pytorch.py
30
35
  unienv_data/storages/transformation.py
36
+ unienv_data/storages/video_storage.py
37
+ unienv_data/third_party/tensordict/memmap_tensor.py
31
38
  unienv_data/transformations/image_compress.py
32
39
  unienv_interface/__init__.py
33
40
  unienv_interface/backends/__init__.py
@@ -66,8 +73,10 @@ unienv_interface/space/spaces/union.py
66
73
  unienv_interface/transformations/__init__.py
67
74
  unienv_interface/transformations/batch_and_unbatch.py
68
75
  unienv_interface/transformations/chained_transform.py
76
+ unienv_interface/transformations/crop.py
69
77
  unienv_interface/transformations/dict_transform.py
70
78
  unienv_interface/transformations/filter_dict.py
79
+ unienv_interface/transformations/identity.py
71
80
  unienv_interface/transformations/image_resize.py
72
81
  unienv_interface/transformations/iter_transform.py
73
82
  unienv_interface/transformations/rescale.py
@@ -1,7 +1,8 @@
1
1
  numpy
2
- xbarray>=0.0.1a8
2
+ xbarray>=0.0.1a13
3
3
  pillow
4
4
  cloudpickle
5
+ pyvers
5
6
 
6
7
  [dev]
7
8
  pytest
@@ -7,6 +7,7 @@ from unienv_interface.env_base.env import ContextType, ObsType, ActType
7
7
  from unienv_interface.space import Space, BoxSpace, DictSpace
8
8
  import dataclasses
9
9
 
10
+ from functools import cached_property
10
11
  from unienv_interface.space.space_utils import batch_utils as space_batch_utils, flatten_utils as space_flatten_utils
11
12
 
12
13
  __all__ = [
@@ -46,13 +47,18 @@ class BatchBase(abc.ABC, Generic[BatchT, BArrayType, BDeviceType, BDtypeType, BR
46
47
  ):
47
48
  self.single_space = single_space
48
49
  self.single_metadata_space = single_metadata_space
49
- self._batched_space : Space[BatchT, BDeviceType, BDtypeType, BRNGType] = space_batch_utils.batch_space(single_space, 1)
50
- if single_metadata_space is not None:
51
- self._batched_metadata_space : DictSpace[
52
- BDeviceType, BDtypeType, BRNGType
53
- ] = space_batch_utils.batch_space(single_metadata_space, 1)
50
+
51
+ # For backwards compatibility
52
+ @cached_property
53
+ def _batched_space(self) -> Space[BatchT, BDeviceType, BDtypeType, BRNGType]:
54
+ return space_batch_utils.batch_space(self.single_space, 1)
55
+
56
+ @cached_property
57
+ def _batched_metadata_space(self) -> Optional[DictSpace[BDeviceType, BDtypeType, BRNGType]]:
58
+ if self.single_metadata_space is not None:
59
+ return space_batch_utils.batch_space(self.single_metadata_space, 1)
54
60
  else:
55
- self._batched_metadata_space = None
61
+ return None
56
62
 
57
63
  @property
58
64
  def backend(self) -> ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType]:
@@ -146,7 +152,7 @@ class BatchBase(abc.ABC, Generic[BatchT, BArrayType, BDeviceType, BDtypeType, BR
146
152
  if tqdm:
147
153
  from tqdm import tqdm
148
154
  iterable_start = tqdm(iterable_start, desc="Extending Batch")
149
- for start_idx in range(0, n_total, chunk_size):
155
+ for start_idx in iterable_start:
150
156
  end_idx = min(start_idx + chunk_size, n_total)
151
157
  data_chunk = other.get_at(slice(start_idx, end_idx))
152
158
  self.extend(data_chunk)
@@ -183,15 +189,24 @@ class BatchSampler(
183
189
  ) -> None:
184
190
  super().__init__(single_space=single_space, single_metadata_space=single_metadata_space)
185
191
  self.batch_size = batch_size
186
- self._batched_space : Space[SamplerBatchT, SamplerDeviceType, SamplerDtypeType, SamplerRNGType] = space_batch_utils.batch_space(self.single_space, batch_size)
187
- self._batched_metadata_space : Optional[DictSpace[SamplerDeviceType, SamplerDtypeType, SamplerRNGType]] = space_batch_utils.batch_space(self.single_metadata_space, batch_size) if self.single_metadata_space is not None else None
188
-
192
+
189
193
  def manual_seed(self, seed : int) -> None:
190
194
  if self.rng is not None:
191
195
  self.rng = self.backend.random.random_number_generator(seed, device=self.device)
192
196
  if self.data_rng is not None:
193
197
  self.data_rng = self.backend.random.random_number_generator(seed, device=self.data.device)
194
198
 
199
+ @cached_property
200
+ def _batched_space(self) -> Space[BatchT, BDeviceType, BDtypeType, BRNGType]:
201
+ return space_batch_utils.batch_space(self.single_space, self.batch_size)
202
+
203
+ @cached_property
204
+ def _batched_metadata_space(self) -> Optional[DictSpace[BDeviceType, BDtypeType, BRNGType]]:
205
+ if self.single_metadata_space is not None:
206
+ return space_batch_utils.batch_space(self.single_metadata_space, self.batch_size)
207
+ else:
208
+ return None
209
+
195
210
  @property
196
211
  def sampled_space(self) -> Space[SamplerBatchT, SamplerDeviceType, SamplerDtypeType, SamplerRNGType]:
197
212
  return self._batched_space
@@ -36,7 +36,7 @@ def data_to(
36
36
  key: data_to(value, source_backend, target_backend, target_device)
37
37
  for key, value in data.items()
38
38
  }
39
- elif isinstance(data, Sequence):
39
+ elif isinstance(data, Sequence) and not isinstance(data, (str, bytes)):
40
40
  data = [
41
41
  data_to(value, source_backend, target_backend, target_device)
42
42
  for value in data
@@ -94,7 +94,7 @@ class CombinedBatch(BatchBase[
94
94
  batch_index = int(self.backend.sum(
95
95
  idx >= self.index_caches[:, 0]
96
96
  ) - 1)
97
- return batch_index, idx - self.index_caches[batch_index, 0]
97
+ return batch_index, idx - int(self.index_caches[batch_index, 0])
98
98
 
99
99
  def _convert_index(self, idx : Union[IndexableType, BArrayType]) -> Tuple[
100
100
  int,
@@ -2,6 +2,7 @@ import abc
2
2
  import os
3
3
  import dataclasses
4
4
  import multiprocessing as mp
5
+ import ctypes
5
6
  from contextlib import nullcontext
6
7
 
7
8
  from typing import Generic, TypeVar, Optional, Any, Dict, Union, Tuple, Sequence, Callable, Type
@@ -94,6 +95,48 @@ class ReplayBuffer(BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGTy
94
95
  metadata = json.load(f)
95
96
  return metadata.get('type', None) == __class__.__name__
96
97
  return False
98
+
99
+ @staticmethod
100
+ def get_length_from_path(
101
+ path : Union[str, os.PathLike]
102
+ ) -> Optional[int]:
103
+ if os.path.exists(os.path.join(path, "metadata.json")):
104
+ with open(os.path.join(path, "metadata.json"), "r") as f:
105
+ metadata = json.load(f)
106
+ if metadata.get('type', None) != __class__.__name__:
107
+ return None
108
+ return int(metadata["count"])
109
+ return None
110
+
111
+ @staticmethod
112
+ def get_capacity_from_path(
113
+ path : Union[str, os.PathLike]
114
+ ) -> Optional[int]:
115
+ if os.path.exists(os.path.join(path, "metadata.json")):
116
+ with open(os.path.join(path, "metadata.json"), "r") as f:
117
+ metadata = json.load(f)
118
+ if metadata.get('type', None) != __class__.__name__:
119
+ return None
120
+ return int(metadata["capacity"])
121
+ return None
122
+
123
+ @staticmethod
124
+ def get_space_from_path(
125
+ path : Union[str, os.PathLike],
126
+ *,
127
+ backend: ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType],
128
+ device: Optional[BDeviceType] = None,
129
+ ) -> Optional[Space[BatchT, BDeviceType, BDtypeType, BRNGType]]:
130
+ if os.path.exists(os.path.join(path, "metadata.json")):
131
+ with open(os.path.join(path, "metadata.json"), "r") as f:
132
+ metadata = json.load(f)
133
+ if metadata.get('type', None) != __class__.__name__:
134
+ return None
135
+ single_instance_space = bsu.json_to_space(
136
+ metadata["single_instance_space"], backend, device
137
+ )
138
+ return single_instance_space
139
+ return None
97
140
 
98
141
  @staticmethod
99
142
  def load_from(
@@ -167,11 +210,11 @@ class ReplayBuffer(BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGTy
167
210
  self._storage_path_relative = storage_path_relative
168
211
  self._cache_path = cache_path
169
212
  self._multiprocessing = multiprocessing
170
- if multiprocessing:
213
+ if multiprocessing and storage.is_mutable:
171
214
  assert storage.is_multiprocessing_safe, "Storage is not multiprocessing safe"
172
- self._lock = mp.Lock()
173
- self._count_value = mp.Value("q", int(count))
174
- self._offset_value = mp.Value("q", int(offset))
215
+ self._lock = mp.RLock()
216
+ self._count_value = mp.Value(ctypes.c_long, int(count))
217
+ self._offset_value = mp.Value(ctypes.c_long, int(offset))
175
218
  else:
176
219
  self._lock = None
177
220
  self._count_value = int(count)
@@ -201,22 +244,22 @@ class ReplayBuffer(BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGTy
201
244
 
202
245
  @property
203
246
  def count(self) -> int:
204
- return self._count_value.value if self._multiprocessing else self._count_value
247
+ return self._count_value.value if not isinstance(self._count_value, int) else self._count_value
205
248
 
206
249
  @count.setter
207
250
  def count(self, value: int) -> None:
208
- if self._multiprocessing:
251
+ if not isinstance(self._count_value, int):
209
252
  self._count_value.value = int(value)
210
253
  else:
211
254
  self._count_value = int(value)
212
255
 
213
256
  @property
214
257
  def offset(self) -> int:
215
- return self._offset_value.value if self._multiprocessing else self._offset_value
258
+ return self._offset_value.value if not isinstance(self._offset_value, int) else self._offset_value
216
259
 
217
260
  @offset.setter
218
261
  def offset(self, value: int) -> None:
219
- if self._multiprocessing:
262
+ if not isinstance(self._offset_value, int):
220
263
  self._offset_value.value = int(value)
221
264
  else:
222
265
  self._offset_value = int(value)