Benchmark-v0 / index /utils.py
Junyin's picture
Add files using upload-large-folder tool
05744dc verified
raw
history blame contribute delete
688 Bytes
import datetime
import os
def ensure_dir(dir_path):
os.makedirs(dir_path, exist_ok=True)
def set_color(log, color, highlight=True):
color_set = ["black", "red", "green", "yellow", "blue", "pink", "cyan", "white"]
try:
index = color_set.index(color)
except:
index = len(color_set) - 1
prev_log = "\033["
if highlight:
prev_log += "1;3"
else:
prev_log += "0;3"
prev_log += str(index) + "m"
return prev_log + log + "\033[0m"
def get_local_time():
r"""Get current time
Returns:
str: current time
"""
cur = datetime.datetime.now()
cur = cur.strftime("%b-%d-%Y_%H-%M-%S")
return cur