forked from dos-group/group-adaptive-scheduler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
228 lines (196 loc) · 5.17 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
import argparse
import sys
import generator
import scheduler
import complementarity
import subprocess
from application import Application
from scheduler import Scheduler
from datetime import datetime
def run(args):
scheduler_class = getattr(scheduler, args.scheduler)
estimation_class = getattr(complementarity, args.estimation)
Scheduler.jobs_to_peek_arg = args.jobs_to_peek
Scheduler.waiting_limit = args.waiting_limit
Scheduler.activate_random_arrival = args.random_rate
s = generator.scheduler(
scheduler_class=scheduler_class,
estimation_class=estimation_class,
exp_xml_str=args.experiment_xml.read(),
jobs_xml_str=args.jobs_xml.read(),
config_yaml=args.config_yaml
)
Application.print_command_line = args.pcmd
Application.experiment_name = "experiment_" + datetime.now().strftime("%Y%m%d_%H%M%S") + "_" + args.experiment_name
print("Experiment folder = {}".format(Application.experiment_name))
subprocess.Popen("mkdir /data/vinh.tran/new/expData/{}".format(Application.experiment_name), shell=True)
#Scheduler.jobs_to_peek_arg = args.jobs_to_peek
if args.estimation_parameters is not None:
s.estimation.load(args.estimation_parameters)
if args.estimation_folder is not None:
s.estimation.output_folder = args.estimation_folder
s.start()
def gen(args):
exp = generator.experiment(args.jobs_xml.read(), args.n_jobs)
args.output.write(exp.to_xml())
def estimation_bench(args):
s = generator.estimations_bench(
exp_xml_str=args.experiment_xml.read(),
jobs_xml_str=args.jobs_xml.read(),
config_yaml=args.config_yaml
)
s.start()
parser = argparse.ArgumentParser(
prog="pyScheduler",
description="Schedule Application on a Cluster"
)
subparsers = parser.add_subparsers()
parser_run = subparsers.add_parser("run", help="Run an experiment")
parser_run.set_defaults(func=run)
parser_estimations = subparsers.add_parser("estimations", help="Print the different estimations for an experiment")
parser_estimations.set_defaults(func=estimation_bench)
parser_gen = subparsers.add_parser("gen", help="Generate an experiment from jobs list")
parser_gen.set_defaults(func=gen)
# RUN
parser_run.add_argument(
"config_yaml",
metavar="config.yaml",
type=argparse.FileType('r'),
nargs="?",
help="path to the config.yaml"
)
parser_run.add_argument(
"jobs_xml",
metavar="jobs.xml",
type=argparse.FileType('r'),
nargs="?",
help="path to the jobs.xml"
)
parser_run.add_argument(
"experiment_xml",
metavar="exp.xml",
type=argparse.FileType('r'),
nargs="?",
help="path to the experiment.xml"
)
parser_run.add_argument(
"-s",
dest="scheduler",
type=str,
nargs="?",
help="scheduling strategy",
default="RoundRobin",
choices=["RoundRobin", "Adaptive", "Random", "GroupAdaptive", "GroupAdaptiveExtend"]
)
parser_run.add_argument(
"-e",
dest="estimation",
type=str,
nargs="?",
help="complementarity estimation strategy",
default="Gradient",
choices=["EpsilonGreedy", "Gradient", "GroupGradient"]
)
parser_run.add_argument(
"-ep",
dest="estimation_parameters",
type=str,
nargs="?",
help="complementarity estimation parameters folder",
)
parser_run.add_argument(
"-eo",
dest="estimation_folder",
type=str,
nargs="?",
help="estimation data folder",
default="estimation"
)
parser_run.add_argument(
"-en",
dest="experiment_name",
type=str,
nargs="?",
help="experiment name",
default="first_roundrobin"
)
parser_run.add_argument(
"-jtp",
dest="jobs_to_peek",
type=int,
nargs="?",
help="number of jobs for scheduler to peek",
default=7
)
parser_run.add_argument(
"-wl",
dest="waiting_limit",
type=int,
nargs="?",
help="waiting limit before set job as late job",
default=-1
)
parser_run.add_argument(
"-rr",
dest="random_rate",
type=bool,
nargs="?",
help="Decide whether to use random rate",
default=False
)
parser_run.add_argument(
"--pcmd",
help="Print or not command lines",
action='store_true'
)
# ESTIMATION BENCH
parser_estimations.add_argument(
"config_yaml",
metavar="config.yaml",
type=argparse.FileType('r'),
nargs="?",
help="path to the config.yaml"
)
parser_estimations.add_argument(
"jobs_xml",
metavar="jobs.xml",
type=argparse.FileType('r'),
nargs="?",
help="path to the jobs.xml"
)
parser_estimations.add_argument(
"experiment_xml",
metavar="exp.xml",
type=argparse.FileType('r'),
nargs="?",
help="path to the experiment.xml"
)
# GEN
parser_gen.add_argument(
"jobs_xml",
metavar="jobs.xml",
type=argparse.FileType('r'),
nargs="?",
help="path to the jobs.xml"
)
parser_gen.add_argument(
"-n",
dest="n_jobs",
type=int,
nargs="?",
help="number of jobs in the experiment",
default=10
)
parser_gen.add_argument(
"-o",
dest="output",
type=argparse.FileType('w+'),
nargs="?",
help="output path",
default="experiment.xml"
)
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
args.func(args)