-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_utils.py
55 lines (49 loc) · 2.02 KB
/
run_utils.py
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, yaml
from pathlib import Path
from itertools import count
dumpdir = "runs_new_cn_jan24/"
if not os.path.isdir(dumpdir):
os.mkdir(dumpdir)
fixed_text = "#!/bin/bash\n"\
"#SBATCH --nodes=1\n"\
"#SBATCH --cpus-per-task=16 \n"\
"#SBATCH --time=48:00:00\n"\
"#SBATCH --mem=40GB\n"
config_file = "configs/cn.yaml"
with open(config_file, "r") as stream:
try: config = yaml.safe_load(stream)
except yaml.YAMLError as exc: print(exc)
for n_agents in [3, 5, 7, 10]:
for dru_toggle in [0, 1]:
for meslen in [0, 1]:
for randomseed in [ 2528, 66962, 34046, 58876, 84054, 34131, 33989, 59004, 94644, 98216 ]:
if (dru_toggle==1) and (meslen==0):
continue
exp = str(randomseed)
command = fixed_text + "#SBATCH --job-name="+exp+"\n#SBATCH --output="+exp+".out\n"
command += "\nsource ../venvs/hammer/bin/activate\n"\
"\nmodule load python/intel/3.8.6\n"\
"module load openmpi/intel/4.0.5\n"\
"time python3 hammer-run.py "
command = ' '.join([
command,
'--envname cn',
'--config configs/cn.yaml',
'--nagents', str(n_agents),
'--dru_toggle', str(dru_toggle),
'--meslen', str(meslen),
'--partialobs 0',
'--heterogeneity 0',
'--randomseed', str(randomseed),
])
# print(command)
log_dir = Path(dumpdir)
for i in count(1):
temp = log_dir/('run{}.sh'.format(i))
if temp.exists():
pass
else:
with open(temp, "w") as f:
f.write(command)
log_dir = temp
break