CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
WorkFlowRunner.WorkFlowRunner Class Reference
Inheritance diagram for WorkFlowRunner.WorkFlowRunner:

Public Member Functions

def __init__
 
def doCmd
 
def run
 

Public Attributes

 cafVeto
 
 dryRun
 
 nfail
 
 noRun
 
 npass
 needs to set self.report More...
 
 report
 wrap up #### More...
 
 retStep
 
 stat
 
 status
 
 wf
 
 wfDir
 

Detailed Description

Definition at line 8 of file WorkFlowRunner.py.

Constructor & Destructor Documentation

def WorkFlowRunner.WorkFlowRunner.__init__ (   self,
  wf,
  noRun = False,
  dryRun = False,
  cafVeto = True 
)

Definition at line 9 of file WorkFlowRunner.py.

9 
10  def __init__(self, wf, noRun=False,dryRun=False,cafVeto=True):
11  Thread.__init__(self)
12  self.wf = wf
13 
14  self.status=-1
15  self.report=''
16  self.nfail=0
17  self.npass=0
18  self.noRun=noRun
19  self.dryRun=dryRun
20  self.cafVeto=cafVeto
21 
22  self.wfDir=str(self.wf.numId)+'_'+self.wf.nameId
23  return
npass
needs to set self.report

Member Function Documentation

def WorkFlowRunner.WorkFlowRunner.doCmd (   self,
  cmd 
)

Definition at line 24 of file WorkFlowRunner.py.

References WorkFlowRunner.WorkFlowRunner.dryRun, and WorkFlowRunner.WorkFlowRunner.wfDir.

24 
25  def doCmd(self, cmd):
26 
27  msg = "\n# in: " +os.getcwd()
28  if self.dryRun: msg += " dryRun for '"
29  else: msg += " going to execute "
30  msg += cmd.replace(';','\n')
31  print msg
32 
33  cmdLog = open(self.wfDir+'/cmdLog','a')
34  cmdLog.write(msg+'\n')
35  cmdLog.close()
36 
37  ret = 0
38  if not self.dryRun:
39  p = Popen(cmd, shell=True)
40  ret = os.waitpid(p.pid, 0)[1]
41  if ret != 0:
42  print "ERROR executing ",cmd,'ret=', ret
43 
44  return ret
def WorkFlowRunner.WorkFlowRunner.run (   self)

Definition at line 45 of file WorkFlowRunner.py.

References runall.testit.nfail, WorkFlowRunner.WorkFlowRunner.nfail, runall.testit.npass, WorkFlowRunner.WorkFlowRunner.npass, TShapeAnalysis.npass, and WorkFlowRunner.WorkFlowRunner.wfDir.

Referenced by Types.LuminosityBlockID.cppID().

45 
46  def run(self):
47 
48  startDir = os.getcwd()
49 
50  if not os.path.exists(self.wfDir):
51  os.makedirs(self.wfDir)
52 
53  preamble = 'cd '+self.wfDir+'; '
54 
55  startime='date %s' %time.asctime()
56 
57  # check where we are running:
58  onCAF = False
59  if 'cms/caf/cms' in os.environ['CMS_PATH']:
60  onCAF = True
61 
62  ##needs to set
63  #self.report
64  self.npass = []
65  self.nfail = []
66  self.stat = []
67  self.retStep = []
68 
69  def closeCmd(i,ID):
70  return ' > %s 2>&1; ' % ('step%d_'%(i,)+ID+'.log ',)
71 
72  inFile=None
73  lumiRangeFile=None
74  aborted=False
75  for (istepmone,com) in enumerate(self.wf.cmds):
76  istep=istepmone+1
77  cmd = preamble
78  if aborted:
79  self.npass.append(0)
80  self.nfail.append(0)
81  self.retStep.append(0)
82  self.stat.append('NOTRUN')
83  continue
84  if not isinstance(com,str):
85  if self.cafVeto and (com.location == 'CAF' and not onCAF):
86  print "You need to be no CAF to run",self.wf.numId
87  self.npass.append(0)
88  self.nfail.append(0)
89  self.retStep.append(0)
90  self.stat.append('NOTRUN')
91  aborted=True
92  continue
93  cmd2 = com.lumiRanges()
94  if cmd2:
95  cmd2 =cmd+cmd2+closeCmd(istep,'lumiRanges')
96  lumiRangeFile='step%d_lumiRanges.log'%(istep,)
97  retStep = self.doCmd(cmd2)
98  cmd+=com.das()
99  cmd+=closeCmd(istep,'dasquery')
100  retStep = self.doCmd(cmd)
101  #don't use the file list executed, but use the das command of cmsDriver for next step
102  inFile='filelist:step%d_dasquery.log'%(istep,)
103  print "---"
104  else:
105  #chaining IO , which should be done in WF object already and not using stepX.root but <stepName>.root
106  cmd += com
107  if self.noRun:
108  cmd +=' --no_exec'
109  if inFile: #in case previous step used DAS query (either filelist of das:)
110  cmd += ' --filein '+inFile
111  inFile=None
112  if lumiRangeFile: #DAS query can also restrict lumi range
113  cmd += ' --lumiToProcess '+lumiRangeFile
114  lumiRangeFile=None
115  if 'HARVESTING' in cmd and not '134' in str(self.wf.numId) and not '--filein' in cmd:
116  cmd+=' --filein file:step%d_inDQM.root --fileout file:step%d.root '%(istep-1,istep)
117  else:
118  if istep!=1 and not '--filein' in cmd:
119  cmd+=' --filein file:step%s.root '%(istep-1,)
120  if not '--fileout' in com:
121  cmd+=' --fileout file:step%s.root '%(istep,)
122 
123 
124 
125  cmd+=closeCmd(istep,self.wf.nameId)
126  retStep = self.doCmd(cmd)
127 
128  self.retStep.append(retStep)
129  if (retStep!=0):
130  #error occured
131  self.npass.append(0)
132  self.nfail.append(1)
133  self.stat.append('FAILED')
134  #to skip processing
135  aborted=True
136  else:
137  #things went fine
138  self.npass.append(1)
139  self.nfail.append(0)
140  self.stat.append('PASSED')
141 
142 
143  os.chdir(startDir)
144 
145  endtime='date %s' %time.asctime()
146  tottime='%s-%s'%(endtime,startime)
147 
148 
149  #### wrap up ####
150 
151  logStat=''
152  for i,s in enumerate(self.stat):
153  logStat+='Step%d-%s '%(i,s)
154  self.report='%s_%s %s - time %s; exit: '%(self.wf.numId,self.wf.nameId,logStat,tottime)+' '.join(map(str,self.retStep))+'\n'
155 
156  return
157 
158 
159 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
npass
needs to set self.report

Member Data Documentation

WorkFlowRunner.WorkFlowRunner.cafVeto

Definition at line 19 of file WorkFlowRunner.py.

WorkFlowRunner.WorkFlowRunner.dryRun

Definition at line 18 of file WorkFlowRunner.py.

Referenced by WorkFlowRunner.WorkFlowRunner.doCmd().

WorkFlowRunner.WorkFlowRunner.nfail

Definition at line 15 of file WorkFlowRunner.py.

Referenced by WorkFlowRunner.WorkFlowRunner.run().

WorkFlowRunner.WorkFlowRunner.noRun

Definition at line 17 of file WorkFlowRunner.py.

WorkFlowRunner.WorkFlowRunner.npass

needs to set self.report

Definition at line 16 of file WorkFlowRunner.py.

Referenced by WorkFlowRunner.WorkFlowRunner.run().

WorkFlowRunner.WorkFlowRunner.report

wrap up ####

Definition at line 14 of file WorkFlowRunner.py.

Referenced by addOnTests.testit.run().

WorkFlowRunner.WorkFlowRunner.retStep

Definition at line 66 of file WorkFlowRunner.py.

WorkFlowRunner.WorkFlowRunner.stat

Definition at line 65 of file WorkFlowRunner.py.

WorkFlowRunner.WorkFlowRunner.status

Definition at line 13 of file WorkFlowRunner.py.

Referenced by dirstructure.Comparison.__make_image(), and dirstructure.Comparison.__repr__().

WorkFlowRunner.WorkFlowRunner.wf

Definition at line 11 of file WorkFlowRunner.py.

WorkFlowRunner.WorkFlowRunner.wfDir

Definition at line 21 of file WorkFlowRunner.py.

Referenced by WorkFlowRunner.WorkFlowRunner.doCmd(), and WorkFlowRunner.WorkFlowRunner.run().