Add dataset manifest, checksums and download helper
Browse files- download.py +42 -0
download.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Download selected ForceBench training tasks and expose their historical LeRobot IDs."""
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import argparse
|
| 4 |
+
import json
|
| 5 |
+
from huggingface_hub import HfApi, snapshot_download
|
| 6 |
+
|
| 7 |
+
REPO = 'hanxuan2003/ForceBench'
|
| 8 |
+
|
| 9 |
+
def main():
|
| 10 |
+
p=argparse.ArgumentParser(description=__doc__)
|
| 11 |
+
p.add_argument('--task',action='append',help='Repeat to select tasks; omit for all eight.')
|
| 12 |
+
p.add_argument('--root',type=Path,default=Path('forcebench_data'))
|
| 13 |
+
p.add_argument('--revision',default='main',help='A commit or tag; resolved once and pinned for the download.')
|
| 14 |
+
args=p.parse_args()
|
| 15 |
+
root=args.root.expanduser().resolve()
|
| 16 |
+
sha=HfApi().dataset_info(REPO,revision=args.revision).sha
|
| 17 |
+
target=root/'releases'/sha
|
| 18 |
+
snapshot_download(REPO,repo_type='dataset',revision=sha,local_dir=target,
|
| 19 |
+
allow_patterns=['manifest.json','checksums.json','README.md'])
|
| 20 |
+
manifest=json.loads((target/'manifest.json').read_text())
|
| 21 |
+
available={x['task']:x for x in manifest['datasets']}
|
| 22 |
+
tasks=args.task or list(available)
|
| 23 |
+
unknown=set(tasks)-available.keys()
|
| 24 |
+
if unknown:p.error('Unknown task(s): '+', '.join(sorted(unknown)))
|
| 25 |
+
snapshot_download(REPO,repo_type='dataset',revision=sha,local_dir=target,
|
| 26 |
+
allow_patterns=[f'tasks/{task}/**' for task in tasks])
|
| 27 |
+
home=root/'lerobot'
|
| 28 |
+
for task in tasks:
|
| 29 |
+
row=available[task]
|
| 30 |
+
src=target/'tasks'/task
|
| 31 |
+
link=home/row['historical_repo_id']
|
| 32 |
+
link.parent.mkdir(parents=True,exist_ok=True)
|
| 33 |
+
if link.exists() or link.is_symlink():
|
| 34 |
+
if link.resolve()!=src.resolve():
|
| 35 |
+
raise RuntimeError(f'Existing dataset left unchanged: {link}. Use another --root to download this revision.')
|
| 36 |
+
else:link.symlink_to(src,target_is_directory=True)
|
| 37 |
+
print(task,'->',link)
|
| 38 |
+
print('Pinned dataset revision:',sha)
|
| 39 |
+
print('Set HF_LEROBOT_HOME to:',home)
|
| 40 |
+
print('Use the matching historical_repo_id from manifest.json in your LeRobot v2.1-compatible training configuration.')
|
| 41 |
+
|
| 42 |
+
if __name__=='__main__':main()
|