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