-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sh
More file actions
95 lines (76 loc) · 2.61 KB
/
script.sh
File metadata and controls
95 lines (76 loc) · 2.61 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
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
#SBATCH --job-name=poisson_exp
#SBATCH --output=logs/poisson_exp_%j.out
#SBATCH --error=logs/poisson_exp_%j.err
#SBATCH --time=02:00:00
#SBATCH --partition=barnard
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=4
#SBATCH --mem=8G
#SBATCH --mail-type=FAIL
#SBATCH --mail-user=anna.kurova@tu-dresden.de
# ------------------------ SETUP ------------------------
WSNAME=poisson_$SLURM_JOB_ID
export WSDIR=$(ws_allocate --filesystem horse --name "$WSNAME" --duration 2)
test -z "$WSDIR" && echo "Error: Failed to allocate workspace." && exit 1
echo "Allocated workspace: $WSDIR"
rsync -av \
--exclude="models_notebooks/" \
--exclude="logs/" \
--exclude="run_results*/" \
--exclude="results/" \
--exclude=".git" \
--exclude=".*" \
--exclude="plots" \
--exclude="*.sh" \
--exclude="*.pth" \
--exclude="*.md" \
--exclude="helpers/" \
"$HOME/score_matching/" \
"$WSDIR/"
cd "$WSDIR" || { echo "Failed to cd into $WSDIR"; exit 1; }
echo "Working inside $WSDIR"
python -m venv .venv
source .venv/bin/activate
export TMPDIR="$WSDIR/tmp_pip"
export PIP_CACHE_DIR="$WSDIR/pip_cache"
mkdir -p "$TMPDIR" "$PIP_CACHE_DIR"
pip install --upgrade pip
pip install --cache-dir="$PIP_CACHE_DIR" -r requirements.txt
RUN_RESULTS_DIR="$HOME/score_matching/run_results_statistical_analysis_distance_weight"
mkdir -p "$RUN_RESULTS_DIR"
echo "Results will be stored in $RUN_RESULTS_DIR"
# ------------------------ EXPERIMENT LOOP ------------------------
SCRIPT_NAME="poisson_experiment"
NUM_JOBS=10
for i in $(seq 1 $NUM_JOBS); do
(
echo "Running iteration $i"
WORK_DIR="workspace_$i"
mkdir -p "$WORK_DIR"
CONFIG_FILE="$WORK_DIR/configs/config_${SCRIPT_NAME}_iteration_${i}.json"
mkdir -p "$WORK_DIR/configs"
cp "configs/config_${SCRIPT_NAME}_${i}.json" "$CONFIG_FILE"
sed -i "s/\"region\": \"[^\"]*\"/\"region\": \"region_${i}\"/" "$CONFIG_FILE"
python "src/run_script.py" \
--script "$SCRIPT_NAME" \
--config "$CONFIG_FILE" \
--workspace "$WORK_DIR"
if [ -d "$WORK_DIR/results" ]; then
DEST="$RUN_RESULTS_DIR/results_${SCRIPT_NAME}_job_${SLURM_JOB_ID}_iteration_$i"
cp -r "$WORK_DIR/results/" "$DEST"
echo "Copied results for iteration $i to $DEST"
else
echo "No results directory found for iteration $i"
fi
rm -rf "$WORK_DIR"
echo "Cleaned up workspace for iteration $i"
) &
done
wait
echo "All parallel runs completed."
# ------------------------ CLEANUP ------------------------
rm -rf "$TMPDIR" "$PIP_CACHE_DIR"
echo "Temporary pip/cache directories cleaned up."
ws_release -F horse "$WSNAME"
echo "Workspace $WSNAME released successfully."