This is an automated email from the ASF dual-hosted git repository.

JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 96b84c2fd1 [Python] Avoid unused tensor conversions in LeRobot windows 
(#10704)
96b84c2fd1 is described below

commit 96b84c2fd116d787ad70038edf5b54c3e29cf826
Author: XiaoHongbo <[email protected]>
AuthorDate: Wed Oct 21 15:31:30 2026 +0800

    [Python] Avoid unused tensor conversions in LeRobot windows (#10704)
---
 paimon-python/pypaimon/multimodal/lerobot/dataset.py |  5 ++++-
 .../pypaimon/tests/multimodal_lerobot_test.py        | 20 +++++++++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/paimon-python/pypaimon/multimodal/lerobot/dataset.py 
b/paimon-python/pypaimon/multimodal/lerobot/dataset.py
index 38793e26da..22a0fb65c9 100644
--- a/paimon-python/pypaimon/multimodal/lerobot/dataset.py
+++ b/paimon-python/pypaimon/multimodal/lerobot/dataset.py
@@ -460,9 +460,12 @@ class PaimonDatasetReader(ABC):
                 row, self._features, self.return_uint8)
             for position, row in base_rows.items()
         }
+        window_keys = {key for plan in plans for key in plan["windows"]}
         converted.update({
             position: _torch_row(
-                row, self._features, self.return_uint8)
+                {key: value for key, value in row.items()
+                 if key in window_keys},
+                self._features, self.return_uint8)
             for position, row in delta_rows.items()
         })
 
diff --git a/paimon-python/pypaimon/tests/multimodal_lerobot_test.py 
b/paimon-python/pypaimon/tests/multimodal_lerobot_test.py
index a9eb32ef00..e3cfc4f6da 100644
--- a/paimon-python/pypaimon/tests/multimodal_lerobot_test.py
+++ b/paimon-python/pypaimon/tests/multimodal_lerobot_test.py
@@ -990,7 +990,12 @@ class LeRobotValidationTest(unittest.TestCase):
         self.assertEqual(_schema_from_info(info), dataset.reader.schema)
         self.assertIsNone(dataset.reader.absolute_to_relative_idx)
         self.assertTrue(repr(dataset).startswith("PaimonLeRobotDataset("))
-        sample, _ = dataset.__getitems__([1, 2])
+        with patch(
+                "pypaimon.multimodal.lerobot.dataset._torch_row",
+                wraps=_torch_row) as convert:
+            sample, _ = dataset.__getitems__([1, 2])
+        self.assertEqual(3, convert.call_count)
+        self.assertEqual({"action"}, set(convert.call_args_list[-1][0][0]))
 
         self.assertEqual([((0, 1, 2), tuple(info["features"]))],
                          reader.calls)
@@ -1010,6 +1015,19 @@ class LeRobotValidationTest(unittest.TestCase):
             batch_size=2, shuffle=False, num_workers=0)))
         self.assertEqual([0, 1], batch["index"].tolist())
         self.assertEqual([2, 3], list(batch["action"].shape))
+        control_reader = Reader(
+            metadata,
+            delta_timestamps={"timestamp": [-0.1, 0.0, 0.1]},
+        )
+        torch.testing.assert_close(
+            control_reader[1]["timestamp"], torch.tensor([0.0, 0.1, 0.2]))
+        control_reader.close()
+        rows[0]["episode_index"] = 1
+        try:
+            with self.assertRaisesRegex(ValueError, "episode_index"):
+                dataset[1]
+        finally:
+            rows[0]["episode_index"] = 0
         with self.assertRaisesRegex(ValueError, "manages collate_fn"):
             dataset.to_dataloader(batch_size=2, collate_fn=lambda rows: rows)
         dataset.return_uint8 = True

Reply via email to