def operator_validator(alert: Alert, validator_config: str) -> bool: """ Returns True if a recent observation is greater than or equal to the value given in the validator config """ observation = alert.get_last_observation() if not observation or observation.value in (None, np.nan): return False operator = json.loads(validator_config)["op"] threshold = json.loads(validator_config)["threshold"] return OPERATOR_FUNCTIONS[operator](observation.value, threshold)
def not_null_validator( alert: Alert, validator_config: str # pylint: disable=unused-argument ) -> bool: """Returns True if a recent observation is not NULL""" observation = alert.get_last_observation() # TODO: Validate malformed observations/observations with errors separately if (not observation or observation.error_msg or observation.value in (0, None, np.nan)): return False return True