Perform an event count check.
1038 for inData, neventsInData
in self._inEventDict.
items():
1039 if not isinstance(neventsInData, int):
1040 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))
1042 if inData
in self._eventCountConf:
1046 matchedInData =
False
1047 for inDataKey
in self._eventCountConf:
1048 if fnmatch.fnmatch(inData, inDataKey):
1049 msg.info(
"Matched input data type {inData} to {inDataKey} by globbing".
format(inData=inData, inDataKey=inDataKey))
1050 matchedInData =
True
1052 if not matchedInData:
1053 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)))
1057 expectedEvents = neventsInData
1058 if self._skipEvents
is not None and self._skipEvents > 0:
1059 expectedEvents -= self._skipEvents
1060 if expectedEvents < 0:
1061 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))
1063 if self._maxEvents
is not None:
1064 if expectedEvents < self._maxEvents:
1065 if self._skipEvents
is not None:
1066 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))
1068 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))
1070 expectedEvents = self._maxEvents
1071 msg.debug(
'Expected number of processed events for {0} is {1}'.
format(inData, expectedEvents))
1074 for outData, neventsOutData
in self._outEventDict.
items():
1075 if not isinstance(neventsOutData, int):
1076 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))
1078 if outData
in self._eventCountConf[inDataKey]:
1079 checkConf = self._eventCountConf[inDataKey][outData]
1080 outDataKey = outData
1084 for outDataKey, outDataConf
in self._eventCountConf[inDataKey].
items():
1085 if fnmatch.fnmatch(outData, outDataKey):
1086 msg.info(
'Matched output data type {outData} to {outDatakey} by globbing'.
format(outData=outData, outDatakey=outDataKey))
1087 outDataKey = outData
1088 checkConf = outDataConf
1091 msg.warning(
'No defined event count match for {inData} -> {outData}, so no check possible in this case.'.
format(inData=inData, outData=outData))
1093 msg.debug(
'Event count check for {inData} to {outData} is {checkConf}'.
format(inData=inData, outData=outData, checkConf=checkConf))
1096 if checkConf ==
'match':
1098 if neventsOutData == expectedEvents:
1099 msg.info(
"Event count check for {inData} to {outData} passed: all processed events found ({neventsOutData} output events)".
format(inData=inData, outData=outData, neventsOutData=neventsOutData))
1101 raise trfExceptions.TransformValidationException(trfExit.nameToCode(
'TRF_EXEC_VALIDATION_EVENTCOUNT'),
1102 'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected {expectedEvents}'.
format(inData=inData, outData=outData, neventsOutData=neventsOutData, expectedEvents=expectedEvents))
1103 elif checkConf ==
'filter':
1104 if neventsOutData <= expectedEvents
and neventsOutData >= 0:
1105 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))
1107 raise trfExceptions.TransformValidationException(trfExit.nameToCode(
'TRF_EXEC_VALIDATION_EVENTCOUNT'),
1108 '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))
1109 elif checkConf ==
'minEff':
1110 if neventsOutData >=
int(expectedEvents * self._evAccEff)
and neventsOutData <= expectedEvents:
1111 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))
1113 raise trfExceptions.TransformValidationException(trfExit.nameToCode(
'TRF_EXEC_VALIDATION_EVENTCOUNT'),
1114 'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected from {minEvents} to {expectedEvents}'.
format(inData=inData, outData=outData, neventsOutData=neventsOutData,
1115 minEvents=
int(expectedEvents * self._evAccEff), expectedEvents=expectedEvents))
1116 elif isinstance(checkConf, (float, int)):
1117 checkConf =
float(checkConf)
1118 if checkConf < 0.0
or checkConf > 1.0:
1119 raise trfExceptions.TransformValidationException(trfExit.nameToCode(
'TRF_EXEC_VALIDATION_EVENTCOUNT'),
1120 '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))
1121 if neventsOutData >=
int(expectedEvents * checkConf)
and neventsOutData <= expectedEvents:
1122 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))
1124 raise trfExceptions.TransformValidationException(trfExit.nameToCode(
'TRF_EXEC_VALIDATION_EVENTCOUNT'),
1125 'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected from {minEvents} to {expectedEvents}'.
format(inData=inData, outData=outData, neventsOutData=neventsOutData,
1126 minEvents=
int(expectedEvents * checkConf), expectedEvents=expectedEvents))
1128 raise trfExceptions.TransformValidationException(trfExit.nameToCode(
'TRF_EXEC_VALIDATION_EVENTCOUNT'),
1129 'Unrecognised event count configuration for {inData} to {outData}: "{conf}" is not known'.
format(inData=inData, outData=outData, conf=checkConf))
1130 self._eventCount = expectedEvents