File size: 1,712 Bytes
a22c748
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
# Sync Torch MAPS checkpoints into tools/maps/torch_models/.
#
# Preference order for source tree:
#   1. $TORCH_MAPS_SRC / $MAPS_SRC
#   2. $HOME/TORCH-MAPS or $HOME/MAPS (local checkouts)
#   3. shallow clone of github.com/Tom-Brenner/TORCH-MAPS into third_party/TORCH-MAPS
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$ROOT/../.." && pwd)"
DEST="$ROOT/torch_models"

pick_src() {
  local cand
  for cand in \
    "${TORCH_MAPS_SRC:-}" \
    "${MAPS_SRC:-}" \
    "$HOME/TORCH-MAPS" \
    "$HOME/MAPS" \
    "$REPO_ROOT/third_party/TORCH-MAPS"
  do
    [[ -n "$cand" && -d "$cand/torch_models" ]] || continue
    echo "$cand"
    return 0
  done
  return 1
}

SRC="$(pick_src || true)"
if [[ -z "${SRC}" ]]; then
  CLONE_DIR="$REPO_ROOT/third_party/TORCH-MAPS"
  echo "No local TORCH-MAPS/MAPS checkout found; cloning into $CLONE_DIR ..."
  mkdir -p "$(dirname "$CLONE_DIR")"
  if [[ -d "$CLONE_DIR/.git" ]]; then
    git -C "$CLONE_DIR" pull --ff-only || true
  else
    git clone --depth 1 https://github.com/Tom-Brenner/TORCH-MAPS.git "$CLONE_DIR"
  fi
  SRC="$CLONE_DIR"
fi

if [[ ! -f "$SRC/torch_models/timbuck_eng.pt" ]]; then
  echo "Missing $SRC/torch_models/timbuck_eng.pt" >&2
  exit 1
fi

mkdir -p "$DEST/ensemble_model"
cp -f "$SRC/torch_models/timbuck_eng.pt" "$DEST/"
if [[ -f "$SRC/torch_models/manifest.json" ]]; then
  cp -f "$SRC/torch_models/manifest.json" "$DEST/"
fi
if compgen -G "$SRC/torch_models/ensemble_model/"*.pt >/dev/null; then
  cp -f "$SRC/torch_models/ensemble_model/"*.pt "$DEST/ensemble_model/"
fi
echo "Synced MAPS checkpoints from $SRC → $DEST"
ls -la "$DEST/timbuck_eng.pt" "$DEST/ensemble_model" | head