data / sync_dualsim.sh
chen-gao's picture
Sync root metadata
cb10448 verified
Raw
History Blame Contribute Delete
2.78 kB
#!/usr/bin/env bash
#
# MIRROR-sync this local `dualsim` folder to the Hugging Face dataset repo.
#
# Repo: https://huggingface.co/datasets/chen-gao/dualsim
#
# Uses `hf upload --delete "*"` per subtree so the Hub becomes an EXACT MIRROR of
# local: new/changed files are uploaded, and files deleted locally are ALSO deleted
# on the Hub. `hf upload` hashes files, so unchanged files are skipped (only deltas
# transfer). Each run is a versioned commit on the Hub.
#
# --delete is scoped to each subtree's path_in_repo (verified against
# huggingface_hub._prepare_folder_deletions: patterns are matched RELATIVE to
# path_in_repo), so the `eval` sync can never touch `train/` and vice-versa.
#
# Usage:
# ./sync_dualsim.sh # mirror meta + eval + train
# ./sync_dualsim.sh eval # mirror eval subtree only (fast)
# ./sync_dualsim.sh train # mirror train/AgiBotWorld2026 only
# ./sync_dualsim.sh meta # push root files (README/.gitattributes/this script)
# DRY=1 ./sync_dualsim.sh eval # print what would upload/delete, do nothing
#
# Prereq: `hf auth login` (write token) done once.
set -euo pipefail
REPO="chen-gao/dualsim"
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WHAT="${1:-all}"
DRY="${DRY:-0}"
hf_bin="$(command -v hf || echo "$HOME/.local/bin/hf")"
run() {
if [[ "$DRY" == "1" ]]; then echo "[DRY-RUN] $*"; else "$@"; fi
}
# Root-level files only (README, .gitattributes, sync script). No --delete here to
# avoid ever matching the eval/ or train/ subtrees at repo root.
sync_meta() {
echo ">> Uploading root metadata files ..."
run "$hf_bin" upload "$REPO" "$HERE" . \
--repo-type dataset \
--exclude "eval/**" --exclude "train/**" \
--exclude ".git/**" --exclude "**/__pycache__/**" --exclude "*.pyc" \
--commit-message "Sync root metadata"
}
sync_eval() {
echo ">> Mirroring eval/ subtree (uploads changes, deletes stale) ..."
run "$hf_bin" upload "$REPO" "$HERE/eval" eval \
--repo-type dataset \
--delete "*" \
--commit-message "Mirror eval"
}
sync_train() {
local src
src="$(readlink -f "$HERE/train/AgiBotWorld2026")"
if [[ ! -d "$src" ]]; then
echo "!! train/AgiBotWorld2026 does not resolve to a directory ($src) — skipping train." >&2
return 0
fi
echo ">> Mirroring train/AgiBotWorld2026 subtree from $src ..."
run "$hf_bin" upload "$REPO" "$src" train/AgiBotWorld2026 \
--repo-type dataset \
--delete "*" \
--commit-message "Mirror train/AgiBotWorld2026"
}
case "$WHAT" in
meta) sync_meta ;;
eval) sync_eval ;;
train) sync_train ;;
all) sync_meta; sync_eval; sync_train ;;
*) echo "Usage: $0 [all|meta|eval|train] (DRY=1 for dry-run)" >&2; exit 2 ;;
esac
echo ">> Done. https://huggingface.co/datasets/$REPO"