Skip to content

Commit

Permalink
Merge pull request #26 from nasa/logger
Browse files Browse the repository at this point in the history
logger fix
  • Loading branch information
pjuangph authored Jul 25, 2022
2 parents 1564c09 + e3f5e28 commit d816467
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions glennopt/base/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import math
import pprint
import logging
from warnings import catch_warnings
import pandas as pd
"""
External Modules
Expand Down Expand Up @@ -54,8 +55,12 @@ def __init__(self,name:str,eval_command:str, eval_folder:str = None,opt_folder:s
self.name = name
assert opt_folder is not None

logging.basicConfig(filename=os.path.join(opt_folder,'log.dat'), level=logging.DEBUG)
self.logger = logging.getLogger()
try:
logging.basicConfig(filename=os.path.join(opt_folder,'log.dat'), level=logging.DEBUG)
self.logger = logging.getLogger()
except:
self.logger = None


if (not os.path.isabs(eval_folder)):
eval_folder = os.path.join(os.getcwd(),eval_folder)
Expand Down Expand Up @@ -458,7 +463,8 @@ def __write_proc_log__(self,p:subprocess.Popen,pop:int,ind_name:str):
"""
if p is not None:
for line in p.stdout:
self.logger.debug('POP {0} Indivudual: {1} Message: {2}'.format(pop,ind_name,line.decode("utf-8").replace('\n', ' ').replace('\r', '')).strip())
if (self.logger):
self.logger.debug('POP {0} Indivudual: {1} Message: {2}'.format(pop,ind_name,line.decode("utf-8").replace('\n', ' ').replace('\r', '')).strip())

def load_history_file(self):
"""Reads the history file if exists
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "GlennOPT"
version = "1.4.3"
version = "1.4.4"
description = "Multi and single objective optimization tool for cfd/computer simulations."
authors = ["Paht Juangphanich <[email protected]>"]

Expand Down

0 comments on commit d816467

Please sign in to comment.