mpt-30b-instruct / logging_utils.py
irenedea's picture
LLM-foundry update March 26, 2024 23:50:31
ef9200f verified
raw
history blame
814 Bytes
import logging
import os
class SpecificWarningFilter(logging.Filter):
def __init__(self, message_to_suppress: str):
"""Filter out a specific warning message based on its content.
This can be useful for filtering out specific warning messages from third party packages.
Args:
message_to_suppress (str): The warning message to suppress.
"""
super().__init__()
self.message_to_suppress = message_to_suppress
def filter(self, record: logging.LogRecord) -> bool:
return self.message_to_suppress not in record.getMessage()
def get_mosaicml_logger():
if os.environ.get(MOSAICML_PLATFORM_ENV_VAR, 'false').lower() == 'true' and os.environ.get(MOSAICML_ACCESS_TOKEN_ENV_VAR):
return MosaicMLLogger()
else:
return None