-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript_resume_short_jobs.py
executable file
·45 lines (34 loc) · 1.15 KB
/
script_resume_short_jobs.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
import rich
import time
import os
import subprocess
import sys
import re
from pathlib import Path
SCRIPT_DIR = Path(__file__).absolute().parent
def cmd(command):
output = subprocess.check_output(command).strip().decode().split("\n")
return [x for x in output if x]
def start(command):
return subprocess.Popen(command)
def main():
find_command = ["find", str(SCRIPT_DIR / "log_results/oracle"), str(SCRIPT_DIR / "log_results/basic"), "-iname", "*ckpt"]
launch_command = ["python", "bin_main_launcher.py", "resume"]
finds = cmd(find_command)
if not finds:
rich.print("Didn't find anything with command:\n")
rich.print(find_command)
return
# rich.print(finds)
targets = []
for line in finds:
epoch = int(re.match(r".*epoch=(\w+).*", line).group(1));
if epoch <= 60:
target = Path(line).parent.parent.parent.parent.parent / "specific_config.json"
targets.append(target)
rich.print(targets)
procs = [start(launch_command + [target]) for target in targets]
[proc.wait() for proc in procs]
rich.print("Done.")
if __name__ == "__main__":
main()