copernicus-rag-core / scripts /pubs_rag /run_embed_loop.sh
dmpantiu's picture
Upload folder using huggingface_hub
0ec8fd6 verified
Raw
History Blame Contribute Delete
1.08 kB
#!/usr/bin/env bash
# run_embed_loop.sh — run embed_orchestrator every INTERVAL until EMBED_DONE.
# Each pass: poll in-flight shard jobs, download completed, submit more shards
# until the daily quota 429s. Stops when out/EMBED_DONE appears.
set -uo pipefail
cd /Users/dmpantiu/copernicus_mcp/pubs_rag
PY=/Users/dmpantiu/copernicus_mcp/marine_rag/.venv/bin/python
LOG=out/embed_loop.log
INTERVAL=180
MAX=400 # ~20h at 180s
ts(){ date '+%Y-%m-%d %H:%M:%S'; }
log(){ echo "[$(ts)] $*" | tee -a "$LOG"; }
TOTAL=$(wc -l < out/chunks.jsonl | tr -d ' ')
log "=== embed loop started (total $TOTAL chunks) ==="
i=0
while [ "$i" -lt "$MAX" ]; do
i=$((i+1))
if [ -f out/EMBED_DONE ]; then
log "EMBED_DONE present — stopping loop."
break
fi
log "pass $i"
$PY embed_orchestrator.py >> "$LOG" 2>&1
emb=$([ -f out/chunks_embedded.jsonl ] && wc -l < out/chunks_embedded.jsonl | tr -d ' ' || echo 0)
log "pass $i done — embedded $emb/$TOTAL"
[ -f out/EMBED_DONE ] && { log "complete."; break; }
sleep "$INTERVAL"
done
log "=== embed loop exiting (pass $i) ==="