diffusion-gif's picture
data: licensed simulation observations, trajectories and public rationale drafts
ce60264 verified
Raw History Blame Contribute Delete
2.83 kB
"""Allowlisted public simulation record schema; no account or source-ID fields."""
import math,re
SOURCES={'RoboTwin2.0':'mit','DexMimicGen':'cc-by-nc-sa-4.0'}
BODIES={'aloha','arx','franka','piper','ur5','dmg'}
FIELDS={'sample_id','group_id','split','source_dataset','license','robot_body','task',
'coordinate_space','point_names','n_hist','n_fut','forecast_arm_count',
'history','anchor','future_delta','hw','media_archive','media_member','media_sha256'}
TEXT_RISK=re.compile(r'\bhf_[A-Za-z0-9]{25,}|\bghp_[A-Za-z0-9]{25,}|\bgithub_pat_[A-Za-z0-9_]{25,}|\bsk-[A-Za-z0-9_-]{25,}|-----BEGIN [A-Z ]*PRIVATE KEY-----|/(?:pfs|root|home|Users)/|https?://|[\w.+-]+@[\w.-]+\.[A-Za-z]{2,}',re.I)
def validate(row):
if set(row)!=FIELDS:raise ValueError('Non-allowlisted record field')
for k in ('sample_id','group_id'):
if not re.fullmatch('[0-9a-f]{32}',row[k]):raise ValueError('Identifier not pseudonymous')
if row['source_dataset'] not in SOURCES or row['license']!=SOURCES[row['source_dataset']]:raise ValueError('Unknown source/license')
if row['robot_body'] not in BODIES or row['split'] not in ('train','heldout'):raise ValueError('Unknown body/split')
if not re.fullmatch('[a-z0-9_]{1,80}',row['task']):raise ValueError('Non-enumerated task text')
if row['coordinate_space']!='normalized_1000_anchor_delta' or (row['n_hist'],row['n_fut'])!=(8,8):raise ValueError('Wrong protocol')
arms=row['forecast_arm_count']
if arms not in (1,2) or len(row['point_names'])!=arms:raise ValueError('Wrong point/arm count')
if any(p not in ('left_eef_origin','right_eef_origin') for p in row['point_names']):raise ValueError('Not fixed EEF points')
for name in ('history','future_delta'):
if len(row[name])!=arms:raise ValueError('Wrong arm-first dimension')
for arm in row[name]:
if len(arm)!=8:raise ValueError('Wrong time dimension')
for point in arm:
if len(point)!=2 or any(type(v) not in (int,float) or not math.isfinite(v) for v in point):raise ValueError('Invalid numeric XY')
if row['anchor']!=[arm[-1] for arm in row['history']]:raise ValueError('Wrong anchor')
for a in range(arms):
for xy in row['history'][a]:
if any(v<0 or v>1000 for v in xy):raise ValueError('Observed point out of view')
for delta in row['future_delta'][a]:
if any(row['anchor'][a][i]+delta[i]<0 or row['anchor'][a][i]+delta[i]>1000 for i in range(2)):raise ValueError('Future point out of view')
if len(row['hw'])!=2 or any(type(v)!=int or not 1<=v<=4096 for v in row['hw']):raise ValueError('Invalid frame dimensions')
if not re.fullmatch('data/archives/(train|heldout)-[0-9]{5}\\.tar',row['media_archive']):raise ValueError('Unsafe archive path')
if row['media_member']!=row['sample_id']+'.npz' or not re.fullmatch('[0-9a-f]{64}',row['media_sha256']):raise ValueError('Unsafe media identity')
return row