logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

27 lines
645 B

2 years ago
# every utils that don't use torch
import hashlib
import json
import logging
import multiprocessing as mp
import os
def get_hash(s):
m = hashlib.md5()
m.update(s.encode('utf8'))
return m.hexdigest()
def read_config(path):
with open(path, 'r') as fin:
return json.load(fin)
def init_logger(app_name):
os.makedirs('logs', exist_ok=True)
logger = mp.get_logger()
logger.setLevel(logging.INFO)
handler = logging.FileHandler('logs/%s.log' % app_name, encoding="utf8")
handler.setFormatter(logging.Formatter('[%(asctime)s] [%(processName)s/%(levelname)s] %(message)s'))
logger.addHandler(handler)