Download index/utils.py from JayceAnova/Benchmark-v0: direct link, hf CLI and curl.
- Browser
- Download file 688 Bytes
-
https://huggingface.co/JayceAnova/Benchmark-v0/resolve/main/index/utils.py
- Command line
-
hf download hf://JayceAnova/Benchmark-v0/index/utils.py
-
curl -L -o utils.py https://huggingface.co/JayceAnova/Benchmark-v0/resolve/main/index/utils.py
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 | |