Skip to content

Commit 5cb6b1d

Browse files
DeepMindcopybara-github
authored andcommitted
Replaced deprecated @abstractproperty decorator that was causing lint errors
Following these instructions: https://docs.python.org/3/library/abc.html#abc.abstractproperty PiperOrigin-RevId: 480906718 Change-Id: I7c9a9754a4da2c30fcc94841bf728dbb229d1b5a
1 parent 49cb4ab commit 5cb6b1d

7 files changed

Lines changed: 38 additions & 16 deletions

File tree

dm_control/_render/executor/render_executor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ def execution_context(self):
9696
def terminated(self):
9797
return self._terminated
9898

99-
@abc.abstractproperty
99+
@property
100+
@abc.abstractmethod
100101
def thread(self):
101102
pass
102103

103-
@abc.abstractproperty
104+
@property
105+
@abc.abstractmethod
104106
def _lock_if_necessary(self):
105107
pass
106108

dm_control/composer/entity.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,23 @@ def add_observable(self, name, observable, enabled=True):
172172
class FreePropObservableMixin(metaclass=abc.ABCMeta):
173173
"""Enforce observables of a free-moving object."""
174174

175-
@abc.abstractproperty
175+
@property
176+
@abc.abstractmethod
176177
def position(self):
177178
pass
178179

179-
@abc.abstractproperty
180+
@property
181+
@abc.abstractmethod
180182
def orientation(self):
181183
pass
182184

183-
@abc.abstractproperty
185+
@property
186+
@abc.abstractmethod
184187
def linear_velocity(self):
185188
pass
186189

187-
@abc.abstractproperty
190+
@property
191+
@abc.abstractmethod
188192
def angular_velocity(self):
189193
pass
190194

@@ -284,7 +288,8 @@ def after_step(self, physics, random_state):
284288
"""Callback executed after an agent control step."""
285289
pass
286290

287-
@abc.abstractproperty
291+
@property
292+
@abc.abstractmethod
288293
def mjcf_model(self):
289294
raise NotImplementedError
290295

dm_control/composer/robot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
class Robot(entity.Entity, metaclass=abc.ABCMeta):
2727
"""The abstract base class for robots."""
2828

29-
@abc.abstractproperty
29+
@property
30+
@abc.abstractmethod
3031
def actuators(self):
3132
"""Returns the actuator elements of the robot."""
3233
raise NotImplementedError

dm_control/entities/manipulators/base.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,14 @@ def set_site_to_xpos(self, physics, random_state, site, target_pos,
150150

151151
return success
152152

153-
@abc.abstractproperty
153+
@property
154+
@abc.abstractmethod
154155
def joints(self):
155156
"""Returns the joint elements of the arm."""
156157
raise NotImplementedError
157158

158-
@abc.abstractproperty
159+
@property
160+
@abc.abstractmethod
159161
def wrist_site(self):
160162
"""Returns the wrist site element of the arm."""
161163
raise NotImplementedError
@@ -188,6 +190,7 @@ def set_grasp(self, physics, close_factors):
188190
number is specified, the same position is applied to all fingers.
189191
"""
190192

191-
@abc.abstractproperty
193+
@property
194+
@abc.abstractmethod
192195
def tool_center_point(self):
193196
"""Returns the tool center point element of the hand."""

dm_control/locomotion/arenas/corridors.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ class Corridor(composer.Arena, metaclass=abc.ABCMeta):
3535
def regenerate(self, random_state):
3636
raise NotImplementedError
3737

38-
@abc.abstractproperty
38+
@property
39+
@abc.abstractmethod
3940
def corridor_length(self):
4041
raise NotImplementedError
4142

42-
@abc.abstractproperty
43+
@property
44+
@abc.abstractmethod
4345
def corridor_width(self):
4446
raise NotImplementedError
4547

46-
@abc.abstractproperty
48+
@property
49+
@abc.abstractmethod
4750
def ground_geoms(self):
4851
raise NotImplementedError
4952

@@ -175,6 +178,7 @@ def ground_geoms(self):
175178
class GapsCorridor(EmptyCorridor):
176179
"""A corridor that consists of multiple platforms separated by gaps."""
177180

181+
# pylint: disable=arguments-renamed
178182
def _build(self,
179183
platform_length=1.,
180184
gap_length=2.5,
@@ -236,6 +240,8 @@ def _build(self,
236240

237241
self._ground_body = self._mjcf_root.worldbody.add('body', name='ground')
238242

243+
# pylint: enable=arguments-renamed
244+
239245
def regenerate(self, random_state):
240246
"""Regenerates this corridor.
241247
@@ -334,6 +340,7 @@ def ground_geoms(self):
334340
class WallsCorridor(EmptyCorridor):
335341
"""A corridor obstructed by multiple walls aligned against the two sides."""
336342

343+
# pylint: disable=arguments-renamed
337344
def _build(self,
338345
wall_gap=2.5,
339346
wall_width=2.5,
@@ -382,6 +389,8 @@ def _build(self,
382389
self._swap_wall_side = swap_wall_side
383390
self._include_initial_padding = include_initial_padding
384391

392+
# pylint: enable=arguments-renamed
393+
385394
def regenerate(self, random_state):
386395
"""Regenerates this corridor.
387396

dm_control/locomotion/tasks/reference_pose/tracking.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,8 @@ def action_spec(self, physics: 'mjcf.Physics'):
800800
name='\t'.join(actuator.full_identifier # pytype: disable=attribute-error
801801
for actuator in self._walker.actuators))
802802

803-
@abc.abstractproperty
803+
@property
804+
@abc.abstractmethod
804805
def name(self):
805806
raise NotImplementedError
806807

dm_control/locomotion/walkers/cmu_humanoid.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ def _build(self,
235235
def _build_observables(self):
236236
return CMUHumanoidObservables(self)
237237

238-
@abc.abstractproperty
238+
@property
239+
@abc.abstractmethod
239240
def _xml_path(self):
240241
raise NotImplementedError
241242

0 commit comments

Comments
 (0)