salience-editor/deploy-models.sh

33 lines
1.1 KiB
Bash
Raw Normal View History

2025-11-02 13:09:23 -08:00
#!/bin/sh
set -eu
# rsync local models_cache to server shared cache
# reports server models not in local (manual cleanup required)
ssh=deploy-peoplesgrocers-website
base=/home/peoplesgrocers
project=salience
ssh $ssh "mkdir -p $base/$project/shared/models_cache"
test -d api/models_cache || { echo 'no local api/models_cache'; exit 1; }
echo "local models_cache size:"
du -sh api/models_cache
echo "syncing to $ssh:$base/$project/shared/models_cache/"
# do not use compression because these model files are basically random data
# the SSH connection is pretty spotting when transferring large files
rsync -va --info=progress2 --partial --append-verify api/models_cache/ $ssh:$base/$project/shared/models_cache/
# local models
local=$(cd api/models_cache && find . -maxdepth 2 -name 'models--*' -type d | sed 's|./||' | sort)
# server models
remote=$(ssh $ssh "cd $base/$project/shared/models_cache && find . -maxdepth 2 -name 'models--*' -type d | sed 's|./||'" | sort)
# report server models not in local
echo "checking for unused models on server..."
for r in $remote; do
echo "$local" | grep -q "^${r}$" || echo "unused: $r"
done