adaptai / platform /aiml /mlops /elizabeth_logs_sync.sh
ADAPT-Chase's picture
Add files using upload-large-folder tool
42bba47 verified
#!/usr/bin/env bash
set -euo pipefail
# Sync all Elizabeth-related logs into a single project view and build an index.
# No compression; preserve raw logs to support training and tracing.
SRC_DIR="/data/adaptai/platform/aiml/mlops/logs"
DST_DIR="/data/adaptai/projects/elizabeth/logs"
mkdir -p "$DST_DIR"
rsync -a --delete-delay "$SRC_DIR/" "$DST_DIR/"
# Build INDEX.md with basic metadata extracted from logs
INDEX="$DST_DIR/INDEX.md"
{
echo "# Elizabeth Logs Index"
echo
echo "Generated: $(date -Iseconds)"
echo
echo "| File | Modified | Size | Model | Port | PID |"
echo "|------|----------|------|-------|------|-----|"
# Iterate newest first
while IFS= read -r -d '' f; do
mod_time=$(date -r "$f" '+%Y-%m-%d %H:%M:%S' 2>/dev/null || stat -c '%y' "$f" | cut -d'.' -f1)
size_h=$(du -h "$f" | awk '{print $1}')
# Grep a few hints
serve_line=$(grep -m1 -E 'Serving .* as .* on ' "$f" || true)
model=$(echo "$serve_line" | sed -n 's/^Serving \(.*\) as .*/\1/p')
port=$(echo "$serve_line" | sed -n 's/.*on [^:]*:\([0-9][0-9]*\).*/\1/p')
pid=$(grep -m1 -E '\(APIServer pid=|APIServer pid=' "$f" | sed -n 's/.*pid=\([0-9][0-9]*\).*/\1/p' || true)
rel="$(basename "$f")"
echo "| $rel | $mod_time | $size_h | ${model:-} | ${port:-} | ${pid:-} |"
done < <(find "$DST_DIR" -maxdepth 1 -type f -name "*.log" -print0 | xargs -0 ls -1t | tr '\n' '\0')
} > "$INDEX"
# Maintain a convenience symlink to the latest serve log, if any
latest_log=$(ls -1t "$DST_DIR"/serve_elizabeth_vllm_*.log 2>/dev/null | head -n1 || true)
if [[ -n "$latest_log" ]]; then
ln -sfn "$latest_log" "$DST_DIR/latest.log"
fi
echo "Logs synced to: $DST_DIR"
echo "Index written: $INDEX"