RoboDojo-Task-Examples / scripts /build_browser.py
Travor278's picture
Pin browser to the reordered top-left-right video revision
68ed5f1 verified
Raw History Blame Contribute Delete
2.16 kB
"""Build a static HF Space task browser without duplicating any video files."""
from pathlib import Path
import json
ROOT=Path(__file__).resolve().parents[1]
DATA=ROOT/'dataset'
if not DATA.exists() and (ROOT/'provenance').exists():
DATA=ROOT
OUT=ROOT/'space'
REPO='Travor278/RoboDojo-Task-Examples'
MEDIA_REVISION='1d5b4c0a07f814d0b9c23b4e98c904b1b2afe4b1'
def build():
OUT.mkdir(exist_ok=True)
tasks=json.loads((DATA/'provenance/task_catalog.json').read_text(encoding='utf-8'))
samples=json.loads((DATA/'provenance/selected_episodes.json').read_text(encoding='utf-8'))
source=json.loads((DATA/'provenance/source.json').read_text(encoding='utf-8'))
payload={'tasks':tasks,'samples':samples,'source_revision':source['revision'],
'repo_url':f'https://huggingface.co/datasets/{REPO}',
'media_base':f'https://huggingface.co/datasets/{REPO}/resolve/{MEDIA_REVISION}/',
'file_base':f'https://huggingface.co/datasets/{REPO}/blob/{MEDIA_REVISION}/'}
assert len(tasks)==43 and len(samples)==105
template=(ROOT/'browser/index.html').read_text(encoding='utf-8')
encoded=json.dumps(payload,ensure_ascii=False,separators=(',',':')).replace('</','<\\/')
(OUT/'index.html').write_text(template.replace('__CATALOG_JSON__',encoded),encoding='utf-8')
(OUT/'README.md').write_text('''---
title: RoboDojo Task Examples
emoji: 🦾
colorFrom: green
colorTo: gray
sdk: static
app_file: index.html
pinned: false
fullWidth: true
---
# RoboDojo Task Examples Browser
Task-indexed MP4 browser for 43 official task pages, 105 selected demonstrations, and website evaluation demos.
Videos are read directly from the curated HF dataset. This Space contains only static HTML and task metadata, no duplicate video data.
Dataset: https://huggingface.co/datasets/Travor278/RoboDojo-Task-Examples
Deep links use `?task=0` through `?task=34`; eval-only tasks use task keys such as `?task=align_blocks`.
''',encoding='utf-8')
print(f'Built static browser: {len(tasks)} tasks / {len(samples)} demonstrations / {(OUT/"index.html").stat().st_size:,} HTML bytes')
if __name__=='__main__':
build()