PortSimEnv / fetch_assets.py
AdithyaSK's picture
AdithyaSK HF Staff
Upload folder using huggingface_hub
a1e3907 verified
Raw History Blame Contribute Delete
1.04 kB
"""Build step: download the binary assets from the public bucket (twin data into the installed viewer, the
gzipped train pack into /app/tasks). A Docker Space build copies LFS pointer files, so binaries can't come from the
Space repo."""
import pathlib
import urllib.request
import berth_openenv
twin = pathlib.Path(berth_openenv.__file__).parent / "web" / "twin"
files = {"twin/" + n: twin / n for n in ['twin.json.gz', 'terrain.png', 'cover.png', 'scenery.json.gz', 'surface.webp']}
files.update({p: pathlib.Path("/app") / p for p in ['tasks/dock-v1-train/tasks.jsonl.gz']})
for remote, local in files.items():
if local.is_file():
continue
local.parent.mkdir(parents=True, exist_ok=True)
with urllib.request.urlopen("https://huggingface.co/buckets/FineEnvs/PortSimEnv/resolve/" + remote, timeout=120) as r:
body = r.read()
if body.startswith(b"version https://git-lfs") or len(body) < 1000:
raise SystemExit("bad download for " + remote)
local.write_bytes(body)
print(remote, len(body))