Skip to content

fix(rollout): accept a sequence of MjData, not only a list - #3818

Merged
copybara-service[bot] merged 1 commit into
google-deepmind:mainfrom
zhengqiuyang:fix/rollout-sequence-data
Nov 21, 2026
Merged

copybara-service[bot] merged 1 commit into
google-deepmind:mainfrom
zhengqiuyang:fix/rollout-sequence-data

Conversation

@zhengqiuyang

Copy link
Copy Markdown
Contributor

Fixes #3817.

rollout.rollout and Rollout.rollout accept Union[mujoco.MjData, Sequence[mujoco.MjData]]
in their signatures and docstrings, but they only recognised list and wrapped every other
value in a one-element list. A tuple of MjData therefore reached pybind11 as a tuple and
failed with RuntimeError: Unable to cast Python instance of type <class 'tuple'>.

Only a bare MjData is the single-instance case now; any other sequence is used as given.

Tests

New test_data_accepts_a_sequence runs the same rollout with a list and with a tuple and
compares both outputs.

  • On main: the new test fails with the cast error.
  • With the change: rollout_test.py 70 passed, 1 skipped.

The signature and the docstring of rollout() and Rollout.rollout() accept Sequence[MjData], but the implementation only recognised list and wrapped anything else in a one-element list. A tuple therefore reached pybind11 as a tuple of MjData and failed with an opaque cast error. Treat only a bare MjData as the single-instance case and keep every other sequence as is.

Signed-off-by: 郑润泽 <[email protected]>
@copybara-service
copybara-service Bot merged commit 58a0597 into google-deepmind:main Nov 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python] rollout rejects a tuple of MjData although its signature accepts a Sequence

1 participant