-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSLURM_runner.py
More file actions
55 lines (40 loc) · 1.64 KB
/
SLURM_runner.py
File metadata and controls
55 lines (40 loc) · 1.64 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
import os
import sys
import random
import time
import glob
#update
root_dir = "/project/jonccal/common/sdrbench/"
applications = ["nyx"]
if not os.path.exists("./slurm_scripts"):
os.mkdir("slurm_scripts")
for app in applications:
print("\n\n\nStarting application: " + app + "\n")
for field in sorted(glob.glob( os.path.join(root_dir,app,"*") )):
print("\t" + os.path.basename(field))
fname = "job_"+app+"_"+ os.path.basename(field)+".slurm"
with open(fname,"w") as outfile:
#write slurm header
outfile.write("#!/bin/bash\n"
"#SBATCH --nodes 1\n"
"#SBATCH --tasks-per-node 8\n"
"#SBATCH --mem 8gb\n"
"#SBATCH --time 09:00:00\n"
"#SBATCH --job-name my-job-name\n"
#"#SBATCH -j oe\n"
"\n")
#load modules
outfile.write("module purge\n"
"module load gcc\n"
#"module load mpich\n"
"module list\n\n")
#set up spack and load libpressio if needed
outfile.write("source ~/spack/share/spack/setup-env.sh\n"
"spack env activate cprss\n\n")
#go to the location where the slurm was submitted
outfile.write("cd $SLURM_SUBMIT_DIR \n\n")
#issue the cmds that you need to run your workflow
outfile.write("./a.out \n")
#launch the job and cleanup
os.system("sbatch " + fname)
os.rename(fname, os.path.join("./slurm_scripts", fname))