migration: relabel robot_type to 'unknown' when SO name doesn't match structure

is_so is decided purely from the robot_type string, so datasets labeled
so100/so101 whose joint dim isn't a multiple of 6 carry a provably wrong label.
Rewrite meta/info.json robot_type to 'unknown' in that case so the v3.0 output
isn't misidentified as an SO arm.
This commit is contained in:
CarolinePascal
2026-07-17 15:23:21 +02:00
parent 9e3dc7c43c
commit 0ec7c912e7
+12 -3
View File
@@ -17,6 +17,13 @@ def _stack(col_values) -> np.ndarray:
return np.stack([np.asarray(v, dtype=np.float64) for v in col_values]) # (N, D)
def _set_robot_type(root: Path, robot_type: str) -> None:
info_path = root / "meta" / "info.json"
info = json.loads(info_path.read_text())
info["robot_type"] = robot_type
info_path.write_text(json.dumps(info, indent=4))
def _rewrite_parquet(root: Path, encoding: str) -> None:
for pq in sorted((root / "data").glob("*/*.parquet")):
df = pd.read_parquet(pq)
@@ -82,10 +89,12 @@ def fix_dataset_in_place(root) -> dict:
dims = [feats[c]["shape"][0] for c in VALUE_COLS if c in feats and feats[c].get("shape")]
if any(d % 6 != 0 for d in dims):
# Not a plain stack of 6-joint SO arms (e.g. 7-dim with an appended EE pose): the
# degrees mapping doesn't apply, so migrate structurally and leave the values alone.
return {**cls, "converted": False,
# degrees mapping doesn't apply. The `so100`/`so101` robot_type is provably wrong for
# this structure, so relabel it 'unknown' and migrate structurally without touching values.
_set_robot_type(root, "unknown")
return {**cls, "robot_type": "unknown", "converted": False,
"action": f"structural v2.1->v3.0 only; joint dims {dims} not a multiple of 6 "
"(non-standard arm), joint values left unchanged"}
"(non-standard arm), robot_type set to 'unknown', joint values left unchanged"}
# drop stray files that would otherwise be uploaded
for junk in (root / "meta").glob("info.json.bak"):
junk.unlink()