diff --git a/src/gretel_trainer/benchmark/__init__.py b/src/gretel_trainer/benchmark/__init__.py index da7efc83..9f76eced 100644 --- a/src/gretel_trainer/benchmark/__init__.py +++ b/src/gretel_trainer/benchmark/__init__.py @@ -1,5 +1,3 @@ -import logging - from gretel_trainer.benchmark.core import BenchmarkConfig, Datatype from gretel_trainer.benchmark.custom.datasets import create_dataset, make_dataset from gretel_trainer.benchmark.entrypoints import compare, launch @@ -18,20 +16,4 @@ GretelLSTM, GretelModel, ) - -log_format = "%(levelname)s - %(asctime)s - %(message)s" -time_format = "%Y-%m-%d %H:%M:%S" -formatter = logging.Formatter(log_format, time_format) -handler = logging.StreamHandler() -handler.setFormatter(formatter) - -# Clear out any existing root handlers -# (This prevents duplicate log output in Colab) -for root_handler in logging.root.handlers: - logging.root.removeHandler(root_handler) - -# Configure benchmark loggers -logger = logging.getLogger("gretel_trainer.benchmark") -logger.handlers.clear() -logger.addHandler(handler) -logger.setLevel("INFO") +from gretel_trainer.benchmark.log import set_log_level diff --git a/src/gretel_trainer/benchmark/log.py b/src/gretel_trainer/benchmark/log.py new file mode 100644 index 00000000..3144d371 --- /dev/null +++ b/src/gretel_trainer/benchmark/log.py @@ -0,0 +1,24 @@ +import logging + +BENCHMARK = "gretel_trainer.benchmark" + +log_format = "%(levelname)s - %(asctime)s - %(message)s" +time_format = "%Y-%m-%d %H:%M:%S" +formatter = logging.Formatter(log_format, time_format) +handler = logging.StreamHandler() +handler.setFormatter(formatter) + +logger = logging.getLogger(BENCHMARK) +logger.handlers.clear() +logger.addHandler(handler) +logger.setLevel("INFO") + +# Clear out any existing root handlers +# (This prevents duplicate log output in Colab) +for root_handler in logging.root.handlers: + logging.root.removeHandler(root_handler) + + +def set_log_level(level: str): + logger = logging.getLogger(BENCHMARK) + logger.setLevel(level)