2 from __future__
import print_function
3 from builtins
import range
4 import os,subprocess,sys,re,time,random
5 from threading
import *
6 from subprocess
import call
8 STATE_CREATED,STATE_COMPLETED,STATE_ERROR=list(
range(3))
22 self.QueueList.QueueLock.acquire()
23 sSrv=self.QueueList.smallestQueue()
24 tSrv=self.QueueList.thinerQueue()
28 elif self.
Weight + self.
QueueList[sSrv].queueWeight() <= (self.QueueList.Cores/self.QueueList.Jay)*1.5:
33 self.QueueList.QueueLock.release()
38 rValue=call([
'ssh',self.
Queue,
'cd ~/CMSSW_3_5_7;scram build -j %d' % self.QueueList.Jay,self.BuildNode.LibName])
39 self.QueueList.EdmRefreshLock.acquire()
40 call([
'ssh',self.
Queue,
'cd ~/CMSSW_3_5_7;eval `scram runtime -sh`;EdmPluginRefresh %s' % self.BuildNode.LibName])
41 self.QueueList.EdmRefreshLock.release()
43 self.BuildNode.State=STATE_COMPLETED
45 print(
"Build failed for %s" % self.BuildNode.LibName)
46 self.BuildNode.State=STATE_ERROR
52 self.BuildNode.State=STATE_ERROR
53 self.IsComplete.acquire()
54 self.IsComplete.notifyAll()
55 self.IsComplete.release()
59 while not depsCompleted:
61 for deps
in self.BuildNode.DependsOn:
62 if deps.State
is STATE_ERROR :
65 if deps.State
is not STATE_COMPLETED :
67 deps.BThread.IsComplete.acquire()
68 deps.BThread.IsComplete.wait()
70 deps.BThread.IsComplete.release()
74 self.IsComplete.acquire()
75 self.IsComplete.notifyAll()
76 self.IsComplete.release()
86 list.__init__(self,value)
102 itP=it.AreDependent.findLib(lib,head)
109 if not node.BThread.is_alive():
114 node.AreDependent.startThreads()
117 return self.
findLib(dep.replace(
"/",
""))
120 if not value.__class__ == BuildTreeNode:
121 raise TypeError(
"Expected BuildTreeNode")
122 self.SeenLibs.append(value.LibName)
123 self.SeenModules.append(value.Module)
124 self.SeenSubModules.append(value.SubModule)
125 list.__setitem__(self,index,value)
128 if not value.__class__ == BuildTreeNode:
129 raise TypeError(
"Expected BuildTreeNode")
130 value.LibName
not in self.
SeenLibs and self.SeenLibs.append(value.LibName)
131 value.Module
not in self.
SeenModules and self.SeenModules.append(value.Module)
132 value.SubModule
not in self.
SeenSubModules and self.SeenSubModules.append(value.SubModule)
133 list.append(self,value)
135 def __str__(self,topDown=False,direction=False):
137 return "[\n...%s]" %
str(
"\n...".
join([
str(it).
replace(
"...",
"......")
for it
in self]))
140 return "[\n---%s]" %
"\n---".
join([
"'%s':'%s'\n------State = %d \n------DependsOn : %s " % (it.LibName,it.SubModule
or it.Module,it.State,it.DependsOn.__str__(
True,
True).
replace(
"---",
"------"))
for it
in self ])
142 return "\n".
join([it.__str__(
True)
for it
in self])
146 def __init__(self,libname="",module="",submodule="",depends=None,areDependent=None,weight=1,srvqueue=None):
151 if areDependent==
None:
162 if name
is "DependsOn" or name
is "AreDependent":
163 if not value.__class__ == BuildTreeNodeList:
164 raise TypeError(
"Expected BuildTreeNodeList")
165 elif name
is "State" or name
is "ModulesToDo":
166 if not value.__class__ == int:
167 raise TypeError(
"Expected int")
168 elif name
is "Module" or name
is "SubModule" or name
is "LibName":
169 if not value.__class__ == str:
170 raise TypeError(
"Expected str")
171 object.__setattr__(self,name,value)
178 return "'%s':'%s'\n---State = %d \n---DependsOn : %s " % (self.
LibName,self.
SubModule or self.
Module,self.
State,self.DependsOn.__str__(
True,
True).
replace(
"---",
"------"))
180 return self.AreDependent.__str__(topDown=
True)
191 self.RunningThreads.append(item)
193 self.ThreadLog.append([t,item.BuildNode.LibName,
"INFO: %s thread %s added for Library %s" % (t,item.name,item.BuildNode.LibName)])
199 return sum([x.Weight
for x
in self.
RunningThreads if x.is_alive()])
205 dict.__init__(self,dict.fromkeys(servers))
206 for srv
in self.keys():
215 smallest=self.keys()[0]
216 sizeSmallest=self[smallest].pendingThreads()
217 for srv
in self.keys()[1:]:
218 size=self[srv].pendingThreads()
219 if size < sizeSmallest:
225 thinnest=self.keys()[0]
226 weightThinnest=self[thinnest].queueWeight()
227 for srv
in self.keys()[1:]:
228 weight=self[srv].queueWeight()
229 if weight < weightThinnest:
231 weightThinnest = weight
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
const uint16_t range(const Frame &aFrame)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)