forked from huyangoceans/ECSched
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch.py
74 lines (56 loc) · 1.74 KB
/
launch.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
from environment import Environment
from parameter import Parameter
from mac_generator import MacGenerator
from job_generator import JobGenerator
from element import Machine, Job
from agent import ecs_agent, ecs_dp_agent, ecs_ml_agent, swarm_agent, pack_agent, k8s_agent
import plot
def run(agent):
Machine.reset()
Job.reset()
pa = Parameter()
pa.agent = agent
env = Environment(pa)
mac_gen = MacGenerator(pa)
job_gen = JobGenerator(pa)
for i in mac_gen.mac_sequence:
env.add_machine(i)
job_idx = 0
current_time = 0
while True:
env.step()
env.time_log()
while ( env.job_count < pa.job_queue_num and
job_gen.job_sequence[job_idx] is not None and
job_gen.job_sequence[job_idx].submission_time <= current_time
):
if (job_gen.job_sequence[job_idx].submission_time == current_time): # add job to environment
env.add_job(job_gen.job_sequence[job_idx])
job_idx += 1
if agent == "ecs":
ecs_agent.schedule(env)
elif agent =="k8s":
k8s_agent.schedule(env)
elif agent == "pack":
pack_agent.schedule(env)
elif agent == "ecs_dp":
ecs_dp_agent.schedule(env)
elif agent == "ecs_ml":
ecs_ml_agent.schedule(env)
elif agent == "swarm":
swarm_agent.schedule(env)
if job_gen.job_sequence[job_idx] is None:
if env.status() == "Idle": # finish all jobs
break
current_time += 1
env.job_log()
env.finish()
def main():
run("ecs_dp")
run("ecs_ml")
run("k8s")
run("swarm")
plot.run()
# run("pack")
if __name__ == "__main__":
main()