-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
59 lines (52 loc) · 1.92 KB
/
run.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
56
57
58
59
import argparse
import datetime
import os
from lib.postprocess import post_process as pp
from lib.local_utils import send_email, run_command
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--path", type=str, default="convbbt", help="path of main file")
parser.add_argument("--git", type=str, default="", help="push or not(you have to set your git repository)")
args = parser.parse_args()
return args
def main():
fetch = run_command("python3 setup.py")
print(fetch)
# pip = run_command("pip3 install -r requirements.txt")
args = parse_args()
date = datetime.datetime.now().strftime("%m%d")
idx = 0
while os.path.exists(f"result/{date}_{args.path}_{idx}"):
idx += 1
dirname = f"result/{date}_{args.path}_{idx}"
print(f"{date}_{args.path}_{idx} running...")
os.makedirs(dirname)
os.makedirs(f"{dirname}/raw")
os.makedirs(f"{dirname}/processed")
os.makedirs(f"{dirname}/processed/assets")
cp_lib = run_command(f"cp -r lib/ {dirname}/raw/")
cp_main = run_command(f"cp main/{args.path}.py {dirname}/raw/")
print("setup done")
main = run_command(
f"python3 main/{args.path}.py > {dirname}/raw/experiment.log"
)
print("main done")
pp(dirname)
print("result done")
print(f"{date}_{args.path}_{idx} done")
# send_email(f"{date}_{args.path}_{idx} done", f"{date}_{args.path}_{idx} is done")
if args.git == "push":
gitpull = run_command(f"git pull")
gita = run_command(f"git add .")
print("git add")
message = run_command(f"tail -5 {dirname}/raw/experiment.log")
# gitc = run_command(f"git commit -m {message}")
gitc = run_command(f'git commit -m "add result"')
print("git commit")
print(message)
gitpush = run_command(f"git push")
print("git push")
print("git done")
print("done")
if __name__ == "__main__":
main()