Source code for evalml.data_checks.data_check_message
"""Messages returned by a DataCheck, tagged by name."""fromevalml.data_checks.data_check_message_typeimportDataCheckMessageType
[docs]classDataCheckMessage:"""Base class for a message returned by a DataCheck, tagged by name. Args: message (str): Message string. data_check_name (str): Name of the associated data check. message_code (DataCheckMessageCode, optional): Message code associated with the message. Defaults to None. details (dict, optional): Additional useful information associated with the message. Defaults to None. action_options (list, optional): A list of `DataCheckActionOption`s associated with the message. Defaults to None. """message_type=Nonedef__init__(self,message,data_check_name,message_code=None,details=None,action_options=None,):self.message=messageself.data_check_name=data_check_nameself.message_code=message_codeself.details={"columns":None,"rows":None}ifdetailsisnotNone:self.details.update(details)self.action_options=action_optionsdef__str__(self):"""String representation of data check message, equivalent to self.message attribute."""returnself.messagedef__eq__(self,other):"""Check for equality. Two DataCheckMessage objs are considered equivalent if all of their attributes are equivalent. Args: other: An object to compare equality with. Returns: bool: True if the other object is considered an equivalent data check message, False otherwise. """return(self.message_type==other.message_typeandself.message==other.messageandself.data_check_name==other.data_check_nameandself.message_code==other.message_codeandself.details==other.detailsandself.action_options==other.action_options)
[docs]defto_dict(self):"""Return a dictionary form of the data check message."""message_dict={"message":self.message,"data_check_name":self.data_check_name,"level":self.message_type.value,"details":self.details,}ifself.message_codeisnotNone:message_dict.update({"code":self.message_code.name})action_options_dict=[]ifself.action_options:foraction_optioninself.action_options:action_options_dict.append(action_option.to_dict())message_dict.update({"action_options":action_options_dict})returnmessage_dict
[docs]classDataCheckError(DataCheckMessage):"""DataCheckMessage subclass for errors returned by data checks."""message_type=DataCheckMessageType.ERROR"""DataCheckMessageType.ERROR"""
[docs]classDataCheckWarning(DataCheckMessage):"""DataCheckMessage subclass for warnings returned by data checks."""message_type=DataCheckMessageType.WARNING"""DataCheckMessageType.WARNING"""