Skip to content

Commit 3133e99

Browse files
committed
deprecate built in wrappers for supersuit
1 parent bc76034 commit 3133e99

15 files changed

+35
-12
lines changed

gym/wrappers/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Deprecation
2+
3+
While Gym's wrappers will continue to work for the foreseeable future due to the widespread dependence on them throughout the community, we are deprecating them and encourage users to use [SuperSuit](https://github.com/PettingZoo-Team/SuperSuit) instead.
4+
5+
# Old Docs:
6+
17
# Wrappers
28

39
Wrappers are used to transform an environment in a modular way:

gym/wrappers/atari_preprocessing.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np
2-
2+
import warnings
33
import gym
44
from gym.spaces import Box
55
from gym.wrappers import TimeLimit
@@ -67,6 +67,7 @@ def __init__(
6767
)
6868
self.noop_max = noop_max
6969
assert env.unwrapped.get_action_meanings()[0] == "NOOP"
70+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
7071

7172
self.frame_skip = frame_skip
7273
self.screen_size = screen_size

gym/wrappers/clip_action.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np
2-
2+
import warnings
33
from gym import ActionWrapper
44
from gym.spaces import Box
55

@@ -9,6 +9,7 @@ class ClipAction(ActionWrapper):
99

1010
def __init__(self, env):
1111
assert isinstance(env.action_space, Box)
12+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
1213
super(ClipAction, self).__init__(env)
1314

1415
def action(self, action):

gym/wrappers/filter_observation.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import copy
2-
2+
import warnings
33
from gym import spaces
44
from gym import ObservationWrapper
55

@@ -26,6 +26,7 @@ def __init__(self, env, filter_keys=None):
2626
assert isinstance(
2727
wrapped_observation_space, spaces.Dict
2828
), "FilterObservationWrapper is only usable with dict observations."
29+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
2930

3031
observation_keys = wrapped_observation_space.spaces.keys()
3132

gym/wrappers/flatten_observation.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import gym.spaces as spaces
22
from gym import ObservationWrapper
3+
import warnings
34

45

56
class FlattenObservation(ObservationWrapper):
@@ -8,6 +9,7 @@ class FlattenObservation(ObservationWrapper):
89
def __init__(self, env):
910
super(FlattenObservation, self).__init__(env)
1011
self.observation_space = spaces.flatten_space(env.observation_space)
12+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
1113

1214
def observation(self, observation):
1315
return spaces.flatten(self.env.observation_space, observation)

gym/wrappers/frame_stack.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from collections import deque
22
import numpy as np
3-
3+
import warnings
44
from gym.spaces import Box
55
from gym import Wrapper
66

@@ -22,6 +22,7 @@ class LazyFrames(object):
2222
__slots__ = ("frame_shape", "dtype", "shape", "lz4_compress", "_frames")
2323

2424
def __init__(self, frames, lz4_compress=False):
25+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
2526
self.frame_shape = tuple(frames[0].shape)
2627
self.shape = (len(frames),) + self.frame_shape
2728
self.dtype = frames[0].dtype

gym/wrappers/gray_scale_observation.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np
2-
2+
import warnings
33
from gym.spaces import Box
44
from gym import ObservationWrapper
55

@@ -15,6 +15,7 @@ def __init__(self, env, keep_dim=False):
1515
len(env.observation_space.shape) == 3
1616
and env.observation_space.shape[-1] == 3
1717
)
18+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
1819
obs_shape = self.observation_space.shape[:2]
1920
if self.keep_dim:
2021
self.observation_space = Box(

gym/wrappers/pixel_observation.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
"""An observation wrapper that augments observations by pixel values."""
2-
31
import collections
42
from collections.abc import MutableMapping
53
import copy
6-
4+
import warnings
75
import numpy as np
86

97
from gym import spaces
@@ -54,6 +52,8 @@ def __init__(
5452
assert render_mode == "rgb_array", render_mode
5553
render_kwargs[key]["mode"] = "rgb_array"
5654

55+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
56+
5757
wrapped_observation_space = env.observation_space
5858

5959
if isinstance(wrapped_observation_space, spaces.Box):

gym/wrappers/record_episode_statistics.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import time
22
from collections import deque
3-
3+
import warnings
44
import gym
55

66

@@ -14,6 +14,7 @@ def __init__(self, env, deque_size=100):
1414
self.episode_length = 0
1515
self.return_queue = deque(maxlen=deque_size)
1616
self.length_queue = deque(maxlen=deque_size)
17+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
1718

1819
def reset(self, **kwargs):
1920
observation = super(RecordEpisodeStatistics, self).reset(**kwargs)

gym/wrappers/rescale_action.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np
2-
2+
import warnings
33
import gym
44
from gym import spaces
55

@@ -19,6 +19,7 @@ def __init__(self, env, a, b):
1919
env.action_space, spaces.Box
2020
), "expected Box action space, got {}".format(type(env.action_space))
2121
assert np.less_equal(a, b).all(), (a, b)
22+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
2223
super(RescaleAction, self).__init__(env)
2324
self.a = np.zeros(env.action_space.shape, dtype=env.action_space.dtype) + a
2425
self.b = np.zeros(env.action_space.shape, dtype=env.action_space.dtype) + b

gym/wrappers/resize_observation.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np
2-
2+
import warnings
33
from gym.spaces import Box
44
from gym import ObservationWrapper
55

@@ -12,6 +12,7 @@ def __init__(self, env, shape):
1212
if isinstance(shape, int):
1313
shape = (shape, shape)
1414
assert all(x > 0 for x in shape), shape
15+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
1516
self.shape = tuple(shape)
1617

1718
obs_shape = self.shape + self.observation_space.shape[2:]

gym/wrappers/time_aware_observation.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np
2-
2+
import warnings
33
from gym.spaces import Box
44
from gym import ObservationWrapper
55

@@ -17,6 +17,7 @@ def __init__(self, env):
1717
super(TimeAwareObservation, self).__init__(env)
1818
assert isinstance(env.observation_space, Box)
1919
assert env.observation_space.dtype == np.float32
20+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
2021
low = np.append(self.observation_space.low, 0.0)
2122
high = np.append(self.observation_space.high, np.inf)
2223
self.observation_space = Box(low, high, dtype=np.float32)

gym/wrappers/time_limit.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import gym
2+
import warnings
23

34

45
class TimeLimit(gym.Wrapper):
56
def __init__(self, env, max_episode_steps=None):
67
super(TimeLimit, self).__init__(env)
8+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
79
if max_episode_steps is None and self.env.spec is not None:
810
max_episode_steps = env.spec.max_episode_steps
911
if self.env.spec is not None:

gym/wrappers/transform_observation.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from gym import ObservationWrapper
2+
import warnings
23

34

45
class TransformObservation(ObservationWrapper):
@@ -21,6 +22,7 @@ class TransformObservation(ObservationWrapper):
2122
def __init__(self, env, f):
2223
super(TransformObservation, self).__init__(env)
2324
assert callable(f)
25+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
2426
self.f = f
2527

2628
def observation(self, observation):

gym/wrappers/transform_reward.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from gym import RewardWrapper
2+
import warnings
23

34

45
class TransformReward(RewardWrapper):
@@ -23,6 +24,7 @@ class TransformReward(RewardWrapper):
2324
def __init__(self, env, f):
2425
super(TransformReward, self).__init__(env)
2526
assert callable(f)
27+
warnings.warn("Gym\'s internal preprocessing wrappers are now deprecated. While they will continue to work for the foreseeable future, we strongly recommend using SuperSuit instead: https://github.com/PettingZoo-Team/SuperSuit")
2628
self.f = f
2729

2830
def reward(self, reward):

0 commit comments

Comments
 (0)