diff --git a/apputils/execution_env.py b/apputils/execution_env.py index 8867b9ce7964b5d1d0cfd71dba3ea89e0aa88500..52441828263f903b00135dd448e0ffee36739913 100755 --- a/apputils/execution_env.py +++ b/apputils/execution_env.py @@ -91,11 +91,12 @@ def config_pylogger(log_cfg_file, experiment_name): """ timestr = time.strftime("%Y.%m.%d-%H%M%S") filename = timestr if experiment_name is None else experiment_name + '___' + timestr - logdir = './logs' + '/' + filename + logdir = os.path.join('./logs', filename) if not os.path.exists(logdir): os.makedirs(logdir) log_filename = os.path.join(logdir, filename + '.log') - logging.config.fileConfig(os.path.join(os.getcwd(), log_cfg_file), defaults={'logfilename': log_filename}) + if os.path.isfile(log_cfg_file): + logging.config.fileConfig(log_cfg_file, defaults={'logfilename': log_filename}) msglogger = logging.getLogger() msglogger.logdir = logdir msglogger.log_filename = log_filename diff --git a/examples/classifier_compression/compress_classifier.py b/examples/classifier_compression/compress_classifier.py index b302522851ca1ab483d9419a41d7c1b63a6a2cff..3a2d5500fb52fa243451b0b13ae5d99efb946ece 100755 --- a/examples/classifier_compression/compress_classifier.py +++ b/examples/classifier_compression/compress_classifier.py @@ -146,7 +146,7 @@ def main(): global msglogger check_pytorch_version() args = parser.parse_args() - msglogger = apputils.config_pylogger('logging.conf', args.name) + msglogger = apputils.config_pylogger(os.path.join(script_dir, 'logging.conf'), args.name) # Log various details about the execution environment. It is sometimes useful # to refer to past experiment executions and this information may be useful.