-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathHPC_run_all_exp.sh
50 lines (44 loc) · 1.38 KB
/
HPC_run_all_exp.sh
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
#!/bin/bash
# BEHAVIOR:
# Parses the abm/data/metarunner/experiments folder and runs each experiment py file in the folder on the HPC cluster.
# Each experiment will be run on a different node.
# Prepares the environment on the gateway such es env files, empty folders for logging and errors of the jobs, etc.
# Initializing SLURM logging structure
if [ ! -d "slurm_log" ]; then
mkdir slurm_log
echo "Directory for job logs initialized..."
fi
# Parsing experiment files
search_dir=./abm/data/metaprotocol/experiments
if [ ! -d "$search_dir" ]; then
echo "Can not find experiments folder..."
exit 1
else
echo "Found experiment folder $search_dir"
fi
# Find experiment files and their names
exp_path_array=()
exp_name_array=()
for exp_path in "$search_dir"/*.py
do
exp_name=$(basename $exp_path .py)
echo "Found experiment: $exp_name"
exp_path_array+=("$exp_path")
exp_name_array+=("$exp_name")
done
# Prepare empty env files for each experiment on root
for exp_name in "${exp_name_array[@]}"
do
if [ ! -f "./$exp_name.env" ]; then
cp ./.env ./$exp_name.env
echo "Created default env file for experiment $exp_name"
else
echo "Env file already exists for experiment $exp_name"
fi
done
# Run an experiment on a dedicated node
for exp_name in "${exp_name_array[@]}"
do
echo "Starting experiment $exp_name"
sbatch --export=EXPERIMENT_NAME=$exp_name ./HPC_batch_run.sh
done