Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEA: hash config, split HyperTuning's log, add command in log #1341

Merged
merged 8 commits into from
Jul 10, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion recbole/quick_start/quick_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import logging
from logging import getLogger

import sys
import torch

import pickle

from recbole.config import Config
Expand All @@ -33,7 +36,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
Expand Down Expand Up @@ -95,6 +98,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)
Expand Down
6 changes: 4 additions & 2 deletions recbole/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import os
import colorlog
import re

import hashlib
from recbole.utils.utils import get_local_time, ensure_dir
from colorama import init

Expand Down Expand Up @@ -73,7 +73,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)

Expand Down