ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.PostProcessing.PostProcessingStep Class Reference
Collaboration diagram for python.PostProcessing.PostProcessingStep:

Public Member Functions

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

Public Attributes

 stepName
 
 executedSteps
 
 taskman
 
 taskDict
 
 dsName
 
 taskName
 
 taskDir
 
 oldStatus
 
 postprocLib
 
 jobName
 
 baseName
 
 baseNameStep
 
 logfile
 

Detailed Description

Definition at line 148 of file PostProcessing.py.

Constructor & Destructor Documentation

◆ __init__()

def 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__()

def 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()

def 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()

def 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()

def 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()

def 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 

◆ jobList()

def 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()

def 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()

def 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 

◆ taskFileList()

def 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

python.PostProcessing.PostProcessingStep.baseName

Definition at line 162 of file PostProcessing.py.

◆ baseNameStep

python.PostProcessing.PostProcessingStep.baseNameStep

Definition at line 163 of file PostProcessing.py.

◆ dsName

python.PostProcessing.PostProcessingStep.dsName

Definition at line 156 of file PostProcessing.py.

◆ executedSteps

python.PostProcessing.PostProcessingStep.executedSteps

Definition at line 152 of file PostProcessing.py.

◆ jobName

python.PostProcessing.PostProcessingStep.jobName

Definition at line 161 of file PostProcessing.py.

◆ logfile

python.PostProcessing.PostProcessingStep.logfile

Definition at line 164 of file PostProcessing.py.

◆ oldStatus

python.PostProcessing.PostProcessingStep.oldStatus

Definition at line 159 of file PostProcessing.py.

◆ postprocLib

python.PostProcessing.PostProcessingStep.postprocLib

Definition at line 160 of file PostProcessing.py.

◆ stepName

python.PostProcessing.PostProcessingStep.stepName

Definition at line 151 of file PostProcessing.py.

◆ taskDict

python.PostProcessing.PostProcessingStep.taskDict

Definition at line 155 of file PostProcessing.py.

◆ taskDir

python.PostProcessing.PostProcessingStep.taskDir

Definition at line 158 of file PostProcessing.py.

◆ taskman

python.PostProcessing.PostProcessingStep.taskman

Definition at line 154 of file PostProcessing.py.

◆ taskName

python.PostProcessing.PostProcessingStep.taskName

Definition at line 157 of file PostProcessing.py.


The documentation for this class was generated from the following file:
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename R::value_type > sorted(const R &r, PROJ proj={})
Helper function to create a sorted vector from an unsorted range.
python.TaskManager.getJobConfig
def getJobConfig(jobDir, dsName, taskName, jobName=' *')
Definition: TaskManager.py:101
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
python.processes.powheg.ZZj_MiNNLO.ZZj_MiNNLO.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZj_MiNNLO.py:18
buildDatabase.getKey
def getKey(filename)
Definition: buildDatabase.py:545
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
RCU::hadd
void hadd(const std::string &output_file, const std::vector< std::string > &input_files, unsigned max_files)
effects: perform the hadd functionality guarantee: basic failures: out of memory III failures: i/o er...
Definition: hadd.cxx:28
LArG4FSStartPointFilter.exec
exec
Definition: LArG4FSStartPointFilter.py:103
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
Trk::open
@ open
Definition: BinningType.h:40
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.AthDsoLogger.__del__
def __del__(self)
Definition: AthDsoLogger.py:81
python.TrfUtils.getFileName
def getFileName(name, sep='#')
Definition: TrfUtils.py:45
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
python.Utils.getUserName
def getUserName(default='UNKNOWN')
Definition: InnerDetector/InDetExample/InDetBeamSpotExample/python/Utils.py:48
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65