File size: 2,873 Bytes
3ccaf5a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | #!/usr/bin/env bash
###############################################################################
# StepProbe — Cleanup / Reset
#
# Usage:
# bash scripts/cleanup.sh --logs # remove logs only
# bash scripts/cleanup.sh --results # remove all results (keep code)
# bash scripts/cleanup.sh --cache # clear HuggingFace cache
# bash scripts/cleanup.sh --all # full reset
# bash scripts/cleanup.sh --phase 5 # remove phase 5+ outputs only
###############################################################################
set -euo pipefail
PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
TARGET="none"
PHASE=""
while [[ $# -gt 0 ]]; do
case $1 in
--logs) TARGET="logs"; shift ;;
--results) TARGET="results"; shift ;;
--cache) TARGET="cache"; shift ;;
--all) TARGET="all"; shift ;;
--phase) TARGET="phase"; PHASE=$2; shift 2 ;;
*) shift ;;
esac
done
confirm() {
read -p "⚠️ $1 Continue? [y/N] " -n 1 -r
echo
[[ $REPLY =~ ^[Yy]$ ]] || exit 0
}
case $TARGET in
logs)
confirm "This will delete all log files."
rm -rf "${PROJECT_DIR}/logs/"
echo "✅ Logs removed."
;;
results)
confirm "This will delete ALL experiment results."
rm -rf "${PROJECT_DIR}/results/"
rm -rf "${PROJECT_DIR}/figures/"
echo "✅ Results and figures removed."
;;
cache)
confirm "This will clear the HuggingFace model cache."
rm -rf ~/.cache/huggingface/hub/models--deepseek*
rm -rf ~/.cache/huggingface/hub/models--Qwen*
echo "✅ Model cache cleared."
;;
all)
confirm "This will delete ALL results, logs, figures, and caches."
rm -rf "${PROJECT_DIR}/results/"
rm -rf "${PROJECT_DIR}/figures/"
rm -rf "${PROJECT_DIR}/logs/"
echo "✅ Full reset complete."
;;
phase)
[[ -z "$PHASE" ]] && { echo "Specify phase number with --phase N"; exit 1; }
confirm "This will delete outputs from phase $PHASE onward."
case $PHASE in
2|3) rm -rf "${PROJECT_DIR}/results/inference/" ;&
4) rm -rf "${PROJECT_DIR}/results/segmented/" ;&
5) rm -rf "${PROJECT_DIR}/results/diagnosis/" ;&
6) rm -rf "${PROJECT_DIR}/results/metrics/" ;&
7) rm -rf "${PROJECT_DIR}/results/restored/" "${PROJECT_DIR}/results/silver_bullet/" ;&
8) find "${PROJECT_DIR}/results/inference/" -path "*_restored*" -exec rm -rf {} + 2>/dev/null ;&
9) rm -rf "${PROJECT_DIR}/figures/" ;;
*) echo "Unknown phase: $PHASE"; exit 1 ;;
esac
echo "✅ Phase $PHASE+ outputs removed."
;;
*)
echo "Usage: bash scripts/cleanup.sh --logs|--results|--cache|--all|--phase N"
;;
esac
|