"""Read the portable release without the original collection directories.""" from pathlib import Path import numpy as np from datasets import load_dataset, load_from_disk CACHES={'train':'local_RoboFAPE_train','test_ind':'setting_12_ind_test','test_ood':'setting_4_ood_test'} def resolve(root,relative): root=Path(root).resolve() if Path(relative).is_absolute():raise ValueError('Expected a release-relative path') path=(root/relative).resolve() if not path.is_relative_to(root):raise ValueError('Path escapes the release directory') return path def load_processed(root,split): return load_from_disk(str(Path(root)/'repro/processed'/CACHES[split]/'processed_dataset')) def read_frames(root,row): with np.load(resolve(Path(root)/'repro/processed',row['frames']),allow_pickle=False) as data: return data['frames'] def load_native(root,cache_dir=None): return load_dataset('parquet',data_files={s:sorted(str(p) for p in (Path(root)/'data'/s).glob('*.parquet')) for s in CACHES},cache_dir=cache_dir)