| #!/usr/bin/env bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| 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 |
|
|