-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerge_results.sh
More file actions
83 lines (65 loc) · 2.56 KB
/
Copy pathmerge_results.sh
File metadata and controls
83 lines (65 loc) · 2.56 KB
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
#!/bin/bash
set -euo pipefail
module load python
eval "$(conda shell.bash hook)"
conda activate CI
CONFIG_PATH=${1:?Usage: ./merge_results.sh <config_path e.g. classif/config_classif>}
CFG_ROOT="src/cfg"
CONFIG_FILE="${CFG_ROOT}/${CONFIG_PATH}.yaml"
CONFIG_DIR=$(dirname "$CONFIG_PATH") # e.g. "classif"
ABLATION_GROUP="${CONFIG_DIR}/ablations" # e.g. "classif/ablations"
if [[ ! -f "$CONFIG_FILE" ]]; then
echo "ERROR: Config file not found: $CONFIG_FILE"
exit 1
fi
# ── Extract from main config (mirrors run_all.sh) ──────────────────
mapfile -t EXPERIMENTS < <(
python src/utils/extract_sweep.py run_plan.experiments \
--config "$CONFIG_FILE"
)
SWEEP_FILE_REL=$(python src/utils/extract_sweep.py run_plan.sweep_file \
--config "$CONFIG_FILE")
SWEEP_FILE="${CFG_ROOT}/${SWEEP_FILE_REL}"
if [[ ! -f "$SWEEP_FILE" ]]; then
echo "ERROR: Sweep file not found: $SWEEP_FILE"
exit 1
fi
# Determine task type from config directory name
if [[ "$CONFIG_DIR" == *"classif"* ]]; then
TASK_TYPE="classif"
elif [[ "$CONFIG_DIR" == *"segm"* ]]; then
TASK_TYPE="segm"
else
echo "ERROR: Cannot infer task type (classif/segm) from config path: $CONFIG_DIR"
exit 1
fi
echo "========================================"
echo " Config file: $CONFIG_FILE"
echo " Ablation group: $ABLATION_GROUP"
echo " Sweep file: $SWEEP_FILE"
echo " Task type: $TASK_TYPE"
echo " Experiments: ${EXPERIMENTS[*]}"
echo "========================================"
echo ""
for EXPERIMENT in "${EXPERIMENTS[@]}"; do
echo "──────────────────────────────────────"
echo " Merging: $EXPERIMENT"
echo "──────────────────────────────────────"
# relative_output_dir is overridden in each ablation config
ABLATION_CFG="${CFG_ROOT}/${ABLATION_GROUP}/${EXPERIMENT}.yaml"
if [[ ! -f "$ABLATION_CFG" ]]; then
echo " WARNING: Ablation config not found: $ABLATION_CFG — skipping."
continue
fi
RESULTS_DIR=$(python src/utils/extract_sweep.py relative_output_dir \
--config "$ABLATION_CFG")
echo " Results dir: $RESULTS_DIR"
python src/utils/merge_dataframes.py \
--results_dir "$RESULTS_DIR" \
--sweep_file "$SWEEP_FILE" \
--task_type "$TASK_TYPE"
echo ""
done
echo "========================================"
echo " All merges complete."
echo "========================================"