File size: 2,781 Bytes
af506d9
 
cb10448
af506d9
 
 
cb10448
 
 
 
 
 
 
 
af506d9
 
cb10448
 
 
 
 
af506d9
cb10448
af506d9
 
 
 
 
 
cb10448
af506d9
 
cb10448
 
 
 
 
 
 
 
 
 
 
 
 
 
 
af506d9
cb10448
 
af506d9
cb10448
 
af506d9
 
 
 
 
 
 
 
 
cb10448
 
af506d9
cb10448
 
af506d9
 
 
cb10448
af506d9
 
cb10448
 
af506d9
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/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"