File size: 788 Bytes
93be2a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
set -euo pipefail

if [ "$#" -lt 2 ]; then
  echo "Usage: $0 <src_checkpoint_dir> <dest_model_dir>" >&2
  exit 1
fi

SRC="$1"
DEST="$2"

echo "[promote] Validating source: $SRC"
for f in model-00001-of-00004.safetensors model-00002-of-00004.safetensors model-00003-of-00004.safetensors model-00004-of-00004.safetensors config.json tokenizer.json tokenizer_config.json merges.txt vocab.json added_tokens.json model.safetensors.index.json; do
  if [ ! -f "$SRC/$f" ]; then
    echo "[promote] Missing $f in $SRC" >&2
    exit 2
  fi
done

ts=$(date +%F_%H-%M-%S)
backup="${DEST}.bak_${ts}"
echo "[promote] Backing up $DEST -> $backup"
cp -a "$DEST" "$backup"

echo "[promote] Copying new weights"
rsync -a --delete "$SRC/" "$DEST/"

echo "[promote] Promotion complete"