mergebench-property-sweep / code /scripts /restore_from_hub.sh
suchirsalhan's picture
Back up code/scripts/restore_from_hub.sh
d545a7e verified
Raw
History Blame Contribute Delete
1.18 kB
#!/usr/bin/env bash
# Restore the MergeBench artefacts from the Hub copy after a working-tree loss.
#
# We have published additively all night, so the dataset repo is the authoritative backup. This
# downloads it to a staging directory and reports what is there; it does NOT overwrite anything by
# itself -- the caller decides what to put back, because a partially-restored tree that then gets
# republished is how good artefacts become degraded ones.
#
# bash scripts/restore_from_hub.sh [staging_dir]
set -u
cd "$(dirname "$0")/.."
PY=${PYTHON:-/root/venvs/mergeability/bin/python}
[ -f /root/.ms_hf_env ] && set -a && . /root/.ms_hf_env && set +a
DEST=${1:-/root/mergebench_restore}
PYTHONPATH=src exec "$PY" - "$DEST" <<'PY'
import sys, os
from huggingface_hub import snapshot_download
dest = sys.argv[1]
p = snapshot_download("Mergeability-2/mergebench-property-sweep", repo_type="dataset",
local_dir=dest)
print("restored snapshot ->", p)
for root, _d, files in os.walk(p):
if ".cache" in root:
continue
for f in sorted(files):
fp = os.path.join(root, f)
print(f" {os.path.getsize(fp):9d} {os.path.relpath(fp, p)}")
PY