File size: 2,337 Bytes
e484a46
 
 
 
 
 
 
 
 
 
 
 
 
 
8ce4090
e484a46
 
8ce4090
e484a46
 
 
 
 
 
8ce4090
e484a46
 
 
 
 
 
 
 
 
8ce4090
 
 
 
 
e484a46
 
 
 
 
 
 
8ce4090
e484a46
 
 
 
 
 
 
 
 
 
 
 
 
8ce4090
e484a46
 
 
 
 
 
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
#!/usr/bin/env bash
# ===========================================
# validate_pipeline.sh — Canonical Smoke Test
# AI-Driven Polymer Aging Prediction System
# Requires: conda (or venv) already installed
# ===========================================

set -euo pipefail
RED='\033[0;31m'
GRN='\033[0;32m'
YLW='\033[1;33m'
NC='\033[0m'

die() {
    echo -e "${RED}[FAIL] $1${NC}"
    exit 1
}
pass() { echo -e "${GRN}[PASS] $1${NC}"; }

echo -e "${YLW}>>> Activating environment...${NC}"
source "$(conda info --base)/etc/profile.d/conda.sh"
conda activate polymer_env || die "conda env 'polymer_env' not found"

root_dir="$(dirname "$(readlink -f "$0")")"
cd "$root_dir" || die "repo root not found"

# ---------- Step 1: Preprocessing ----------
echo -e "${YLW}>>> Step 1: Preprocessing${NC}"
python scripts/preprocess_dataset.py datasets/rdwp \
    --target-len 500 --baseline --smooth --normalize |
    grep -q "X shape:" || die "preprocess_dataset.py failed"
pass "Preprocessing"

# ---------- Step 2: CV Training (Figure2) ----------
mkdir -p outputs outputs/logs || true
# Optional: skip gracefully if dataset is not present
if [ ! -d "datasets/rdwp" ] || [ -z "$(find datasets/rdwp -maxdepth 1 -name '*.txt' 2>/dev/null)" ]; then
echo -e "${YLW}{SKIP} Training (no datasets/rdwp/*.txt found)${NC}"
else
echo -e "${YLW}>>> Step 2: 10-Fold CV Training${NC}"
python scripts/train_model.py \
    --target-len 500 --baseline --smooth --normalize \
    --model figure2
[[ -f outputs/figure2_model.pth ]] || die "model .pth not found"
[[ -f outputs/logs/raman_figure2_diagnostics.json ]] || die "diagnostics JSON not found"
pass "Training & artifacts"
fi

# ---------- Step 3: Inference ----------
echo -e "${YLW}>>> Step 3: Inference${NC}"
python scripts/run_inference.py \
    --target-len 500 \
    --input datasets/rdwp/wea-100.txt \
    --model outputs/figure2_model.pth \
    --output outputs/inference/test_prediction.json
[[ -f outputs/inference/test_prediction.json ]] || die "inference output missing"
pass "Inference"

# ---------- Step 4: Spectrum Plot ----------
echo -e "${YLW}>>> Step 4: Plot Spectrum${NC}"
mkdir -p outputs/inference || true
python scripts/plot_spectrum.py --input datasets/rdwp/sta-10.txt
[[ $? -eq 0 ]] || die "plot_spectrum.py failed"
pass "Plotting"


echo -e "${GRN}All validation checks passed!${NC}"