-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
85 lines (58 loc) · 2.51 KB
/
main.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import argparse
import kaggle
import time
import os
from utils import *
from notify import *
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--local_or_remote", type = str, default = "local")
parser.add_argument("--competition_or_upload", type = str, default = "upload") #optional -> only if submit/upload
parser.add_argument("--user_name", type = str)
parser.add_argument("--kernel_name", type = str, default = None)
parser.add_argument("--competition_name", type = str, default = None) #optional ->only if to submit
parser.add_argument("--frequency", type = int, default = None)
parser.add_argument("--notify", type = str, default = None) #msg/desktop/tone
parser.add_argument("--notify_message", type = str, default = "kernel_run_finished")
parser.add_argument("--tone_path", type = str, default = None)
parser.add_argument("--result_dir", type = str, default = None) #optional -> to save resukt
parser.add_argument("--master_path", type = str, default = None) #optional
parser.add_argument("--result_to_append", type = str, default = None)#optional -> to append in master callback
args = parser.parse_args()
preProcessor()
if(args.local_or_remote == "local"):
s = Submit(args.kernel_name, args.competition_name)
if(args.competition_or_upload == "competition"):
s.submit_to_competition()
else:
s.upload()
gs = CheckStatus(args.user_name, args.kernel_name, args.frequency)
res = gs.getStatus()
if res == 1:
print("Kernel run failed")
if(args.notify == "msg"):
notify = Notify(args.kernel_name, "Failed_with_error")
notify.notifyMessage()
elif(args.notify == "desktop"):
notify = Notify(args.kernel_name, "Failed_with_error")
notify.notifyDesktop()
elif(args.notify == "tone"):
notify = Notify(kernel_name = args.kernel_name, tone_path = args.tone_path)
notify.notifyTone()
return 1
all_result_files = None
if(args.result_dir is not None):
go = GetOutput(args.user_name, args.kernel_name, args.result_dir)
all_result_files = go.getOutput()
postProcessor(args.user_name, args.kernel_name, args.master_path, args.result_dir, all_result_files, args.result_to_append)
if(args.notify == "msg"):
notify = Notify(args.kernel_name, args.notify_message)
notify.notifyMessage()
elif(args.notify == "desktop"):
notify = Notify(args.kernel_name, args.notify_message)
notify.notifyDesktop()
elif(args.notify == "tone"):
notify = Notify(kernel_name = args.kernel_name, tone_path = args.tone_path)
notify.notifyTone()
if __name__ == "__main__":
main()