Ejemplo n.º 1
0
 def _validate_historical_checks(self):
     """Method to validate staging data prior to import. By default does nothing."""
     self._logger.info(
         'Running historic validation checks on staging table data...')
     for check, result, value, hvalue, min_required_value, metric_key in self._historical_validation_checks:
         if not result:
             msg = 'Failed {check} historic check, historic value is: {hvalue:.2f}, ' \
                   'imported data has: {value:.2f} and minimum required is {min_required_value:.2f}'
             raise exceptions.ValidationCheckException(
                 msg.format(check=check,
                            hvalue=hvalue,
                            value=value,
                            min_required_value=min_required_value),
                 metric_key=metric_key,
                 statsd=self._statsd,
                 metrics_failures_root=self._metrics_failures_root)
         else:
             msg = 'Passed {check} historic check, historic value is: {hvalue:.2f}, ' \
                   'imported data has: {value:.2f} and minimum required is {min_required_value:.2f}'
             self._logger.info(
                 msg.format(check=check,
                            hvalue=hvalue,
                            value=value,
                            min_required_value=min_required_value))
     self._logger.info(
         'Finished running historic validation checks on staging table data'
     )
Ejemplo n.º 2
0
 def _validate_binary_checks(self):
     """Method to validate staging data prior to import. By default does nothing."""
     self._logger.info(
         'Running binary validation checks on staging table data...')
     for result, msg, metric_key in self._binary_validation_checks:
         if not result:
             raise exceptions.ValidationCheckException(
                 msg,
                 metric_key=metric_key,
                 statsd=self._statsd,
                 metrics_failures_root=self._metrics_failures_root)
         else:
             self._logger.info(msg)
     self._logger.info(
         'Finished running binary validation checks on staging table data')
Ejemplo n.º 3
0
 def _validate_threshold_checks(self):
     """Method to validate staging data prior to import. By default does nothing."""
     self._logger.info('Running threshold checks on staging table data...')
     for check, result, ratio, threshold, metric_key in self._threshold_validation_checks:
         if not result:
             msg = 'Failed {check} threshold check, limit is: {threshold:.2f} and imported data has: {ratio:.2f}'
             raise exceptions.ValidationCheckException(
                 msg.format(check=check, ratio=ratio, threshold=threshold),
                 metric_key=metric_key,
                 statsd=self._statsd,
                 metrics_failures_root=self._metrics_failures_root)
         else:
             msg = 'Passed {check} threshold check, limit is: {threshold:.2f} and imported data has: {ratio:.2f}'
             self._logger.info(
                 msg.format(check=check, ratio=ratio, threshold=threshold))
     self._logger.info(
         'Finished running threshold validation checks on staging table data'
     )