forked from HumanArk/hafarm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SlurmRender.py
27 lines (24 loc) · 1021 Bytes
/
SlurmRender.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
import pprint
from managers.slurm import Slurm
from itertools import cycle
class SlurmRender(object):
def __init__(self, hagraphitems_lst, **kwargs):
super(SlurmRender, self).__init__()
self.hagraphitems_lst = hagraphitems_lst
def render(self, dryrun=False, **kwargs):
for k, n in self.hagraphitems_lst.iteritems():
for i in n.dependencies:
item = self.hagraphitems_lst[i]
n.parms['hold_jid'] += [item.parms['job_name']]
items_idx_sended = []
items_idx = self.hagraphitems_lst.keys()
cycle_items_idx = cycle(items_idx)
slurm_obj = Slurm()
while items_idx != []:
idx = next(cycle_items_idx)
item = self.hagraphitems_lst[idx]
if set(item.dependencies) <= set(items_idx_sended):
items_idx.remove(idx)
cycle_items_idx = cycle(items_idx)
items_idx_sended += [idx]
slurm_obj.render(item.parms,dryrun=dryrun)