JingsongLi commented on code in PR #9529:
URL: https://github.com/apache/paimon/pull/9529#discussion_r3913666862
##########
paimon-python/pypaimon/multimodal/lerobot/loader.py:
##########
@@ -147,7 +173,96 @@ def _episode_batches(dataset, info, batch_size):
% (expected_begin, total_frames))
-def _read_batch(dataset, info, begin, end, schema):
+def _validate_frame_controls(
+ batch,
+ fps,
+ episode_index,
+ episode_begin,
+ begin,
+ task_indices):
+ required = [
+ "index", "episode_index", "frame_index", "timestamp", "task_index"
+ ]
+ missing = [name for name in required if name not in batch.column_names]
+ if missing:
+ raise ValueError(
+ "LeRobot frame data is missing control columns: %s."
+ % ", ".join(missing))
+
+ allowed_tasks = set(task_indices)
+ values = {
+ name: batch.column(name).to_pylist()
+ for name in required
+ }
+ seen_tasks = set()
+ for offset in range(batch.num_rows):
+ index = begin + offset
+ frame_index = index - episode_begin
+ _require_control_integer(
+ values["index"][offset], "index", index, index)
+ _require_control_integer(
+ values["episode_index"][offset],
+ "episode_index",
+ episode_index,
+ index,
+ )
+ _require_control_integer(
+ values["frame_index"][offset],
+ "frame_index",
+ frame_index,
+ index,
+ )
+ timestamp = values["timestamp"][offset]
+ if (isinstance(timestamp, bool)
+ or not isinstance(timestamp, numbers.Real)
+ or not math.isclose(
+ float(timestamp), frame_index / fps,
+ rel_tol=0.0, abs_tol=1e-4)):
Review Comment:
LeRobot stores `timestamp` as `float32`, so this fixed absolute tolerance
can reject valid long episodes as the float32 ULP grows. For example, at 30
FPS, `frame_index = 61,441` is stored as `2048.033447265625`, while
`frame_index / fps` is `2048.0333333333333`; the error is about `1.14e-4`, so
this check fails for otherwise valid LeRobot data. Please compare against an
expected value quantized to the declared Arrow dtype, or use a dtype/ULP-aware
tolerance.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]