ATLAS Offline Software
Loading...
Searching...
No Matches
python.PostProcessing.PostProcessingStep Class Reference
Collaboration diagram for python.PostProcessing.PostProcessingStep:

Public Member Functions

 __init__ (self, taskman, taskDict, oldStatus, previousSteps, postprocLib, jobName=None)
 __del__ (self)
 log (self, msg=None, text=None, noTime=False, doPrint=False)
 logExec (self, cmd, doPrint=False, checkStatusCode=True, errorMsg='', abortOnError=True)
 getFileName (self, postFix, stepName='', absPath=False)
 jobList (self)
 taskFileList (self, fileNamePattern, statusName='POSTPROCESSING', jobName=None)
 hadd (self, dir, outputFileName, inputFiles, maxFilesPerHadd=100)
 getJobConfig (self, jobName=None)
 addResult (self, resultFileName)

Public Attributes

 stepName = self.__class__.__name__
 executedSteps = previousSteps
 taskman = taskman
 taskDict = taskDict
 dsName = taskDict['DSNAME']
 taskName = taskDict['TASKNAME']
str taskDir = '/'.join([self.dsName,self.taskName])
 oldStatus = oldStatus
 postprocLib = postprocLib
 jobName = jobName
str baseName = '%s-%s' % (self.dsName,self.taskName)
str baseNameStep = '%s-%s.%s' % (self.dsName,self.taskName,self.stepName)
 logfile = open('%s/%s.log' % (self.taskDir,self.baseNameStep), 'w')

Detailed Description

Definition at line 148 of file PostProcessing.py.

Constructor & Destructor Documentation

◆ __init__()

python.PostProcessing.PostProcessingStep.__init__ ( self,
taskman,
taskDict,
oldStatus,
previousSteps,
postprocLib,
jobName = None )

Definition at line 150 of file PostProcessing.py.

150 def __init__(self,taskman,taskDict,oldStatus,previousSteps,postprocLib,jobName=None):
151 self.stepName = self.__class__.__name__
152 self.executedSteps = previousSteps
153 self.executedSteps.append( self.stepName )
154 self.taskman = taskman
155 self.taskDict = taskDict
156 self.dsName = taskDict['DSNAME']
157 self.taskName = taskDict['TASKNAME']
158 self.taskDir = '/'.join([self.dsName,self.taskName])
159 self.oldStatus = oldStatus
160 self.postprocLib = postprocLib
161 self.jobName = jobName
162 self.baseName = '%s-%s' % (self.dsName,self.taskName)
163 self.baseNameStep = '%s-%s.%s' % (self.dsName,self.taskName,self.stepName)
164 self.logfile = open('%s/%s.log' % (self.taskDir,self.baseNameStep), 'w')
165 self.log('Starting postprocessing: %s' % self.__class__.__name__)
166 self.log('* Data set name = %s' % self.dsName, noTime=True)
167 self.log('* Task name = %s' % self.taskName, noTime=True)
168 self.log('* Old status = %s' % getKey(TaskManager.StatusCodes,self.oldStatus), noTime=True)
169 self.log('* Job name = %s' % self.jobName, noTime=True)
170 self.log('* User name = %s' % getUserName(), noTime=True)
171 self.log('* Host name = %s\n' % os.uname()[1], noTime=True)
172 pass
173

◆ __del__()

python.PostProcessing.PostProcessingStep.__del__ ( self)

Definition at line 174 of file PostProcessing.py.

174 def __del__(self):
175 self.log('Done')
176 self.logfile.close()
177

Member Function Documentation

◆ addResult()

python.PostProcessing.PostProcessingStep.addResult ( self,
resultFileName )

Definition at line 270 of file PostProcessing.py.

270 def addResult(self,resultFileName):
271 # FIXME: strip leading dirs from resultFilename, so I can pass an absolute file name?
272 if not resultFileName:
273 return
274 resultFiles = self.taskDict['RESULTFILES']
275 if resultFiles is None:
276 resultFiles = ''
277 if resultFileName not in resultFiles.split():
278 resultFiles = ' '.join([resultFiles,resultFileName])
279 self.taskman.setValue(self.dsName,self.taskName,'RESULTFILES',resultFiles)
280 self.taskDict['RESULTFILES'] = resultFiles

◆ getFileName()

python.PostProcessing.PostProcessingStep.getFileName ( self,
postFix,
stepName = '',
absPath = False )

Definition at line 211 of file PostProcessing.py.

211 def getFileName(self,postFix,stepName='',absPath=False):
212 if stepName:
213 name = '%s.%s%s' % (self.baseName,stepName,postFix)
214 else:
215 name = self.baseNameStep+postFix
216 if absPath:
217 name = '%s/%s' % (self.taskDir,name)
218 return name
219

◆ getJobConfig()

python.PostProcessing.PostProcessingStep.getJobConfig ( self,
jobName = None )

Definition at line 259 of file PostProcessing.py.

259 def getJobConfig(self,jobName=None):
260 config = {}
261 if not jobName:
262 jobName = '*'
263 configFile = glob.glob('%s/%s/%s' % (self.taskDir,jobName,'*.config.py.final.py'))
264 if not configFile:
265 configFile = glob.glob('%s/%s/%s' % (self.taskDir,jobName,'*.config.py'))
266 if configFile:
267 exec(open(configFile[0],'r'),config) # Eval config file and put defs into config dict
268 return config['jobConfig']
269

◆ hadd()

python.PostProcessing.PostProcessingStep.hadd ( self,
dir,
outputFileName,
inputFiles,
maxFilesPerHadd = 100 )
Execute staged hadd for many files.

Definition at line 242 of file PostProcessing.py.

242 def hadd(self,dir,outputFileName,inputFiles,maxFilesPerHadd=100):
243 """Execute staged hadd for many files."""
244 if len(inputFiles)<=maxFilesPerHadd:
245 self.logExec('cd %s; hadd -f %s %s' % (dir,outputFileName,' '.join(inputFiles)))
246 else:
247 nSteps = int(math.ceil(float(len(inputFiles))/maxFilesPerHadd))
248 partFiles = []
249 for index in range(nSteps):
250 minIndex = index*maxFilesPerHadd
251 maxIndex = min((index+1)*maxFilesPerHadd,len(inputFiles))
252 stepInputFiles = inputFiles[minIndex:maxIndex]
253 stepOutputFileName = '%s.part%i' % (outputFileName,index)
254 self.logExec('cd %s; hadd -f %s %s' % (dir,stepOutputFileName,' '.join(stepInputFiles)))
255 partFiles.append(stepOutputFileName)
256 self.logExec('cd %s; hadd -f %s %s' % (dir,outputFileName,' '.join(partFiles)))
257 self.logExec('cd %s; rm -f %s' % (dir,' '.join(partFiles)))
258
#define min(a, b)
Definition cfImp.cxx:40

◆ jobList()

python.PostProcessing.PostProcessingStep.jobList ( self)

Definition at line 220 of file PostProcessing.py.

220 def jobList(self):
221 try:
222 l = os.listdir(self.taskDir)
223 except Exception:
224 l = []
225 return l
226

◆ log()

python.PostProcessing.PostProcessingStep.log ( self,
msg = None,
text = None,
noTime = False,
doPrint = False )

Definition at line 178 of file PostProcessing.py.

178 def log(self,msg=None,text=None,noTime=False,doPrint=False):
179 outputFiles = [self.logfile]
180 if doPrint:
181 outputFiles.append(sys.stdout)
182 for out in outputFiles:
183 if msg:
184 if noTime:
185 out.write(' '*31)
186 out.write(msg)
187 out.write('\n')
188 else:
189 out.write('\n%-30s %s\n' % (time.strftime('%a %b %d %X %Z %Y'),msg))
190 if text:
191 #out.write('\n')
192 out.write(text)
193 out.write('\n')
194

◆ logExec()

python.PostProcessing.PostProcessingStep.logExec ( self,
cmd,
doPrint = False,
checkStatusCode = True,
errorMsg = '',
abortOnError = True )

Definition at line 195 of file PostProcessing.py.

195 def logExec(self,cmd,doPrint=False,checkStatusCode=True,errorMsg='',abortOnError=True):
196 (status,output) = subprocess.getstatusoutput(cmd)
197 status = status >> 8 # Convert to standard Unix exit code
198 self.log('Executing: %s' % cmd, output)
199 if doPrint or status:
200 print (output)
201 print()
202 if status and checkStatusCode:
203 if not errorMsg:
204 errorMsg = 'ERROR in postprocessing step %s while executing:\n\n%s\n' % (self.stepName,cmd)
205 self.log(text='\nERROR: exit status = %i' % (status))
206 self.log(text=errorMsg)
207 if abortOnError:
208 raise PostProcessingError(errorMsg,self.executedSteps)
209 return status
210
void print(char *figname, TCanvas *c1)

◆ taskFileList()

python.PostProcessing.PostProcessingStep.taskFileList ( self,
fileNamePattern,
statusName = 'POSTPROCESSING',
jobName = None )
Get list of files with specific names from all jobs in a given state.

Definition at line 227 of file PostProcessing.py.

227 def taskFileList(self,fileNamePattern,statusName='POSTPROCESSING',jobName=None):
228 """Get list of files with specific names from all jobs in a given state."""
229 oldDir = os.getcwd()
230 os.chdir(self.taskDir)
231 if jobName:
232 statusFiles = glob.glob('%s/*.status.%s' % (jobName,statusName))
233 else:
234 statusFiles = glob.glob('*/*.status.%s' % (statusName))
235 files = []
236 for s in statusFiles:
237 b = '/'.join(s.split('/')[:-1])
238 files.extend(glob.glob('%s/%s' % (b,fileNamePattern)))
239 os.chdir(oldDir)
240 return sorted(files)
241

Member Data Documentation

◆ baseName

str python.PostProcessing.PostProcessingStep.baseName = '%s-%s' % (self.dsName,self.taskName)

Definition at line 162 of file PostProcessing.py.

◆ baseNameStep

str python.PostProcessing.PostProcessingStep.baseNameStep = '%s-%s.%s' % (self.dsName,self.taskName,self.stepName)

Definition at line 163 of file PostProcessing.py.

◆ dsName

python.PostProcessing.PostProcessingStep.dsName = taskDict['DSNAME']

Definition at line 156 of file PostProcessing.py.

◆ executedSteps

python.PostProcessing.PostProcessingStep.executedSteps = previousSteps

Definition at line 152 of file PostProcessing.py.

◆ jobName

python.PostProcessing.PostProcessingStep.jobName = jobName

Definition at line 161 of file PostProcessing.py.

◆ logfile

python.PostProcessing.PostProcessingStep.logfile = open('%s/%s.log' % (self.taskDir,self.baseNameStep), 'w')

Definition at line 164 of file PostProcessing.py.

◆ oldStatus

python.PostProcessing.PostProcessingStep.oldStatus = oldStatus

Definition at line 159 of file PostProcessing.py.

◆ postprocLib

python.PostProcessing.PostProcessingStep.postprocLib = postprocLib

Definition at line 160 of file PostProcessing.py.

◆ stepName

python.PostProcessing.PostProcessingStep.stepName = self.__class__.__name__

Definition at line 151 of file PostProcessing.py.

◆ taskDict

python.PostProcessing.PostProcessingStep.taskDict = taskDict

Definition at line 155 of file PostProcessing.py.

◆ taskDir

python.PostProcessing.PostProcessingStep.taskDir = '/'.join([self.dsName,self.taskName])

Definition at line 158 of file PostProcessing.py.

◆ taskman

python.PostProcessing.PostProcessingStep.taskman = taskman

Definition at line 154 of file PostProcessing.py.

◆ taskName

python.PostProcessing.PostProcessingStep.taskName = taskDict['TASKNAME']

Definition at line 157 of file PostProcessing.py.


The documentation for this class was generated from the following file: