-
Notifications
You must be signed in to change notification settings - Fork 11
/
common.py
35 lines (25 loc) · 846 Bytes
/
common.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Common utils
"""
import warnings
warnings.filterwarnings("ignore")
import os, datetime
import argparse
from stable_baselines3.common.logger import configure
logger = None
def create_output_dir(args):
output_dir = args.env + datetime.datetime.now().strftime('-%Y-%m-%d_%H-%M-%S')
output_fullpath = os.path.join(os.path.expanduser(args.output_basedir), output_dir)
os.makedirs(output_fullpath, exist_ok=True)
#logger.configure(output_fullpath)
return output_fullpath
def init_logger(args):
tmp_path = create_output_dir(args)
# set up logger
global logger
logger = configure(tmp_path, ["stdout", "csv", "tensorboard"])
return logger
def com_print(text):
logger.log(text)
def get_model_file_name(args):
return args.env + '-' + args.alg + '-' + args.nn + '-' + str(args.num_timesteps)