-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_jobs.py
More file actions
55 lines (40 loc) · 1.5 KB
/
make_jobs.py
File metadata and controls
55 lines (40 loc) · 1.5 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
#!/usr/bin/env python3
import yaml
import os
import stat
import sys
import time
from subprocess import check_output, run, Popen, PIPE, STDOUT
import tempfile
from pathlib import Path
import shutil
if len(sys.argv) < 2:
print(f"[!] Usage: {sys.argv[0]} <DESTINATION>")
sys.exit(0)
DEST = Path(sys.argv[1])
if not DEST.exists():
print(f"{DEST} does not exist. Aborting.")
sys.exit(0)
CONFIG = yaml.safe_load(open(DEST / "config.yaml"))
BENCHMARKS = CONFIG["benchmarks"]
BUILDS = CONFIG["builds"]
START_JOBS_SCRIPT = "#!/bin/sh\n"
for benchmark in BENCHMARKS:
BENCHMARK_PATH = DEST / benchmark
if not BENCHMARK_PATH.exists():
print(f"[!] {BENCHMARK_PATH} does not exist. Aborting.")
sys.exit(0)
BENCHMARK_PBS_SCRIPT = f"#PBS -N run-{benchmark}\n"
BENCHMARK_PBS_SCRIPT += "#PBS -l walltime=24:00:00\n"
BENCHMARK_PBS_SCRIPT += "#PBS -l select=1:ncpus=64:mem=128gb\n"
BENCHMARK_PBS_SCRIPT += "#PBS -l place=excl\n"
BENCHMARK_PBS_SCRIPT += "#PBS -P 31010020\n"
BENCHMARK_PBS_SCRIPT += "#PBS -j oe\n"
BENCHMARK_PBS_SCRIPT += f"cd {BENCHMARK_PATH.absolute()}\n"
BENCHMARK_PBS_SCRIPT += f"./run.sh\n"
BENCHMARK_PBS_SCRIPT_PATH = BENCHMARK_PATH / "job.pbs"
open(BENCHMARK_PBS_SCRIPT_PATH, "w").write(BENCHMARK_PBS_SCRIPT)
START_JOBS_SCRIPT += f"qsub {BENCHMARK_PBS_SCRIPT_PATH.absolute()}\n"
START_JOBS_SCRIPT_PATH = DEST / "start_jobs.sh"
open(START_JOBS_SCRIPT_PATH, "w").write(START_JOBS_SCRIPT)
os.system(f"chmod +x {START_JOBS_SCRIPT_PATH}")