Skip to content

Commit 675f0d9

Browse files
committed
Update
[ghstack-poisoned]
1 parent ba0f221 commit 675f0d9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

torchrl/envs/transforms/ray_service.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,27 @@ def _create_actor(self, **kwargs):
160160

161161
@property
162162
def _ray(self):
163+
ray = self.__dict__.get("_ray_val", None)
164+
if ray is not None:
165+
return ray
163166
# Import ray here to avoid requiring it as a dependency
164167
try:
165168
import ray
166169
except ImportError:
167170
raise ImportError(
168171
"Ray is required for RayTransform. Install with: pip install ray"
169172
)
173+
self.__dict__["_ray_val"] = ray
170174
return ray
171175

172176
@_ray.setter
173177
def _ray(self, value):
174-
self._ray = value
178+
self.__dict__["_ray_val"] = value
179+
180+
def __getstate__(self):
181+
state = super().__getstate__()
182+
state.pop("_ray_val", None)
183+
return state
175184

176185
def __init__(
177186
self,

0 commit comments

Comments
 (0)