diff --git a/recbole/quick_start/quick_start.py b/recbole/quick_start/quick_start.py index fe4aa8c5c..0aac9a56b 100644 --- a/recbole/quick_start/quick_start.py +++ b/recbole/quick_start/quick_start.py @@ -2,6 +2,11 @@ # @Author : Shanlei Mu # @Email : slmu@ruc.edu.cn +# UPDATE: +# @Time : 2022/07/10 +# @Author : Junjie Zhang +# @Email : zjj001128@163.com + """ recbole.quick_start ######################## @@ -9,6 +14,9 @@ import logging from logging import getLogger +import sys + + import pickle from recbole.config import Config @@ -33,7 +41,7 @@ def run_recbole(model=None, dataset=None, config_file_list=None, config_dict=Non # logger initialization init_logger(config) logger = getLogger() - + logger.info(sys.argv) logger.info(config) # dataset filtering @@ -95,6 +103,10 @@ def objective_function(config_dict=None, config_file_list=None, saved=True): config = Config(config_dict=config_dict, config_file_list=config_file_list) init_seed(config['seed'], config['reproducibility']) + logger = getLogger() + for hdlr in logger.handlers[:]: # remove all old handlers + logger.removeHandler(hdlr) + init_logger(config) logging.basicConfig(level=logging.ERROR) dataset = create_dataset(config) train_data, valid_data, test_data = data_preparation(config, dataset) diff --git a/recbole/utils/logger.py b/recbole/utils/logger.py index a50e8ce77..18b850e9c 100644 --- a/recbole/utils/logger.py +++ b/recbole/utils/logger.py @@ -8,6 +8,11 @@ # @Author : Jiawei Guan # @Email : guanjw@ruc.edu.cn +# UPDATE: +# @Time : 2022/07/10 +# @Author : Junjie Zhang +# @Email : zjj001128@163.com + """ recbole.utils.logger ############################### @@ -17,7 +22,7 @@ import os import colorlog import re - +import hashlib from recbole.utils.utils import get_local_time, ensure_dir from colorama import init @@ -73,7 +78,9 @@ def init_logger(config): ensure_dir(dir_name) model_name = os.path.join(dir_name, config['model']) ensure_dir(model_name) - logfilename = '{}/{}.log'.format(config['model'], get_local_time()) + config_str = ''.join([str(key) for key in config.final_config_dict.values()]) + md5 = hashlib.md5(config_str.encode(encoding='utf-8')).hexdigest()[:6] + logfilename = '{}/{}-{}.log'.format(config['model'], get_local_time(), md5) logfilepath = os.path.join(LOGROOT, logfilename)