Repository navigation
fix(lerobot): write official loader fields so v3 exports open in lerobot - #814
Amidwestnoob wants to merge 2 commits into
Conversation
Apply the r002 producer patch from contribution-workshop staging 5f08f73abdfe525dd6200557a82672843d8a3b66 without source changes.
Independent review follow-up to r002: require official lerobot 0.4.4, exercise both sparse task IDs across every frame, and mark the real FFmpeg integration per contribution rules.
[Medium impact] The changes affect HFlow's local LeRobot exports and the tools that open them. The PR appears safe to merge, with a non-blocking recommendation to bound sparse task padding. Findings
|
| max_index = max(registry) | ||
| indices = list(range(max_index + 1)) | ||
| names = [registry.get(i, "") for i in indices] |
There was a problem hiding this comment.
Sparse tasks can exhaust memory
_official_tasks_table allocates rows up to the largest source task ID, with no size limit. A small registry with a very large sparse ID can exhaust memory during export, even when the selected episodes never use that task. Previously, the exporter copied or wrote only the registry's actual entries.
Check the required row count before allocating and reject oversized registries with a clear error.
Summary
LeRobot v3 exports now open in the official
lerobot==0.4.4loader.codebase_version="v3.0",total_tasks, and range-formsplits("train": "0:N"), keeping the existingcodemarker.meta/tasks.parquetwith task strings as the pandas index. Preserve sparse source task IDs with positional padding sotasks.iloc[task_index].nameresolves correctly.EXPORT_VERSIONtolerobot-export-v4and document regeneration of older exports. The canonical episode format and transform behavior version are unchanged.Closes #778
Why
On main
3d9dfb1, an export accepted by the structural validator fails in bothLeRobotDatasetMetadataandLeRobotDatasetwithKeyError: 'codebase_version'. After that field, the official loader also requires the task count, range-form splits, and positional task lookup.The committed opt-in round-trip test opens a typed export with two real synthetic MP4 cameras and checks all eight frames, including sparse task IDs 0 and 10. A separate independent round-trip also passed with unordered task IDs 10 and 2, nonzero source offsets, and both cameras decoded. The same independent test fails with the original missing-key error on unmodified main.
Validation
Local Linux checks on the final source:
uv run --locked pytest -q -rs tests/test_lerobot_export.py: 44 passed, 1 skipped.HFLOW_LEROBOT_LOADER_PYTHON=<isolated lerobot 0.4.4 interpreter> HF_HUB_OFFLINE=1 HF_DATASETS_OFFLINE=1 uv run --locked pytest -q tests/test_lerobot_export.py::test_official_lerobot_loader_opens_typed_export: passed. Running that test together with the independent round-trip gave 2 passed, no skips.uv run --locked pytest -q -n 4 -rs: 2657 passed, 9 skipped on Python 3.11, 3.12, and 3.14.numpy==2.3.5, then ranuv run --no-sync pytest -q -n 4 tests/test_resample_derive.py tests/test_episode_to_arrow.py tests/test_video_import.py: 93 passed. Restored the locked environment afterwards.uv run --locked ruff check .,uv run --locked ruff format --check ., anduv run --locked ty check: passed, including Python 3.14. Also ran the contribution guide's fix/format commands.Full-suite environment: an ephemeral loopback HTTP 404 endpoint replaced optional remote Hub lookups, keeping synthetic fixtures off production services. The suite's explicit loopback HTTP integration remained active. Test artifacts were retained outside the checkout, with a short temporary directory for Python 3.14 multiprocessing sockets. These are environment settings, not changes to production code or test assertions.
The official-loader integration remains opt-in so
lerobotdoes not enter the lockfile. Its default skip was exercised separately. The other eight skips require MediaPipe, network FFmpeg, Docker, or a live bucket. An earlier development run encountered an intermittent failure in an untouched verification test; the reviewed baseline and final full runs passed. macOS and actual upstream GitHub Actions have not been verified locally; no upstream CI pass is claimed.Checklist
uv run ruff check --fix,uv run ruff format, anduv run ty check.