![]() |
![]() |
Inherits threading::Thread.
Public Member Functions | |
def | __init__ |
def | doCmd |
def | run |
Public Attributes | |
cafVeto | |
dryRun | |
nfail | |
noRun | |
npass | |
needs to set self.report | |
report | |
wrap up #### | |
retStep | |
stat | |
status | |
wf | |
wfDir |
Definition at line 8 of file WorkFlowRunner.py.
def WorkFlowRunner::WorkFlowRunner::__init__ | ( | self, | |
wf, | |||
noRun = False , |
|||
dryRun = False , |
|||
cafVeto = True |
|||
) |
Definition at line 9 of file WorkFlowRunner.py.
def WorkFlowRunner::WorkFlowRunner::doCmd | ( | self, | |
cmd | |||
) |
Definition at line 24 of file WorkFlowRunner.py.
00025 : 00026 00027 msg = "\n# in: " +os.getcwd() 00028 if self.dryRun: msg += " dryRun for '" 00029 else: msg += " going to execute " 00030 msg += cmd.replace(';','\n') 00031 print msg 00032 00033 cmdLog = open(self.wfDir+'/cmdLog','a') 00034 cmdLog.write(msg+'\n') 00035 cmdLog.close() 00036 00037 ret = 0 00038 if not self.dryRun: 00039 p = Popen(cmd, shell=True) 00040 ret = os.waitpid(p.pid, 0)[1] 00041 if ret != 0: 00042 print "ERROR executing ",cmd,'ret=', ret 00043 00044 return ret
def WorkFlowRunner::WorkFlowRunner::run | ( | self | ) |
Definition at line 45 of file WorkFlowRunner.py.
00046 : 00047 00048 startDir = os.getcwd() 00049 00050 if not os.path.exists(self.wfDir): 00051 os.makedirs(self.wfDir) 00052 00053 preamble = 'cd '+self.wfDir+'; ' 00054 00055 startime='date %s' %time.asctime() 00056 00057 # check where we are running: 00058 onCAF = False 00059 if 'cms/caf/cms' in os.environ['CMS_PATH']: 00060 onCAF = True 00061 00062 ##needs to set 00063 #self.report 00064 self.npass = [] 00065 self.nfail = [] 00066 self.stat = [] 00067 self.retStep = [] 00068 00069 def closeCmd(i,ID): 00070 return ' > %s 2>&1; ' % ('step%d_'%(i,)+ID+'.log ',) 00071 00072 inFile=None 00073 lumiRangeFile=None 00074 aborted=False 00075 for (istepmone,com) in enumerate(self.wf.cmds): 00076 istep=istepmone+1 00077 cmd = preamble 00078 if aborted: 00079 self.npass.append(0) 00080 self.nfail.append(0) 00081 self.retStep.append(0) 00082 self.stat.append('NOTRUN') 00083 continue 00084 if not isinstance(com,str): 00085 if self.cafVeto and (com.location == 'CAF' and not onCAF): 00086 print "You need to be no CAF to run",self.wf.numId 00087 self.npass.append(0) 00088 self.nfail.append(0) 00089 self.retStep.append(0) 00090 self.stat.append('NOTRUN') 00091 aborted=True 00092 continue 00093 cmd2 = com.lumiRanges() 00094 if cmd2: 00095 cmd2 =cmd+cmd2+closeCmd(istep,'lumiRanges') 00096 lumiRangeFile='step%d_lumiRanges.log'%(istep,) 00097 retStep = self.doCmd(cmd2) 00098 cmd+=com.dbs() 00099 cmd+=closeCmd(istep,'dbsquery') 00100 retStep = self.doCmd(cmd) 00101 #don't use the file list executed, but use the dbs command of cmsDriver for next step 00102 inFile='filelist:step%d_dbsquery.log'%(istep,) 00103 print "---" 00104 else: 00105 #chaining IO , which should be done in WF object already and not using stepX.root but <stepName>.root 00106 cmd += com 00107 if self.noRun: 00108 cmd +=' --no_exec' 00109 if inFile: #in case previous step used DBS query (either filelist of dbs:) 00110 cmd += ' --filein '+inFile 00111 inFile=None 00112 if lumiRangeFile: #DBS query can also restrict lumi range 00113 cmd += ' --lumiToProcess '+lumiRangeFile 00114 lumiRangeFile=None 00115 if 'HARVESTING' in cmd and not '134' in str(self.wf.numId) and not '--filein' in cmd: 00116 cmd+=' --filein file:step%d_inDQM.root --fileout file:step%d.root '%(istep-1,istep) 00117 else: 00118 if istep!=1 and not '--filein' in cmd: 00119 cmd+=' --filein file:step%s.root '%(istep-1,) 00120 if not '--fileout' in com: 00121 cmd+=' --fileout file:step%s.root '%(istep,) 00122 00123 00124 00125 cmd+=closeCmd(istep,self.wf.nameId) 00126 retStep = self.doCmd(cmd) 00127 00128 self.retStep.append(retStep) 00129 if (retStep!=0): 00130 #error occured 00131 self.npass.append(0) 00132 self.nfail.append(1) 00133 self.stat.append('FAILED') 00134 #to skip processing 00135 aborted=True 00136 else: 00137 #things went fine 00138 self.npass.append(1) 00139 self.nfail.append(0) 00140 self.stat.append('PASSED') 00141 00142 00143 os.chdir(startDir) 00144 00145 endtime='date %s' %time.asctime() 00146 tottime='%s-%s'%(endtime,startime) 00147 00148 00149 #### wrap up #### 00150 00151 logStat='' 00152 for i,s in enumerate(self.stat): 00153 logStat+='Step%d-%s '%(i,s) 00154 self.report='%s_%s %s - time %s; exit: '%(self.wf.numId,self.wf.nameId,logStat,tottime)+' '.join(map(str,self.retStep))+'\n' 00155 00156 return 00157 00158 00159
Definition at line 9 of file WorkFlowRunner.py.
Definition at line 9 of file WorkFlowRunner.py.
Definition at line 9 of file WorkFlowRunner.py.
Definition at line 9 of file WorkFlowRunner.py.
needs to set self.report
Definition at line 9 of file WorkFlowRunner.py.
wrap up ####
Definition at line 9 of file WorkFlowRunner.py.
Definition at line 47 of file WorkFlowRunner.py.
Definition at line 47 of file WorkFlowRunner.py.
Definition at line 9 of file WorkFlowRunner.py.
Definition at line 9 of file WorkFlowRunner.py.
Definition at line 9 of file WorkFlowRunner.py.