← back to Designer Wallcoverings

onboarding/sangetsu-lilycolor/scripts/sangetsu-pipeline.sh

17 lines

#!/bin/bash
# Autonomous chain: wait for the rep-image download to finish, then run the
# swap-guarded per-pattern Sangetsu enrichment. Self-completing.
set -u
PROJ="$HOME/Projects/Designer-Wallcoverings/onboarding/sangetsu-lilycolor"; cd "$PROJ"
ST="$PROJ/staging"; CACHE="$HOME/dw-sangetsu-images-local"
log(){ echo "[sg-pipe $(date '+%H:%M:%S')] $*" >> "$ST/sangetsu-pipeline.log"; }
# wait until the download python is gone AND cache size stabilizes
prev=-1
while pgrep -f 'sangetsu-staging.jsonl.*urllib\|urllib.*sangetsu' >/dev/null 2>&1 || true; do
  n=$(ls -1 "$CACHE"/*.jpg 2>/dev/null | wc -l | tr -d ' ')
  if [ "$n" = "$prev" ]; then log "cache stable at $n imgs — download done"; break; fi
  prev=$n; log "waiting on download (cache=$n)"; sleep 45
done
log "launching enrichment on $(ls -1 "$CACHE"/*.jpg 2>/dev/null | wc -l | tr -d ' ') imgs"
exec bash "$PROJ/scripts/sangetsu-enrich-guarded.sh"