Repository navigation
[python] Separate LeRobot dataset loading and episode appends - #11614
XiaoHongbo-Hope wants to merge 9 commits into
Conversation
aaca235 to
0a44b66
Compare
|
+1 |
JingsongLi
left a comment
There was a problem hiding this comment.
I reproduced these six cases on 588d776927.
| for singular, vocabulary in vocabularies.items(): | ||
| entries = [{singular + "_index": index, singular: text} | ||
| for text, index in sorted(vocabulary.items(), key=lambda item: item[1])] | ||
| target[singular + "s"] = entries or None |
There was a problem hiding this comment.
[P1] Preserve an empty subtask vocabulary. A valid LeRobot source can declare subtask_index with an empty meta/subtasks.parquet and null subtask indices in every frame. I reproduced a Dataset that reads successfully after import but fails to open with PaimonLeRobotDataset after appending another such source. entries or None changes _datasets.subtasks from [] to None while the feature is still declared. Keep [] and set total_subtasks to zero when the feature is present.
| if plan["metadata"]["stats_table"] is not None] | ||
| if parts: | ||
| names = dict.fromkeys(name for part in parts for name in part if name not in _CONTROLS) | ||
| stats = {name: _merge_stats([part[name] for part in parts if name in part]) for name in names} |
There was a problem hiding this comment.
[P1] Preserve quantile normalization after an Episode append. With a single Dataset UUID and q01 and q99 in both inputs, I reproduced those stats disappearing from meta.stats["action"] after a successful append. _merge_stats drops the quantiles before the updated Dataset row is written. LeRobot's default PI0.5 configuration then fails during normalization. Please recompute the quantiles over the combined frames or aggregate them using the supported LeRobot version's policy, and add a single-Dataset regression test. PI0.5 configuration · LeRobot normalizer
| for group, coordinates in files.items(): | ||
| column, prefix = group | ||
| values = groups[column] | ||
| if prefix + "chunk_index" in values and prefix + "file_index" in values: |
There was a problem hiding this comment.
[P2] Skip incomplete file coordinates. An existing Dataset can contain (0, 0) and (null, null) in the optional meta/episodes/{chunk_index,file_index} fields. Initial import accepts both rows, but this scan adds both pairs and max() raises TypeError during the next append. Check for a complete integer pair both here and when remapping incoming coordinates so missing coordinates remain missing.
| mapping[source] = coordinate | ||
| coordinates.add(coordinate) | ||
| values.update(zip(keys, mapping[source])) | ||
| row[column] = _variant_value(values) |
There was a problem hiding this comment.
[P2] Preserve large unsigned values when rewriting VARIANT. An Episode with data/vendor_id = 2**64 - 1 in a uint64 Arrow column imports successfully on its own. Appending that Episode fails because decoding the VARIANT yields a Decimal, which _variant_value rejects on the second encode. Apply the coordinate changes before the first encode or use a re-encoding path that preserves Decimal values.
| for key in ("info", "video_info"): | ||
| if isinstance(feature.get(key), dict): | ||
| feature[key] = {name: value for name, value in feature[key].items() | ||
| if (other.get(key) or {}).get(name) == value} |
There was a problem hiding this comment.
[P2] Normalize optional video feature metadata. A target camera with info={"video.fps": 10} and an incoming camera with info="producer" have matching feature contracts and can be imported together. Episode append raises AttributeError here because the truthy string reaches .get(name). Reuse the import path's dictionary normalization for info and video_info.
| plan["next_chunks"][group] += 1 | ||
| mapping[source] = coordinate | ||
| coordinates.add(coordinate) | ||
| values.update(zip(keys, mapping[source])) |
There was a problem hiding this comment.
[P2] Preserve the original file coordinates. I reproduced an append that stored (1, 0) in _episodes.data for an incoming source whose file was at (0, 0). The documented data_path template then points to a file that does not exist in that source. Keep the original coordinate pair and source provenance alongside any coordinates assigned within the combined Dataset. Episode field documentation
Use
load_from_lerobot(..., append=True)for new Datasets andappend_to_lerobot(..., dataset_id=...)for new Episodes in an existing Dataset.Tests: 51 append cases passed on Python/Ray and Native read/write; 446 related tests passed.