From 612ffe64d1b3a65939e4a43b14c4dc3f9f6a12a2 Mon Sep 17 00:00:00 2001 From: xiaohongbo Date: Sat, 5 Dec 2026 21:26:15 -0800 Subject: [PATCH] [python] Separate single-source and multi-source LeRobot readers --- docs/docs/pypaimon/lerobot.md | 20 +- paimon-python/pypaimon/multimodal/__init__.py | 2 + .../pypaimon/multimodal/lerobot/__init__.py | 2 + .../pypaimon/multimodal/lerobot/dataset.py | 190 ++++++++++++-- .../pypaimon/tests/lerobot_aggregate_test.py | 241 ++++++++++++++---- .../pypaimon/tests/multimodal_lerobot_test.py | 8 +- 6 files changed, 374 insertions(+), 89 deletions(-) diff --git a/docs/docs/pypaimon/lerobot.md b/docs/docs/pypaimon/lerobot.md index f5f9269f6589..0867f09a4bd2 100644 --- a/docs/docs/pypaimon/lerobot.md +++ b/docs/docs/pypaimon/lerobot.md @@ -192,9 +192,9 @@ conn.load_from_lerobot( ) ``` -Each source has one row in `_datasets`. Episode `stats` preserves the source -values; `_datasets.__paimon_lerobot_read_control_stats` stores derived statistics for the -combined training reader. +Each source has one row in `_datasets`. Single-source readers use its original +Dataset statistics. `PaimonMultiLeRobotDataset` provides combined metadata and +statistics for all sources; Episode `stats` preserves the source values. `dataset_name` accepts a string for one source or a list/tuple with one label per source in input order. Omitted names are null, and duplicate labels do not merge sources. [Dataset fields](#dataset-fields) describes the retained source metadata. @@ -213,10 +213,9 @@ a source vocabulary is rejected to avoid ambiguous frame IDs. Sources must share robot type and compatible definitions for common features. Each source retains its own FPS from `info`; different source frame rates are handled automatically. Use -`PaimonLeRobotDataset` to train from mixed-FPS groups. Pass `dataset_index=N` to -that reader to select the source at position `N` in UUID order; this reader -argument is not the stored UUID. Frame-rate handling is automatic and does not -require an import option. +`PaimonMultiLeRobotDataset` to train from mixed-FPS groups. For one source, use +`PaimonLeRobotDataset` with its stored `dataset_id` UUID or `dataset_index=N` +(position in UUID order). Frame-rate handling is automatic. ### Schema evolution @@ -545,15 +544,20 @@ If a source feature uses the mask name, underscores are prepended until the name For map-style training, pass an image- or video-backed table group with LeRobot Episode and Dataset companions to `PaimonLeRobotDataset`. +A group with multiple sources requires `dataset_id=""` or +`dataset_index=N`. Indices, Episode selection, and metadata stay source-local. +Use `PaimonMultiLeRobotDataset` for combined training with global indices and +merged metadata. ```python -from pypaimon.multimodal import PaimonLeRobotDataset +from pypaimon.multimodal import PaimonLeRobotDataset, PaimonMultiLeRobotDataset table = conn.get_table("robot_data_frames") dataset = PaimonLeRobotDataset( table, tag_name=tag, ) +# To combine the group: dataset = PaimonMultiLeRobotDataset(table, tag_name=tag) loader = dataset.to_dataloader( batch_size=32, shuffle=True, diff --git a/paimon-python/pypaimon/multimodal/__init__.py b/paimon-python/pypaimon/multimodal/__init__.py index 5de3f3ea328b..0b8ac14fd575 100644 --- a/paimon-python/pypaimon/multimodal/__init__.py +++ b/paimon-python/pypaimon/multimodal/__init__.py @@ -33,6 +33,7 @@ from pypaimon.multimodal.lerobot.dataset import ( PaimonDatasetReader, PaimonLeRobotDataset, + PaimonMultiLeRobotDataset, ) from pypaimon.multimodal.rosbag import ( RosbagLoadResult, @@ -75,6 +76,7 @@ "ObjectInfo", "PaimonDatasetReader", "PaimonLeRobotDataset", + "PaimonMultiLeRobotDataset", "PutObjectResult", "RosbagLoadResult", "RosbagSource", diff --git a/paimon-python/pypaimon/multimodal/lerobot/__init__.py b/paimon-python/pypaimon/multimodal/lerobot/__init__.py index 277cd1620dc2..96e9e97dcc64 100644 --- a/paimon-python/pypaimon/multimodal/lerobot/__init__.py +++ b/paimon-python/pypaimon/multimodal/lerobot/__init__.py @@ -21,6 +21,7 @@ from pypaimon.multimodal.lerobot.dataset import ( PaimonDatasetReader, PaimonLeRobotDataset, + PaimonMultiLeRobotDataset, ) from pypaimon.multimodal.lerobot.writer import PaimonLeRobotWriter @@ -28,6 +29,7 @@ __all__ = [ "PaimonDatasetReader", "PaimonLeRobotDataset", + "PaimonMultiLeRobotDataset", "PaimonLeRobotWriter", "load_from_lerobot", "export_to_lerobot", diff --git a/paimon-python/pypaimon/multimodal/lerobot/dataset.py b/paimon-python/pypaimon/multimodal/lerobot/dataset.py index 0e3eca4dba2a..02edecc2df46 100644 --- a/paimon-python/pypaimon/multimodal/lerobot/dataset.py +++ b/paimon-python/pypaimon/multimodal/lerobot/dataset.py @@ -670,6 +670,10 @@ def __repr__(self): class _PaimonTableDatasetReader(PaimonDatasetReader): + @staticmethod + def _load_metadata(table, tag_name, dataset_index, dataset_id): + return _load_source_dataset(table, tag_name, dataset_index, dataset_id) + def __init__( self, table, @@ -677,6 +681,7 @@ def __init__( tag_name=None, episodes=None, dataset_index=None, + dataset_id=None, image_transforms=None, delta_timestamps=None, tolerance_s=1e-4, @@ -684,19 +689,8 @@ def __init__( video_backend=None, video_metadata_cache=None, return_uint8=False): - self._frames_table, meta = _load_dataset(table, tag_name) - if dataset_index is not None: - if episodes is not None: - raise ValueError("Select either dataset_index or episodes.") - if isinstance(dataset_index, bool) or not isinstance(dataset_index, int) \ - or dataset_index < 0: - raise ValueError("dataset_index must be a non-negative integer.") - sources = meta.datasets - if sources is None or dataset_index >= len(sources): - raise ValueError("LeRobot source dataset_index %d does not exist." - % dataset_index) - begin, end = _source_dataset_ranges(sources)[dataset_index][1:3] - episodes = list(range(begin, end)) + self._frames_table, meta = self._load_metadata(table, tag_name, dataset_index, dataset_id) + self.dataset_id = getattr(meta, "dataset_id", None) self.tag_name = tag_name super().__init__( meta, @@ -721,10 +715,26 @@ def _validate_physical_metadata(self): def _open_frame_rows(self, projection): rows = _PaimonTableFrameReader( self._frames_table, columns=projection) - if rows.num_rows != self._total_frames: + table_total_frames = getattr(self.meta, "_table_total_frames", self._total_frames) + if rows.num_rows != table_total_frames: raise ValueError( "Paimon table has %d rows but metadata declares %d frames." - % (rows.num_rows, self._total_frames)) + % (rows.num_rows, table_total_frames)) + return self._wrap_frame_rows(rows) + + def _wrap_frame_rows(self, rows): + if self.meta.datasets is not None: + return _SourceFrameReader(rows, self.dataset_id, self._total_frames) + return rows + + +class _PaimonMultiTableDatasetReader(_PaimonTableDatasetReader): + + @staticmethod + def _load_metadata(table, tag_name, dataset_index, dataset_id): + return _load_dataset(table, tag_name) + + def _wrap_frame_rows(self, rows): if self.meta.datasets is not None: rows = _SourceEpisodeFrameReader( rows, self.meta.datasets, @@ -732,6 +742,31 @@ def _open_frame_rows(self, projection): return rows +class _SourceFrameReader: + """Read one source's physical keys without translating its local IDs.""" + + def __init__(self, reader, dataset_id, num_rows): + self._reader = reader + self._dataset_id = dataset_id + self.num_rows = num_rows + self.file_io = reader.file_io + self.snapshot_id = reader.snapshot_id + self._table = reader._table + self._locator = reader._locator + + def read_indices(self, indices, columns): + keys = [(self._dataset_id, index) for index in indices] + data = self._reader.read_keys(keys, columns) + expected = set(keys) + actual = list(zip(data["dataset_id"].to_pylist(), data["index"].to_pylist())) + if len(actual) != len(expected) or set(actual) != expected: + raise ValueError("LeRobot frame keys are missing or duplicated.") + return data.select(columns) + + def close(self): + self._reader.close() + + class _SourceEpisodeFrameReader: """Present source-local Episode IDs as ordinals to the training reader.""" @@ -831,8 +866,8 @@ def close(self): self._reader.close() -class PaimonLeRobotDataset: - """Map-style Dataset facade backed by :class:`PaimonDatasetReader`.""" +class _LeRobotDataset: + """Map-style facade shared by the single-source and combined readers.""" def __init__( self, @@ -841,6 +876,7 @@ def __init__( tag_name=None, episodes=None, dataset_index=None, + dataset_id=None, image_transforms=None, delta_timestamps=None, tolerance_s=1e-4, @@ -854,6 +890,7 @@ def __init__( tag_name is not None or episodes is not None or dataset_index is not None + or dataset_id is not None or image_transforms is not None or delta_timestamps is not None or tolerance_s != 1e-4 @@ -866,11 +903,12 @@ def __init__( "Configure Dataset options on PaimonDatasetReader.") self.reader = table else: - self.reader = _PaimonTableDatasetReader( + self.reader = self._reader_class( table, tag_name=tag_name, episodes=episodes, dataset_index=dataset_index, + dataset_id=dataset_id, image_transforms=image_transforms, delta_timestamps=delta_timestamps, tolerance_s=tolerance_s, @@ -894,7 +932,7 @@ def to_dataloader(self, **kwargs): collate_fn = kwargs.pop("collate_fn", None) if collate_fn is not None: raise ValueError( - "PaimonLeRobotDataset.to_dataloader manages collate_fn.") + "%s.to_dataloader manages collate_fn." % type(self).__name__) from torch.utils.data import DataLoader num_workers = kwargs.get("num_workers", 0) batched = _LeRobotDataLoaderAdapter( @@ -941,6 +979,48 @@ def __repr__(self): self.reader.__class__.__name__, self.__class__.__name__, 1) +class PaimonLeRobotDataset(_LeRobotDataset): + """Read one source dataset, retaining its local indices and statistics. + + Select ``dataset_id`` (the stored UUID) or ``dataset_index`` (UUID order) + when the table group contains multiple sources. ``episodes`` is local to + that source. A group with one source needs no selector. + """ + + _reader_class = _PaimonTableDatasetReader + + +class PaimonMultiLeRobotDataset(_LeRobotDataset): + """Read all sources in a table group with combined training metadata. + + Frame and Episode indices are global to the group; task and subtask IDs + use the combined vocabulary. Select ``episodes`` with those global IDs. + Use :class:`PaimonLeRobotDataset` to read an individual source instead. + """ + + _reader_class = _PaimonMultiTableDatasetReader + + def __init__( + self, + table, + *, + tag_name=None, + episodes=None, + image_transforms=None, + delta_timestamps=None, + tolerance_s=1e-4, + blob_parallelism=16, + video_backend=None, + video_metadata_cache=None, + return_uint8=False): + super().__init__( + table, tag_name=tag_name, episodes=episodes, + image_transforms=image_transforms, delta_timestamps=delta_timestamps, + tolerance_s=tolerance_s, blob_parallelism=blob_parallelism, + video_backend=video_backend, video_metadata_cache=video_metadata_cache, + return_uint8=return_uint8) + + class _LeRobotDataLoaderAdapter: def __init__(self, dataset, share_memory): @@ -1142,6 +1222,66 @@ def _load_dataset(table, tag_name): return frames, metadata +def _load_source_dataset(table, tag_name, dataset_index, dataset_id): + raw_table = getattr(table, "raw_table", None) + if raw_table is None: + raise TypeError("table must be a MultimodalTable.") + if tag_name is not None: + _validate_tag_name(tag_name) + identifiers = _companion_table_identifiers(raw_table) + catalog = table.catalog + frames = _component_table(catalog, raw_table, tag_name) + episodes_table = _component_table( + catalog, catalog.get_table(identifiers["episodes"]), tag_name) + datasets_table = _component_table( + catalog, catalog.get_table(identifiers["datasets"]), tag_name) + source_rows = _read_arrow(datasets_table, [ + "id", "name", "info", "tasks", "subtasks", "stats"]).sort_by("id").to_pylist() + if not source_rows: + raise ValueError("LeRobot Dataset metadata is required.") + table_total_frames = _source_dataset_ranges(source_rows)[-1][4] + source = _select_source(source_rows, dataset_index, dataset_id) + source_local_layout = "dataset_id" in _target_schema(episodes_table).names + datasets = [{key: source[key] for key in ("id", "name", "info")}] if source_local_layout else None + episodes = _episode_dataset( + episodes_table, datasets, dataset_id=source["id"] if source_local_layout else None) + tasks, _ = _source_vocabulary([source], "task") + subtasks, _ = _source_vocabulary([source], "subtask") + info = json.loads(source["info"]) + for feature in info.get("features", {}).values(): + feature["shape"] = tuple(feature["shape"]) + stats = _numpy_stats(json.loads(source["stats"])) if source["stats"] is not None else None + metadata = _PaimonLeRobotMetadata( + str(table.identifier), tag_name, info, stats, episodes, tasks, subtasks, datasets) + metadata.dataset_id = source["id"] + metadata._table_total_frames = table_total_frames + metadata._compress_episodes = True + return frames, metadata + + +def _select_source(sources, dataset_index, dataset_id): + if dataset_index is not None and dataset_id is not None: + raise ValueError("Select either dataset_id or dataset_index.") + if dataset_id is not None: + if not isinstance(dataset_id, str): + raise ValueError("dataset_id must be a stored Dataset UUID string.") + for source in sources: + if source["id"] == dataset_id: + return source + raise ValueError("LeRobot source dataset_id %r does not exist." % dataset_id) + if dataset_index is None: + if len(sources) != 1: + raise ValueError( + "Multiple LeRobot sources: select dataset_id or dataset_index, " + "or use PaimonMultiLeRobotDataset to combine them.") + return sources[0] + if isinstance(dataset_index, bool) or not isinstance(dataset_index, int) or dataset_index < 0: + raise ValueError("dataset_index must be a non-negative integer.") + if dataset_index >= len(sources): + raise ValueError("LeRobot source dataset_index %d does not exist." % dataset_index) + return sources[dataset_index] + + def _source_vocabulary(sources, singular): import pandas as pd @@ -1313,15 +1453,17 @@ def _component_table(catalog, table, tag_name): return _time_travel_table(table, tag_name=tag_name) -def _read_arrow(table, projection=None): +def _read_arrow(table, projection=None, predicate=None): builder = table.new_read_builder() if projection is not None: builder = builder.with_projection(projection) + if predicate is not None: + builder = builder.with_filter(predicate) plan = builder.new_scan().plan() return builder.new_read().to_arrow(plan.splits()) -def _episode_dataset(table, datasets=None): +def _episode_dataset(table, datasets=None, dataset_id=None): try: from datasets import Dataset except ImportError as error: @@ -1335,7 +1477,11 @@ def _episode_dataset(table, datasets=None): else: projection = [name for name in _target_schema(table).names if not name.startswith("stats/") and name != "stats"] - data = _read_arrow(table, projection) + if dataset_id is None: + data = _read_arrow(table, projection) + else: + predicate = table.new_read_builder().new_predicate_builder().equal("dataset_id", dataset_id) + data = _read_arrow(table, projection, predicate) if datasets is not None: physical_ids = [dataset["id"] for dataset in datasets] ordinals = pc.index_in(data["dataset_id"], diff --git a/paimon-python/pypaimon/tests/lerobot_aggregate_test.py b/paimon-python/pypaimon/tests/lerobot_aggregate_test.py index 164f08af0f97..3ccaa9f9aeed 100644 --- a/paimon-python/pypaimon/tests/lerobot_aggregate_test.py +++ b/paimon-python/pypaimon/tests/lerobot_aggregate_test.py @@ -314,7 +314,7 @@ def test_timestamp_dtype_in_training_samples(tmp_path, timestamp_dtype, video): conn.load_from_lerobot("robot", uri, batch_size=2) expected = pq.read_table( Path(uri[7:]) / "data/chunk-000/file-000.parquet")["timestamp"].to_pylist() - dataset = pm.PaimonLeRobotDataset( + dataset = pm.PaimonMultiLeRobotDataset( conn.get_table("robot_frames"), video_backend="pyav") try: samples = dataset.reader.get_items(list(range(5))) @@ -483,8 +483,8 @@ def test_append_source_preserves_existing_indices_and_tags(setup, import_paralle pytest.importorskip("datasets") pytest.importorskip("torch") - before = pm.PaimonLeRobotDataset(conn.get_table("robot_frames"), tag_name="before") - after = pm.PaimonLeRobotDataset(conn.get_table("robot_frames"), tag_name="after") + before = pm.PaimonMultiLeRobotDataset(conn.get_table("robot_frames"), tag_name="before") + after = pm.PaimonMultiLeRobotDataset(conn.get_table("robot_frames"), tag_name="after") try: assert len(before) == 5 assert len(after) == 10 @@ -563,7 +563,7 @@ def test_append_preserves_source_episode_stats(setup): pytest.importorskip("datasets") pytest.importorskip("torch") - dataset = pm.PaimonLeRobotDataset(conn.get_table("robot_frames")) + dataset = pm.PaimonMultiLeRobotDataset(conn.get_table("robot_frames")) try: frames = dataset.reader.get_items(range(10)) assert [int(row["task_index"]) for row in frames] == [0] * 2 + [1] * 5 + [2] * 3 @@ -598,7 +598,7 @@ def test_legacy_user_read_control_stats_remains_text(setup, monkeypatch): aggregate._READ_CONTROL_STATS_COLUMN) assert (field.metadata or {}).get(b"description") == \ aggregate._READ_CONTROL_STATS_DESCRIPTION.encode("utf-8") - reader = pm.PaimonLeRobotDataset(conn.get_table("robot_frames")) + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("robot_frames")) try: assert reader.reader.meta.stats["index"]["mean"] == pytest.approx([4.5]) assert reader.reader.meta.stats["episode_index"]["mean"] == pytest.approx([1.6]) @@ -635,7 +635,7 @@ def test_append_mixed_fps_group_remains_readable(setup): conn.load_from_lerobot("robot", [sources[0]]) conn.append_to_lerobot("robot", sources[1]) - dataset = pm.PaimonLeRobotDataset(conn.get_table("robot_frames")) + dataset = pm.PaimonMultiLeRobotDataset(conn.get_table("robot_frames")) try: assert dataset.fps is None assert dataset.episode_fps == (10, 10, 20, 20) @@ -692,7 +692,7 @@ def test_append_twice_keeps_source_keys_and_training_order(setup, tmp_path): pytest.importorskip("datasets") pytest.importorskip("torch") - dataset = pm.PaimonLeRobotDataset(conn.get_table("robot_frames")) + dataset = pm.PaimonMultiLeRobotDataset(conn.get_table("robot_frames")) try: assert len(dataset) == 15 indices = [4, 5, 9, 10, 14] @@ -817,7 +817,7 @@ def test_merge_numbering_stats_and_training(setup, import_parallelism): assert metadata(conn, "stats")["task_index"]["mean"] == pytest.approx([1.1]) pytest.importorskip("datasets") torch = pytest.importorskip("torch") - dataset = pm.PaimonLeRobotDataset( + dataset = pm.PaimonMultiLeRobotDataset( conn.get_table("merged_frames"), tag_name="train", delta_timestamps={"action": [-0.1, 0, 0.1]}) info = dataset.reader.meta.info @@ -843,7 +843,7 @@ def test_merge_numbering_stats_and_training(setup, import_parallelism): batch = next(iter(dataset.to_dataloader(batch_size=3, num_workers=0))) assert batch["action"].shape == (3, 3, 2) assert batch["action"].dtype == torch.float32 - selected = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), tag_name="train", episodes=[2]) + selected = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), tag_name="train", episodes=[2]) assert len(selected) == 2 assert selected[0]["episode_index"].item() == 2 @@ -939,7 +939,7 @@ def test_merge_reordered_source_tasks_match_published_stats(setup): pq.write_table(tasks.take(pa.array([1, 0])), path) conn.load_from_lerobot("merged", sources) - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames")) + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames")) try: assert reader.meta.tasks.index.tolist() == ["pick", "place", "stack"] task_ids = [int(row["task_index"]) for row in reader.get_items(range(len(reader)))] @@ -993,7 +993,7 @@ def test_merge_normalizes_task_text_columns(setup, custom_source): assert vocabulary(conn, kind).index.tolist() == expected pytest.importorskip("datasets") pytest.importorskip("torch") - dataset = pm.PaimonLeRobotDataset(conn.get_table("merged_frames")) + dataset = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames")) assert dataset[5]["task"] == "place" assert dataset[7]["task"] == "stack" @@ -1138,6 +1138,132 @@ def test_single_source_metadata_opt_in(setup, import_parallelism): assert reader.episode_fps == (10, 10) +@pytest.mark.parametrize("selector", ["dataset_id", "dataset_index"]) +@pytest.mark.parametrize("ordinal", [0, 1]) +@pytest.mark.parametrize("tag_name", [None, "train"]) +def test_single_reader_selects_source_metadata_without_merging(setup, monkeypatch, selector, ordinal, tag_name): + pytest.importorskip("datasets") + pytest.importorskip("torch") + import pickle + from pypaimon.multimodal.lerobot import dataset as dataset_module + + conn, sources = setup + conn.load_from_lerobot("group", sources, tag_name="train") + source = rows(conn, "group_datasets").sort_by("id").to_pylist()[ordinal] + expected = json.loads(source["stats"]) + + def unexpected_merge(*args): + raise AssertionError("A single-source reader must use stored statistics") + + monkeypatch.setattr(dataset_module, "_merged_source_stats", unexpected_merge) + selection = {selector: source["id"] if selector == "dataset_id" else ordinal} + reader = pm.PaimonLeRobotDataset(conn.get_table("group_frames"), tag_name=tag_name, **selection) + try: + assert len(reader) == 5 + assert reader.num_episodes == 2 + assert reader.dataset_id == source["id"] + assert len(reader.meta.datasets) == 1 + assert reader.meta.info["total_frames"] == 5 + samples = reader.get_items([4, 0, 2, 2]) + assert [int(item["index"]) for item in samples] == [4, 0, 2, 2] + assert [int(item["episode_index"]) for item in samples] == [1, 0, 1, 1] + assert [int(item["task_index"]) for item in samples] == [1, 0, 1, 1] + assert samples[1]["task"] == ("pick" if ordinal == 0 else "place") + for actual in (reader.meta.stats, pickle.loads(pickle.dumps(reader.meta)).stats): + assert actual.keys() == expected.keys() + for name, stats in expected.items(): + assert actual[name].keys() == stats.keys() + for key, value in stats.items(): + np.testing.assert_allclose(actual[name][key], value) + finally: + reader.close() + + +def test_single_reader_requires_source_and_supports_local_episode_selection(setup): + pytest.importorskip("datasets") + pytest.importorskip("torch") + conn, sources = setup + conn.load_from_lerobot("group", sources) + table = conn.get_table("group_frames") + with pytest.raises(ValueError, match="PaimonMultiLeRobotDataset"): + pm.PaimonLeRobotDataset(table) + with pytest.raises(ValueError, match="either dataset_id or dataset_index"): + pm.PaimonLeRobotDataset(table, dataset_id="unused", dataset_index=0) + with pytest.raises(ValueError, match="dataset_id.*does not exist"): + pm.PaimonLeRobotDataset(table, dataset_id="unknown") + for index in (-1, True, 2, "1"): + with pytest.raises(ValueError, match="dataset_index"): + pm.PaimonLeRobotDataset(table, dataset_index=index) + reader = pm.PaimonLeRobotDataset(table, dataset_index=1, episodes=[1]) + try: + assert len(reader) == 3 + assert reader.num_episodes == 1 + assert [int(item["index"]) for item in reader.get_items(range(3))] == [2, 3, 4] + assert int(reader[0]["episode_index"]) == 1 + assert reader[0]["task"] == "stack" + finally: + reader.close() + + +@pytest.mark.parametrize("num_workers", [0, 2]) +def test_selected_source_dataloader_uses_local_windows(setup, num_workers): + pytest.importorskip("datasets") + pytest.importorskip("torch") + conn, sources = setup + conn.load_from_lerobot("group", sources, tag_name="train") + reader = pm.PaimonLeRobotDataset( + conn.get_table("group_frames"), dataset_index=1, episodes=[1], tag_name="train", + delta_timestamps={"action": [-0.1, 0, 0.1]}) + try: + options = {"multiprocessing_context": "spawn"} if num_workers else {} + batch = next(iter(reader.to_dataloader(batch_size=3, num_workers=num_workers, **options))) + assert batch["index"].tolist() == [2, 3, 4] + assert batch["episode_index"].tolist() == [1, 1, 1] + assert batch["task_index"].tolist() == [1, 1, 1] + assert batch["task"] == ["stack"] * 3 + assert batch["action"][:, :, 0].tolist() == [[2, 2, 3], [2, 3, 4], [3, 4, 4]] + finally: + reader.close() + + +def test_selected_source_without_stats_remains_none(setup, monkeypatch): + pytest.importorskip("datasets") + pytest.importorskip("torch") + from pypaimon.multimodal.lerobot import dataset as dataset_module + + conn, sources = setup + for uri in sources: + (Path(uri[7:]) / "meta/stats.json").unlink() + conn.load_from_lerobot("group", sources) + with patch.object(dataset_module, "_merged_source_stats", side_effect=AssertionError("Unexpected merge")): + reader = pm.PaimonLeRobotDataset(conn.get_table("group_frames"), dataset_index=1) + try: + assert reader.meta.stats is None + assert int(reader[0]["index"]) == 0 + finally: + reader.close() + + +def test_single_reader_excludes_other_source_features(setup): + pytest.importorskip("datasets") + pytest.importorskip("torch") + conn, sources = setup + add_frame_feature(sources[1], "temperature", "float32", [20., 21., 22., 23., 24.]) + conn.load_from_lerobot("group", sources, tag_name="train") + ids = rows(conn, "group_datasets").sort_by("id")["id"].to_pylist() + first = pm.PaimonLeRobotDataset(conn.get_table("group_frames"), dataset_id=ids[0], tag_name="train") + second = pm.PaimonLeRobotDataset(conn.get_table("group_frames"), dataset_id=ids[1], tag_name="train") + try: + assert "temperature" not in first.features + assert "temperature" not in first.meta.stats + assert "temperature" not in first[0] + assert second[0]["temperature"].item() == 20. + np.testing.assert_allclose(second.meta.stats["temperature"]["mean"], [22.]) + finally: + first.close() + second.close() + + def test_source_info_remains_distinct_from_merged_info(setup): conn, sources = setup for ordinal, uri in enumerate(sources): @@ -1171,15 +1297,17 @@ def test_source_selection_derives_unequal_ranges_from_info(setup, dataset_index) for uri in sources: (Path(uri[7:]) / "meta/stats.json").unlink() conn.load_from_lerobot("merged", sources) - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), dataset_index=dataset_index) + dataset_type = pm.PaimonMultiLeRobotDataset if dataset_index is None else pm.PaimonLeRobotDataset + selection = {} if dataset_index is None else {"dataset_index": dataset_index} + reader = dataset_type(conn.get_table("merged_frames"), **selection) try: indices = list(range(7)) if dataset_index is None else ( - [0, 1] if dataset_index == 0 else list(range(2, 7))) + [0, 1] if dataset_index == 0 else list(range(5))) samples = reader.get_items(list(range(len(reader)))) assert [int(sample["index"]) for sample in samples] == indices - expected_episodes = [0, 0, 1, 1, 2, 2, 2] - assert [int(sample["episode_index"]) for sample in samples] == [ - expected_episodes[index] for index in indices] + expected_episodes = ([0, 0, 1, 1, 2, 2, 2] if dataset_index is None + else [0, 0] if dataset_index == 0 else [0, 0, 1, 1, 1]) + assert [int(sample["episode_index"]) for sample in samples] == expected_episodes finally: reader.close() @@ -1196,7 +1324,7 @@ def test_source_info_counts_must_match_episode_layout(setup, field, counts): pytest.importorskip("torch") conn, sources = setup conn.load_from_lerobot("merged", sources) - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames")) + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames")) try: for dataset, count in zip(reader.meta.datasets, counts): info = json.loads(dataset["info"]) @@ -1296,7 +1424,7 @@ def test_video_sources_with_identical_paths(tmp_path, import_parallelism): original_mp4 = (Path(uri[7:]) / "videos/camera/chunk-000/file-000.mp4").read_bytes() assert stored_mp4 == original_mp4 - dataset = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), tag_name="train", video_backend="pyav") + dataset = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), tag_name="train", video_backend="pyav") assert dataset[0]["camera"].mean().item() < 0.05 assert dataset[5]["camera"].mean().item() > 0.3 assert dataset[5]["frame_index"].item() == 0 @@ -1334,8 +1462,9 @@ def test_mixed_fps_group_keeps_episode_rates(tmp_path, import_parallelism): video_backend="pyav") assert len(scoped) == 16 assert scoped.fps == 30 - assert scoped[0]["index"].item() == 16 - dataset = pm.PaimonLeRobotDataset( + assert scoped[0]["index"].item() == 0 + assert scoped.episode_fps == (30, 30) + dataset = pm.PaimonMultiLeRobotDataset( conn.get_table("merged_frames"), tag_name="train", video_backend="pyav", delta_timestamps={"action": [-0.2, 0, 0.2]}) assert dataset.fps is None @@ -1357,14 +1486,14 @@ def test_mixed_fps_group_keeps_episode_rates(tmp_path, import_parallelism): for index, frame in enumerate(reference): np.testing.assert_allclose(dataset[ordinal * 16 + index]["camera"].numpy(), frame.transpose(2, 0, 1) / 255.0) - selected = pm.PaimonLeRobotDataset( + selected = pm.PaimonMultiLeRobotDataset( conn.get_table("merged_frames"), episodes=[2], video_backend="pyav", delta_timestamps={"action": [0, 1 / 30]}) assert selected[0]["action"][:, 0].tolist() == [0, 1] assert next(iter(dataset.to_dataloader(batch_size=2, num_workers=0)))[ "action"].shape == (2, 3, 2) with pytest.raises(ValueError, match="multiples of 1/25"): - pm.PaimonLeRobotDataset( + pm.PaimonMultiLeRobotDataset( conn.get_table("merged_frames"), tag_name="train", delta_timestamps={"action": [0.1]}) @@ -1422,7 +1551,7 @@ def test_official_merge_reference_and_local_sources(tmp_path): np.testing.assert_allclose(actual[name].to_pylist(), expected[name].to_pylist()) assert actual["episode_index"].to_pylist() == [0] * 3 + [1] * 3 + [0] * 3 + [1] * 3 assert actual["dataset_index"].to_pylist() == [0] * 6 + [1] * 6 - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") try: assert [int(sample["index"]) for sample in reader.get_items(range(12))] == ( expected["index"].to_pylist()) @@ -1554,7 +1683,7 @@ def test_merge_nullable_subtask_import(setup, tmp_path, import_parallelism, all_ conn.load_from_lerobot("merged", sources, parallelism=import_parallelism, tag_name="train") expected = [None] * 10 if all_null else [0, None, 0, 1, None] * 2 assert frame_rows(conn, "merged_frames")["subtask_index"].to_pylist() == expected - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") assert reader[1]["subtask"] is None batch = next(iter(reader.to_dataloader(batch_size=5, num_workers=0))) assert batch["subtask_index"][1].item() == -1 @@ -1564,7 +1693,7 @@ def test_merge_nullable_subtask_import(setup, tmp_path, import_parallelism, all_ assert all(variant_value(value)["subtask_index"]["mean"] is not None for value in rows(conn, "merged_episodes")["stats"].to_pylist()) if not all_null: - windowed = pm.PaimonLeRobotDataset( + windowed = pm.PaimonMultiLeRobotDataset( conn.get_table("merged_frames"), delta_timestamps={"subtask_index": [-0.1, 0, 0.1]}) first, second = windowed.get_items([0, 0]) first["subtask_index"][0].fill_(-100) @@ -1585,7 +1714,7 @@ def read_indices(self, indices, columns): conn, sources = setup conn.load_from_lerobot("merged", sources) - meta = pm.PaimonLeRobotDataset(conn.get_table("merged_frames")).meta + meta = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames")).meta info = json.loads(meta.datasets[0]["info"]) info["fps"] = rate meta.datasets[0]["info"] = json.dumps(info) @@ -1609,7 +1738,7 @@ def test_reader_requires_fps_without_episode_column(setup): target = conn.get_table("merged_datasets").raw_table _overwrite_arrow(target, pa.Table.from_pylist(info, schema=_target_schema(target))) with pytest.raises(ValueError, match="missing fps"): - pm.PaimonLeRobotDataset(conn.get_table("merged_frames")) + pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames")) def test_episode_fps_rejects_conflicting_video_feature(tmp_path): @@ -1709,7 +1838,7 @@ def test_default_fps_preserves_importer_contract(tmp_path, multiple, video_rate) episodes = rows(conn, "merged_episodes") assert episodes["fps"].to_pylist() == [10.0, 10.0] assert "fps_mode" not in metadata(conn, "info") - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), video_backend="pyav") + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), video_backend="pyav") try: assert reader.episode_fps == (10, 10) assert tuple(reader[0]["camera"].shape) == (3, 16, 16) @@ -1728,7 +1857,7 @@ def test_nullable_batch_type_stays_stable_after_import(setup, import_parallelism pa.array([0, None, 0, 1, 0], type=pa.int64())) pq.write_table(data, path) conn.load_from_lerobot("merged", sources, parallelism=import_parallelism) - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames")) + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames")) try: batches = list(reader.to_dataloader(batch_size=2, num_workers=0)) assert batches[0]["subtask_index"].tolist() == [0, -1] @@ -1777,7 +1906,7 @@ def read_indices(self, indices, columns): conn, sources = setup conn.load_from_lerobot("merged", sources) - meta = pm.PaimonLeRobotDataset(conn.get_table("merged_frames")).meta + meta = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames")).meta episodes = meta.episodes.to_dict() episodes["dataset_index"][0] = 1 meta.episodes = Dataset.from_dict(episodes) @@ -1809,7 +1938,7 @@ def test_merge_archives_standard_vocabulary_columns(setup, import_parallelism): assert all(set(item) == {kind[:-1] + "_index", kind[:-1]} for item in restored) assert set(conn.catalog.list_tables("default")) == { "merged_frames", "merged_episodes", "merged_datasets"} - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") try: samples = reader.get_items([0, 5]) assert [sample["task"] for sample in samples] == ["pick", "place"] @@ -1855,7 +1984,7 @@ def test_training_metadata_ignores_episode_map_extension(setup): assert episodes.schema.field("vendor_map").type == values.type assert episodes["vendor_map"].to_pylist() == values.to_pylist() + [None, None] - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") try: assert reader.num_episodes == 4 assert "vendor_map" not in reader.meta.episodes.column_names @@ -1875,7 +2004,7 @@ def test_training_projects_out_source_archives(setup, dataset_index): reads = {} read_arrow = dataset_module._read_arrow - def checked_read(table, projection=None): + def checked_read(table, projection=None, predicate=None): name = table.identifier.object if name.endswith(("_datasets", "_episodes")): assert projection is not None @@ -1888,14 +2017,15 @@ def checked_read(table, projection=None): assert "stats" not in projection if projection != ["stats"]: reads[name.rsplit("_", 1)[1]] = projection - result = read_arrow(table, projection) + result = read_arrow(table, projection, predicate) if name.endswith(("_datasets", "_episodes")): assert result.column_names == projection return result with patch.object(dataset_module, "_read_arrow", side_effect=checked_read): - dataset = pm.PaimonLeRobotDataset( - conn.get_table("merged_frames"), tag_name="train", dataset_index=dataset_index) + dataset_type = pm.PaimonMultiLeRobotDataset if dataset_index is None else pm.PaimonLeRobotDataset + selection = {} if dataset_index is None else {"dataset_index": dataset_index} + dataset = dataset_type(conn.get_table("merged_frames"), tag_name="train", **selection) try: assert dataset[0]["task"] == ("pick" if dataset_index is None else "place") assert "source_episode_patch_json" not in dataset.meta.episodes.column_names @@ -1960,7 +2090,7 @@ def test_merge_archives_vocabulary_without_arrow_schema(setup, import_parallelis for kind in ("task", "subtask"): restored = row[kind + "s"] assert restored == originals[ordinal, kind].to_pylist() - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames")) + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames")) try: assert reader[0]["task"] == "pick" assert reader[5]["subtask"] == "grasp" @@ -1987,7 +2117,7 @@ def test_nullable_mask_preserves_source_feature(setup, import_parallelism): pa.array([0, None, 0, 1, 0], type=pa.int64())) pq.write_table(data, path) conn.load_from_lerobot("merged", sources, parallelism=import_parallelism) - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames")) + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames")) try: batch = next(iter(reader.to_dataloader(batch_size=2, num_workers=0))) assert batch["subtask_index_is_valid"].tolist() == [False, True] @@ -2010,7 +2140,7 @@ def test_merge_normalizes_video_fps(setup, tmp_path, import_parallelism, video_r info["features"]["camera"]["info"]["video.fps"] = video_rate path.write_text(json.dumps(info)) conn.load_from_lerobot("merged", sources, parallelism=import_parallelism) - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), video_backend="pyav") + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), video_backend="pyav") try: assert reader.episode_fps == (10, 10, 10, 10) assert tuple(reader[5]["camera"].shape) == (3, 16, 16) @@ -2057,7 +2187,7 @@ def test_merge_source_specific_episode_extensions(setup, import_parallelism, rev for value in values["camera_intrinsics"].to_pylist()] == ( [None, None] if source_index == 0 else [ {"head_left": [1.] * 8}, {"head_left": [2.] * 8}]) - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") try: assert [int(sample["episode_index"]) for sample in reader.get_items([0, 2, 5, 7])] == [0, 1, 2, 3] finally: @@ -2138,7 +2268,7 @@ def test_merge_optional_video_metadata(tmp_path, key, value, reverse): sources.reverse() conn.load_from_lerobot("merged", sources, tag_name="train") assert metadata(conn, "info")["features"]["camera"][key] == {} - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), tag_name="train", video_backend="pyav") + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), tag_name="train", video_backend="pyav") try: assert tuple(reader[5]["camera"].shape) == (3, 16, 16) assert reader.episode_fps == (10, 10, 10, 10) @@ -2162,7 +2292,7 @@ def test_merge_reserves_fps_mode(setup, import_parallelism): assert "fps_mode" not in info for row in rows(conn, "merged_datasets").to_pylist(): assert json.loads(row["info"])["fps_mode"] == "episode" - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") try: assert int(reader[5]["episode_index"]) == 2 assert reader.episode_fps == (10, 10, 10, 10) @@ -2185,7 +2315,7 @@ def test_merge_int32_source_episode_ids(setup, import_parallelism): data = episode_rows(conn, "merged_episodes") assert data.schema.field("episode_index").type == pa.int32() assert data["episode_index"].to_pylist() == [0, 1, 0, 1] - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") try: assert [int(s["episode_index"]) for s in reader.get_items([0, 2, 5, 7])] == [0, 1, 2, 3] finally: @@ -2339,14 +2469,14 @@ def test_extra_dataset_text_fields(setup, multiple, import_parallelism): assert actual["notes"] == notes read_arrow = dataset_module._read_arrow - def checked_read(table, projection=None): + def checked_read(table, projection=None, predicate=None): if table.identifier.object.endswith("_datasets"): assert "config" not in projection assert "notes" not in projection - return read_arrow(table, projection) + return read_arrow(table, projection, predicate) with patch.object(dataset_module, "_read_arrow", side_effect=checked_read): - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), tag_name="train") try: assert len(reader) == (10 if multiple else 5) assert "config" not in reader.meta.datasets[0] @@ -2474,8 +2604,8 @@ def test_schema_evolution_unions_three_tables(setup, import_parallelism, reverse assert metadata(conn, "stats")["temperature"]["count"] == [5] assert metadata(conn, "stats")["pressure"]["mean"] == [8.] assert data.schema.field("temperature").nullable - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), - delta_timestamps={"temperature": [-0.1, 0., 0.1]}) + reader = pm.PaimonMultiLeRobotDataset( + conn.get_table("merged_frames"), delta_timestamps={"temperature": [-0.1, 0., 0.1]}) try: samples = reader.get_items([0, 5]) for item, uri in zip(samples, sources): @@ -2534,8 +2664,9 @@ def test_schema_evolution_allows_missing_video(tmp_path, import_parallelism): sources = [source(tmp_path / "with_video", video=True), source(tmp_path / "without_video")] conn.load_from_lerobot("merged", sources, parallelism=import_parallelism) assert rows(conn, "merged_frames")["camera"].null_count == 5 - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), video_backend="pyav", - delta_timestamps={"camera": [-0.1, 0., 0.1]}) + reader = pm.PaimonMultiLeRobotDataset( + conn.get_table("merged_frames"), video_backend="pyav", + delta_timestamps={"camera": [-0.1, 0., 0.1]}) try: samples = reader.get_items([0, 5]) assert tuple(samples[0]["camera"].shape) == (3, 3, 16, 16) @@ -2556,7 +2687,7 @@ def test_schema_evolution_allows_missing_images(setup, import_parallelism): Image.new("RGB", (2, 2), color="red").save(buffer, format="PNG") add_frame_feature(sources[0], "image", "image", [buffer.getvalue()] * 5, (2, 2, 3)) conn.load_from_lerobot("merged", sources, parallelism=import_parallelism) - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames")) + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames")) try: samples = reader.get_items([0, 5]) assert tuple(samples[0]["image"].shape) == (3, 2, 2) @@ -2584,7 +2715,7 @@ def test_schema_evolution_allows_optional_subtask_column(setup, import_paralleli path.write_text(json.dumps(stats)) conn.load_from_lerobot("merged", sources, parallelism=import_parallelism) assert rows(conn, "merged_frames")["subtask_index"].null_count == 5 - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames")) + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames")) try: samples = reader.get_items([0, 5]) assert samples[0]["subtask"] is None @@ -2642,8 +2773,8 @@ def test_append_evolves_frame_and_dataset_columns(setup, tmp_path, import_parall assert metadata(conn, "stats")["temperature"]["count"] == [5] assert set(conn.catalog.list_tables("default")) == { "merged_frames", "merged_episodes", "merged_datasets"} - old = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), tag_name="before") - new = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), tag_name="after") + old = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), tag_name="before") + new = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), tag_name="after") try: assert len(old) == 10 assert "humidity" not in old[0] @@ -2742,7 +2873,7 @@ def test_append_nullable_visual_features(tmp_path, import_parallelism, media, ad assert rows(conn, "merged_frames")[key].null_count == 5 if media == "video": assert conn.get_table("merged_frames").raw_table.options.video_frame_fields() == {key} - reader = pm.PaimonLeRobotDataset(conn.get_table("merged_frames"), video_backend="pyav") + reader = pm.PaimonMultiLeRobotDataset(conn.get_table("merged_frames"), video_backend="pyav") try: samples = reader.reader.get_items([0, 5]) assert samples[1 - int(add_new)][key] is None diff --git a/paimon-python/pypaimon/tests/multimodal_lerobot_test.py b/paimon-python/pypaimon/tests/multimodal_lerobot_test.py index 548ab2245ff5..b931fbc52641 100644 --- a/paimon-python/pypaimon/tests/multimodal_lerobot_test.py +++ b/paimon-python/pypaimon/tests/multimodal_lerobot_test.py @@ -1073,7 +1073,7 @@ def test_table_option_limits_video_decoders(self): rows = SimpleNamespace( _table=frames, num_rows=1, file_io=LocalFileIO(), close=lambda: None) - with patch(module + "_load_dataset", return_value=(frames, metadata)), \ + with patch(module + "_load_source_dataset", return_value=(frames, metadata)), \ patch(module + "_target_schema", return_value=_schema_from_info(info)), \ patch(module + "_PaimonTableFrameReader", @@ -1099,7 +1099,7 @@ def test_table_option_limits_video_decoders(self): rows = SimpleNamespace( _table=frames, num_rows=1, file_io=LocalFileIO(), close=lambda: None) - with patch(module + "_load_dataset", return_value=(frames, metadata)), \ + with patch(module + "_load_source_dataset", return_value=(frames, metadata)), \ patch(module + "_target_schema", return_value=_schema_from_info(info)), \ patch(module + "_PaimonTableFrameReader", @@ -1445,7 +1445,7 @@ def test_dataset_requires_supported_python(self): with patch( "pypaimon.multimodal.lerobot.dataset.sys.version_info", (3, 9)), patch( - "pypaimon.multimodal.lerobot.dataset._load_dataset") as load: + "pypaimon.multimodal.lerobot.dataset._load_source_dataset") as load: with self.assertRaisesRegex(RuntimeError, "Python 3.10"): pmm.PaimonLeRobotDataset(Mock()) load.assert_not_called() @@ -2305,7 +2305,7 @@ def test_dataset_return_uint8_requires_bool(self): ) with patch( "pypaimon.multimodal.lerobot.dataset." - "_load_dataset", + "_load_source_dataset", return_value=loaded), patch( "pypaimon.multimodal.lerobot.dataset._target_schema", return_value=pa.schema([])), patch(