Perform an event count check.
1039 for inData, neventsInData
in self._inEventDict.
items():
1040 if not isinstance(neventsInData, int):
1041 msg.warning(
'File size metadata for {inData} was not countable, found {neventsInData}. No event checks possible for this input data.'.
format(inData=inData, neventsInData=neventsInData))
1043 if inData
in self._eventCountConf:
1047 matchedInData =
False
1048 for inDataKey
in self._eventCountConf:
1049 if fnmatch.fnmatch(inData, inDataKey):
1050 msg.info(
"Matched input data type {inData} to {inDataKey} by globbing".
format(inData=inData, inDataKey=inDataKey))
1051 matchedInData =
True
1053 if not matchedInData:
1054 msg.warning(
'No defined event count match for {inData} -> {outData}, so no check(s) possible in this case.'.
format(inData=inData, outData=
list(self._outEventDict)))
1058 expectedEvents = neventsInData
1059 if self._skipEvents
is not None and self._skipEvents > 0:
1060 expectedEvents -= self._skipEvents
1061 if expectedEvents < 0:
1062 msg.warning(
'skipEvents was set higher than the input events in {inData}: {skipEvents} > {neventsInData}. This is not an error, but it is not a normal configuration. Expected events is now 0.'.
format(inData=inData, skipEvents=self._skipEvents, neventsInData=neventsInData))
1064 if self._maxEvents
is not None:
1065 if expectedEvents < self._maxEvents:
1066 if self._skipEvents
is not None:
1067 msg.warning(
'maxEvents was set higher than inputEvents-skipEvents for {inData}: {maxEvents} > {neventsInData}-{skipEvents}. This is not an error, but it is not a normal configuration. Expected events remains {expectedEvents}.'.
format(inData=inData, maxEvents=self._maxEvents, neventsInData=neventsInData, skipEvents=self._skipEvents, expectedEvents=expectedEvents))
1069 msg.warning(
'maxEvents was set higher than inputEvents for {inData}: {maxEvents} > {neventsInData}. This is not an error, but it is not a normal configuration. Expected events remains {expectedEvents}.'.
format(inData=inData, maxEvents=self._maxEvents, neventsInData=neventsInData, expectedEvents=expectedEvents))
1071 expectedEvents = self._maxEvents
1072 msg.debug(
'Expected number of processed events for {0} is {1}'.
format(inData, expectedEvents))
1075 for outData, neventsOutData
in self._outEventDict.
items():
1076 if not isinstance(neventsOutData, int):
1077 msg.warning(
'File size metadata for {outData} was not countable, found "{neventsOutData}". No event checks possible for this output data.'.
format(outData=outData, neventsOutData=neventsOutData))
1079 if outData
in self._eventCountConf[inDataKey]:
1080 checkConf = self._eventCountConf[inDataKey][outData]
1081 outDataKey = outData
1085 for outDataKey, outDataConf
in self._eventCountConf[inDataKey].
items():
1086 if fnmatch.fnmatch(outData, outDataKey):
1087 msg.info(
'Matched output data type {outData} to {outDatakey} by globbing'.
format(outData=outData, outDatakey=outDataKey))
1088 outDataKey = outData
1089 checkConf = outDataConf
1092 msg.warning(
'No defined event count match for {inData} -> {outData}, so no check possible in this case.'.
format(inData=inData, outData=outData))
1094 msg.debug(
'Event count check for {inData} to {outData} is {checkConf}'.
format(inData=inData, outData=outData, checkConf=checkConf))
1097 if checkConf ==
'match':
1099 if neventsOutData == expectedEvents:
1100 msg.info(
"Event count check for {inData} to {outData} passed: all processed events found ({neventsOutData} output events)".
format(inData=inData, outData=outData, neventsOutData=neventsOutData))
1102 raise trfExceptions.TransformValidationException(trfExit.nameToCode(
'TRF_EXEC_VALIDATION_EVENTCOUNT'),
1103 'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected {expectedEvents}'.
format(inData=inData, outData=outData, neventsOutData=neventsOutData, expectedEvents=expectedEvents))
1104 elif checkConf ==
'filter':
1105 if neventsOutData <= expectedEvents
and neventsOutData >= 0:
1106 msg.info(
"Event count check for {inData} to {outData} passed: found ({neventsOutData} output events selected from {expectedEvents} processed events)".
format(inData=inData, outData=outData, neventsOutData=neventsOutData, expectedEvents=expectedEvents))
1108 raise trfExceptions.TransformValidationException(trfExit.nameToCode(
'TRF_EXEC_VALIDATION_EVENTCOUNT'),
1109 'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected from 0 to {expectedEvents}'.
format(inData=inData, outData=outData, neventsOutData=neventsOutData, expectedEvents=expectedEvents))
1110 elif checkConf ==
'minEff':
1111 if neventsOutData >=
int(expectedEvents * self._evAccEff)
and neventsOutData <= expectedEvents:
1112 msg.info(
"Event count check for {inData} to {outData} passed: found ({neventsOutData} output events selected from {expectedEvents} processed events)".
format(inData=inData, outData=outData, neventsOutData=neventsOutData, expectedEvents=expectedEvents))
1114 raise trfExceptions.TransformValidationException(trfExit.nameToCode(
'TRF_EXEC_VALIDATION_EVENTCOUNT'),
1115 'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected from {minEvents} to {expectedEvents}'.
format(inData=inData, outData=outData, neventsOutData=neventsOutData,
1116 minEvents=
int(expectedEvents * self._evAccEff), expectedEvents=expectedEvents))
1117 elif isinstance(checkConf, (float, int)):
1118 checkConf =
float(checkConf)
1119 if checkConf < 0.0
or checkConf > 1.0:
1120 raise trfExceptions.TransformValidationException(trfExit.nameToCode(
'TRF_EXEC_VALIDATION_EVENTCOUNT'),
1121 'Event count check for {inData} to {outData} is misconfigured: the efficiency factor of {eff} is not between 0 and 1.'.
format(inData=inData, outData=outData, eff=checkConf))
1122 if neventsOutData >=
int(expectedEvents * checkConf)
and neventsOutData <= expectedEvents:
1123 msg.info(
"Event count check for {inData} to {outData} passed: found ({neventsOutData} output events selected from {expectedEvents} processed events)".
format(inData=inData, outData=outData, neventsOutData=neventsOutData, expectedEvents=expectedEvents))
1125 raise trfExceptions.TransformValidationException(trfExit.nameToCode(
'TRF_EXEC_VALIDATION_EVENTCOUNT'),
1126 'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected from {minEvents} to {expectedEvents}'.
format(inData=inData, outData=outData, neventsOutData=neventsOutData,
1127 minEvents=
int(expectedEvents * checkConf), expectedEvents=expectedEvents))
1129 raise trfExceptions.TransformValidationException(trfExit.nameToCode(
'TRF_EXEC_VALIDATION_EVENTCOUNT'),
1130 'Unrecognised event count configuration for {inData} to {outData}: "{conf}" is not known'.
format(inData=inData, outData=outData, conf=checkConf))
1131 self._eventCount = expectedEvents