#!/usr/bin/env bash
set -u
cd /home/mande/repo/quber
LOG=experiments/que259/out/docling.log
: > "$LOG"
# smallest-first so the 126MB doc is last
for pdf in $(ls -S -r experiments/que259/inputs/*.pdf); do
  id=$(basename "$pdf" .pdf)
  if [[ -f experiments/que259/docling/$id.docling.json ]]; then
    echo "[$id] docling exists, skip" | tee -a "$LOG"; continue
  fi
  echo "[$id] START $(date +%T) size=$(du -h "$pdf"|cut -f1)" | tee -a "$LOG"
  uv run quber document --format json -o experiments/que259/docling "$pdf" >>"$LOG" 2>&1
  echo "[$id] docling rc=$? $(date +%T)" | tee -a "$LOG"
done
echo "DOCLING_COMPLETE $(date +%T)" | tee -a "$LOG"
