Fix corrupted parquet files (footer was never written on upload)
Fix corrupted parquet files (footers were never written on upload)
The two parquet files currently on main are unreadable for bothpyarrow and the Hugging Face dataset viewer:
ArrowInvalid: Parquet magic bytes not found in footer. Either the file is
corrupted or this is not a parquet file.
This branch β fix-corrupted-parquets β fixes both files. No data was lost; the existing on-Hub bodies were intact, only the trailing footer + length + closing PAR1 magic were missing.
Root cause
| File | Status on main |
Recovery |
|---|---|---|
data/chunk-000/file-000.parquet |
leading PAR1 β, page bodies intact, no trailing PAR1 |
footer rebuilt from page-header scan |
meta/episodes/chunk-000/file-000.parquet |
same truncation pattern | regenerated from the data parquet + videos on disk |
meta/tasks.parquet |
OK | unchanged |
For the data parquet, walking the body via Thrift Compact PageHeaders consumed every byte without trailing garbage:
- 6,800 pages = (1 dictionary + 1 data) Γ 17 columns Γ 200 row groups.
- Sum of
num_valuesacross data pages = 10,397,576 =13 scalars Γ 125,272 + (30 + 14 + 14 + 12) list-elements Γ 125,272. - Per-row-group row counts (
556, 654, 671, β¦, 664) sum to 125,272 =total_framesfrommeta/info.json. - Number of row groups = 200 =
total_episodes.
This pattern (PAR1 head, no PAR1 tail, body fully parses) is exactly the signature of an upload (or writer) that was killed mid-finalisation.
What this branch does
Commit 1 β cc65151 fix(data): rebuild missing parquet footer
A synthesised FileMetaData Thrift Compact footer is appended to a copy of the file (followed by the 4-byte little-endian footer length and the closing PAR1 magic). The first 37,450,342 bytes of the recovered file are SHA-256-identical to the original body β only metadata was added.
>>> import datasets
>>> ds = datasets.load_dataset(
... "axiboai/piper-stack-scripted",
... revision="fix-corrupted-parquets",
... data_files="data/chunk-000/file-000.parquet",
... )["train"]
>>> ds
Dataset({
features: ['observation.state', 'observation.ee_pose', 'action.joint_position',
'action.ee_delta', 'metadata.demonstrator_id', ..., 'task_index'],
num_rows: 125272,
})
>>> len(set(ds["episode_index"]))
200
>>> ds["metadata.task_variant"][0]
'stack_red_on_blue'
Commit 2 β 8d87002 fix(meta/episodes): regenerate per-episode index parquet
meta/episodes/chunk-000/file-000.parquet was rebuilt from scratch using the (now-readable) data parquet plus the videos on disk:
- Group rows by
episode_indexβ 200 episodes, lengths 529β700 frames, total 125,272. - For each video feature, walk the existing
videos/<key>/chunk-000/file-*.mp4files (3, 2, 2, 1 files respectively) and assign each episode to a(chunk_index, file_index, from_timestamp, to_timestamp)matching LeRobot's writer roll-over rule (file boundaries align with episode boundaries). - Compute per-episode
{min, max, mean, std, count, q01, q10, q50, q90, q99}for every numeric and video feature using the sameRunningQuantileStatsalgorithm aslerobot.datasets.compute_stats(single deterministic ~125-frame sample per episode for video features, normalised to[0, 1]with shape(3, 1, 1)). - Materialise the 165-column LeRobot v3 schema and write it as a single SNAPPY-compressed row group.
dataset_to_index of the last episode is 125,272, exactly matching the data parquet row count.
Verification
After this branch is merged:
import pyarrow.parquet as pq
from huggingface_hub import HfFileSystem
fs = HfFileSystem()
for path in ["data/chunk-000/file-000.parquet",
"meta/episodes/chunk-000/file-000.parquet",
"meta/tasks.parquet"]:
with fs.open(f"datasets/axiboai/piper-stack-scripted/{path}", "rb") as f:
md = pq.read_metadata(f)
print(path, md.num_rows, "rows", md.num_columns, "cols")
Should print:
data/chunk-000/file-000.parquet 125272 rows 17 cols
meta/episodes/chunk-000/file-000.parquet 200 rows 165 cols
meta/tasks.parquet 1 rows 2 cols
The dataset viewer should also start working again once the merge lands.
Notes
- Per-episode video
stdvalues are(0, 0, 0). This matches what LeRobot's own writer produces (batch ** 2overflows onuint8inRunningQuantileStats.update, which clamps to0innp.maximum(0, variance)). The aggregatedmeta/stats.jsonstdis non-zero because aggregation usesdelta_means**2overfloat64, sidestepping the overflow. meta/info.jsondeclaresvideo.codec: h264but the actual.mp4files are encoded with AV1 (libdav1d). That's an upstream metadata bug worth fixing in a follow-up β it doesn't affect this recovery.