Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion dm_control/locomotion/mocap/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@
import numpy as np


def _is_repeated_field(field):
"""Returns whether a proto field is repeated, across protobuf versions.

`FieldDescriptor.label` was removed in protobuf 7.x in favor of
`is_repeated`, which is only available from protobuf 5.29 onwards.
"""
if hasattr(field, 'is_repeated'):
return field.is_repeated
return field.label == descriptor.FieldDescriptor.LABEL_REPEATED


class TrajectoryLoader(metaclass=abc.ABCMeta):
"""Base class for helpers that load and decode mocap trajectories."""

Expand Down Expand Up @@ -106,7 +117,7 @@ def _fill_primitive_proto_fields(self, proto, h5_group, skip_fields=()):
continue
elif field.type not in (descriptor.FieldDescriptor.TYPE_GROUP,
descriptor.FieldDescriptor.TYPE_MESSAGE):
if field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
if _is_repeated_field(field):
getattr(proto, field.name).extend(h5_group.attrs[field.name])
else:
setattr(proto, field.name, h5_group.attrs[field.name])
Expand Down
2 changes: 1 addition & 1 deletion dm_control/locomotion/mocap/loader_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def assert_proto_equal(self, x, y, msg=''):
for field in x.DESCRIPTOR.fields:
x_field = getattr(x, field.name)
y_field = getattr(y, field.name)
if field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
if loader._is_repeated_field(field):
if field.type == descriptor.FieldDescriptor.TYPE_MESSAGE:
for i, (x_child, y_child) in enumerate(zip(x_field, y_field)):
self.assert_proto_equal(
Expand Down
12 changes: 8 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
absl-py==2.3.1
dm-env==1.6
dm-tree==0.1.9
dm-tree==0.1.10; python_version >= '3.14'
dm-tree==0.1.9; python_version < '3.14'
glfw==2.9.0
h5py==3.14.0
labmaze==1.0.6
h5py==3.16.0; python_version >= '3.14'
h5py==3.14.0; python_version < '3.14'
labmaze @ git+https://github.com/echen01/labmaze.git; python_version >= '3.14'
labmaze==1.0.6; python_version < '3.14'
lxml==6.0.1
mock==5.2.0
mujoco==3.9.0
numpy==2.3.2; python_version >= '3.11'
numpy==2.2.6; python_version == '3.10'
numpy==2.0.2; python_version == '3.9'
pillow==11.3.0
protobuf==3.19.4
protobuf==7.35.0; python_version >= '3.14'
protobuf==3.19.4; python_version < '3.14'
pyopengl==3.1.10
pyparsing==3.2.3
pytest==8.4.1
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ def is_excluded(s):
'dm-env',
'dm-tree != 0.1.2',
'glfw',
'labmaze',
# Upstream labmaze has no Python 3.14 wheels and its sdist requires
# Bazel; this fork builds with just pip and a C++17 compiler.
'labmaze @ git+https://github.com/echen01/labmaze.git ; python_version >= "3.14"',
'labmaze ; python_version < "3.14"',
'lxml',
'mujoco >= 3.9.0',
'numpy >= 1.9.0',
Expand Down