refactor/test: logging suppression + hashed image test
- simpler logging suppression for `transformers` library - suppress logging noise for running tests - get test running for all samplers on mps and cuda platforms - refactor safety model env variable to allow classificationpull/1/head
parent
8c88f495d2
commit
967eb76365
@ -1 +0,0 @@
|
||||
imaginairy-3.10.6
|
@ -0,0 +1,40 @@
|
||||
import logging.config
|
||||
import warnings
|
||||
|
||||
|
||||
def disable_transformers_custom_logging():
|
||||
from transformers.modeling_utils import logger
|
||||
from transformers.utils.logging import _configure_library_root_logger
|
||||
|
||||
_configure_library_root_logger()
|
||||
logger = logger.parent
|
||||
logger.handlers = []
|
||||
logger.propagate = True
|
||||
logger.setLevel(logging.NOTSET)
|
||||
|
||||
|
||||
def disable_pytorch_lighting_custom_logging():
|
||||
from pytorch_lightning import _logger
|
||||
|
||||
_logger.setLevel(logging.NOTSET)
|
||||
|
||||
|
||||
def disable_common_warnings():
|
||||
warnings.filterwarnings(
|
||||
"ignore",
|
||||
category=UserWarning,
|
||||
message=r"The operator .*?is not currently supported.*",
|
||||
)
|
||||
warnings.filterwarnings(
|
||||
"ignore", category=UserWarning, message=r"The parameter 'pretrained' is.*"
|
||||
)
|
||||
warnings.filterwarnings(
|
||||
"ignore", category=UserWarning, message=r"Arguments other than a weight.*"
|
||||
)
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
|
||||
|
||||
def suppress_annoying_logs_and_warnings():
|
||||
disable_transformers_custom_logging()
|
||||
disable_pytorch_lighting_custom_logging()
|
||||
disable_common_warnings()
|
@ -0,0 +1,15 @@
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
from imaginairy.suppress_logs import suppress_annoying_logs_and_warnings
|
||||
|
||||
if "pytest" in str(sys.argv):
|
||||
suppress_annoying_logs_and_warnings()
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def pre_setup():
|
||||
from imaginairy import api
|
||||
|
||||
api.IMAGINAIRY_SAFETY_MODE = "disabled"
|
Loading…
Reference in New Issue