-
Notifications
You must be signed in to change notification settings - Fork 0
/
batch_parallel.sh
66 lines (56 loc) · 1.53 KB
/
batch_parallel.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
#
#SBATCH -J victree
#SBATCH -t 15:00:00
#SBATCH --mem=8192
#SBATCH --ntasks 8
#SBATCH --cpus-per-task 4
#SBATCH --mail-type=ALL
#SBATCH [email protected]
#
# Function to process each YAML file
process_yaml() {
local yaml_file="$1"
echo "running config $1"
srun --exclusive --ntasks=1 --cpus-per-task=4 --mem=1024 \
run_victree_analysis.sh "${yaml_file}"&
}
# Function to recursively search for YAML files
search_yaml() {
local dir="$1"
# Loop through all files and directories in the given directory
for file in "$dir"/*; do
if [ -f "$file" ]; then
# Check if the file is a YAML file
if [[ "$file" == *.yaml || "$file" == *.yml ]]; then
# Check if the YAML file contains an 'input' key
if grep -q '^[[:space:]]*input:' "$file"; then
process_yaml "$file"
fi
fi
elif [ -d "$file" ]; then
# Recursively search the subdirectory
search_yaml "$file"
fi
done
}
# validate input
if [ $# -ne 1 ]; then
echo "Usage: $0 <directory>"
exit 1
fi
# load all required modules and libraries
module add Python/3.10.4-env-nsc1-gcc-2022a-eb
source "/proj/sc_ml/shared/envs/copytree-venv/bin/activate"
module add R/4.2.2-nsc1-gcc-11.3.0-bare
export R_LIBS="/proj/sc_ml/shared/envs/r-libs"
#export R_LIBS_USER="/proj/sc_ml/shared/envs/r-libs"
export NUMEXPR_MAX_THREADS=32
directory="$1"
# Check if the provided directory exists
if [ ! -d "$directory" ]; then
echo "Error: Directory '$directory' not found."
exit 1
fi
search_yaml "$directory"
wait