140 def python(self, fast = False, fileReport = defaultFileReport):
141 myDict = {
'name': self._trf.name,
142 'reportVersion': self._reportVersion,
144 'exitAcronym': trfExit.codeToName(self._trf.exitCode),
145 'exitCode': self._trf.exitCode,
147 'resource': {
'executor': {},
'transform': {}},
150 if len(self._trf.exitMsg) > self._maxMsgLen:
151 myDict[
'exitMsg'] = self._trf.exitMsg[:self._maxMsgLen-len(self._truncationMsg)] + self._truncationMsg
152 myDict[
'exitMsgExtra'] = self._trf.exitMsg[self._maxMsgLen-len(self._truncationMsg):]
154 myDict[
'exitMsg'] = self._trf.exitMsg
155 myDict[
'exitMsgExtra'] =
""
158 for fileType
in (
'input',
'output',
'temporary'):
159 if fileReport[fileType]:
160 myDict[
'files'][fileType] = []
162 for dataType, dataArg
in self._trf._dataDictionary.items():
163 if isinstance(dataArg, list):
165 if dataArg.auxiliaryFile:
167 if fileReport[dataArg.io]:
168 entry = {
"type": dataType}
169 entry.update(trfFileReport(dataArg).
python(fast = fast, type = fileReport[dataArg.io]))
171 if 'subFiles' in entry
and len(entry[
'subFiles']) == 0
and isinstance(dataArg, trfArgClasses.argBSFile) :
172 msg.info(
'No subFiles for entry {0}, suppressing from report.'.
format(entry[
'argName']))
174 myDict[
'files'][dataArg.io].
append(entry)
177 myDict[
'executor'] = []
178 if hasattr(self._trf,
'_executorPath'):
179 for executionStep
in self._trf._executorPath:
180 exe = self._trf._executorDictionary[executionStep[
'name']]
181 myDict[
'executor'].
append(trfExecutorReport(exe).
python(fast = fast))
185 for mergeStep
in exe.myMerger:
186 myDict[
'resource'][
'executor'][mergeStep.name] =
exeResourceReport(mergeStep, self)
187 if self._dbDataTotal > 0
or self._dbTimeTotal > 0:
188 myDict[
'resource'][
'dbDataTotal'] = self._dbDataTotal
189 myDict[
'resource'][
'dbTimeTotal'] = self.roundoff(self._dbTimeTotal)
191 reportTime = os.times()
194 myCpuTime = reportTime[0] + reportTime[1]
195 childCpuTime = reportTime[2] + reportTime[3]
196 wallTime = reportTime[4] - self._trf.transformStart[4]
199 cpuTimePerWorker = myCpuTime
201 msg.debug(
'Raw cpu resource consumption: transform {0}, children {1}'.
format(myCpuTime, childCpuTime))
203 for exeName, exeReport
in myDict[
'resource'][
'executor'].
items():
204 if 'mpworkers' in exeReport:
205 if exeReport[
'mpworkers'] > maxWorkers : maxWorkers = exeReport[
'mpworkers']
207 msg.debug(
'Subtracting {0}s time for executor {1}'.
format(exeReport[
'cpuTime'], exeName))
208 childCpuTime -= exeReport[
'cpuTime']
212 cpuTime += exeReport[
'cpuTime']
213 cpuTimeTotal += exeReport[
'total'][
'cpuTime']
214 if 'cpuTimePerWorker' in exeReport:
215 msg.debug(
'Adding {0}s to cpuTimePerWorker'.
format(exeReport[
'cpuTimePerWorker']))
216 cpuTimePerWorker += exeReport[
'cpuTimePerWorker']
218 msg.debug(
'Adding nonMP cpuTime {0}s to cpuTimePerWorker'.
format(exeReport[
'cpuTime']))
219 cpuTimePerWorker += exeReport[
'cpuTime']
223 msg.debug(
'maxWorkers: {0}, cpuTimeTotal: {1}, cpuTimePerWorker: {2}'.
format(maxWorkers, cpuTime, cpuTimePerWorker))
224 reportGenerationCpuTime = reportGenerationWallTime =
None
225 if self._trf.outFileValidationStop
and reportTime:
226 reportGenerationCpuTime =
calcCpuTime(self._trf.outFileValidationStop, reportTime)
227 reportGenerationWallTime =
calcWallTime(self._trf.outFileValidationStop, reportTime)
229 myDict[
'resource'][
'transform'] = {
'cpuTime': self.roundoff(myCpuTime),
230 'cpuTimeTotal': self.roundoff(cpuTimeTotal),
231 'externalCpuTime': self.roundoff(childCpuTime),
232 'wallTime': self.roundoff(wallTime),
233 'transformSetup': {
'cpuTime': self.roundoff(self._trf.transformSetupCpuTime),
234 'wallTime': self.roundoff(self._trf.transformSetupWallTime)},
235 'inFileValidation': {
'cpuTime': self.roundoff(self._trf.inFileValidationCpuTime),
236 'wallTime': self.roundoff(self._trf.inFileValidationWallTime)},
237 'outFileValidation': {
'cpuTime': self.roundoff(self._trf.outFileValidationCpuTime),
238 'wallTime': self.roundoff(self._trf.outFileValidationWallTime)},
239 'reportGeneration': {
'cpuTime': self.roundoff(reportGenerationCpuTime),
240 'wallTime': self.roundoff(reportGenerationWallTime)}, }
241 if self._trf.processedEvents:
242 myDict[
'resource'][
'transform'][
'processedEvents'] = self._trf.processedEvents
243 myDict[
'resource'][
'transform'][
'trfPredata'] = self._trf.trfPredata
246 myDict[
'resource'][
'transform'][
'cpuEfficiency'] =
round(cpuTime/maxWorkers/wallTime, 4)
247 myDict[
'resource'][
'transform'][
'cpuPWEfficiency'] =
round(cpuTimePerWorker/wallTime, 4)
248 myDict[
'resource'][
'machine'] = machineReport().
python(fast = fast)