From a7ed8cad42e9da4148bdcb80a17e480079f352d5 Mon Sep 17 00:00:00 2001
From: Neta Zmora <neta.zmora@intel.com>
Date: Thu, 17 May 2018 19:33:14 +0300
Subject: [PATCH] Fix system tests failure

The latest changes to the logger caused the CI tests to fail,
because test assumes that the logging.conf file is present in the
same directory as the sample application script.
The sample application used cwd() instead, and did not find the
log configuration file.
---
 apputils/execution_env.py                              | 5 +++--
 examples/classifier_compression/compress_classifier.py | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/apputils/execution_env.py b/apputils/execution_env.py
index 8867b9c..5244182 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 b302522..3a2d550 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.
-- 
GitLab