Skip to content
Snippets Groups Projects
Commit d03a3c6e authored by David Hendriks's avatar David Hendriks
Browse files

old updates. not sure what changed

parent 208a9644
No related branches found
No related tags found
No related merge requests found
...@@ -8,10 +8,12 @@ but copying functionality isn't recommended except if you know what you are doin ...@@ -8,10 +8,12 @@ but copying functionality isn't recommended except if you know what you are doin
""" """
import os import os
import sys
import copy import copy
import json import json
import datetime import datetime
import time import time
import logging
import argparse import argparse
import importlib.util import importlib.util
...@@ -20,7 +22,6 @@ from pathos.helpers import mp as pathos_multiprocess ...@@ -20,7 +22,6 @@ from pathos.helpers import mp as pathos_multiprocess
# from pathos.multiprocessing import ProcessingPool as Pool # from pathos.multiprocessing import ProcessingPool as Pool
from pathos.pools import _ProcessPool as Pool from pathos.pools import _ProcessPool as Pool
from binarycpython.utils.grid_options_defaults import grid_options_defaults_dict from binarycpython.utils.grid_options_defaults import grid_options_defaults_dict
from binarycpython.utils.custom_logging_functions import ( from binarycpython.utils.custom_logging_functions import (
autogen_C_logging_code, autogen_C_logging_code,
...@@ -1381,6 +1382,51 @@ class Population: ...@@ -1381,6 +1382,51 @@ class Population:
""" """
self.grid_options["count"] += 1 self.grid_options["count"] += 1
def set_loggers(self):
"""
Function to set the loggers for the execution of the grid
"""
# Set logfile
binary_c_logfile = self.grid_options["log_file"]
# Create directory
os.makedirs(os.path.dirname(binary_c_logfile), exist_ok=True)
# Set up logger
self.logger = logging.getLogger('binary_c_python_logger')
self.logger.setLevel(self.grid_options["verbose"])
# Reset handlers
self.logger.handlers = []
# Set formatting of output
log_formatter = logging.Formatter(
'%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
# Make and add filehandlers
# make handler for output to file
handler_file = logging.FileHandler(
filename=os.path.join(binary_c_logfile)
)
handler_file.setFormatter(log_formatter)
handler_file.setLevel(logging.INFO)
# Make handler for output to stdout
handler_stdout = logging.StreamHandler(sys.stdout)
handler_stdout.setFormatter(log_formatter)
handler_stdout.setLevel(logging.INFO)
# Add the loggers
self.logger.addHandler(handler_file)
self.logger.addHandler(handler_stdout)
# def join_result_dicts(self): # def join_result_dicts(self):
# """ # """
# Function to join the result dictionaries # Function to join the result dictionaries
......
...@@ -11,13 +11,17 @@ grid_options_defaults_dict = { ...@@ -11,13 +11,17 @@ grid_options_defaults_dict = {
# general (or unordered..) # general (or unordered..)
########################## ##########################
"amt_cores": 1, # total amount of cores used to evolve the population "amt_cores": 1, # total amount of cores used to evolve the population
"verbose": 0, # Level of verbosity of the simulation
"binary": 0, # FLag on whether the systems are binary systems or single systems. "binary": 0, # FLag on whether the systems are binary systems or single systems.
"parse_function": None, # FUnction to parse the output with. "parse_function": None, # FUnction to parse the output with.
"tmp_dir": temp_dir(), # Setting the temp dir of the program "tmp_dir": temp_dir(), # Setting the temp dir of the program
"main_pid": -1, # Placeholder for the main process id of the run. "main_pid": -1, # Placeholder for the main process id of the run.
# "output_dir": # "output_dir":
########################## ##########################
# Execution log:
##########################
"verbose": 0, # Level of verbosity of the simulation. 0=INFO,
"log_file": os.path.join(temp_dir(), 'binary_c_python.log'), # Set to None to not log to file. The directory will be created
##########################
# binary_c files # binary_c files
########################## ##########################
"binary_c_executable": os.path.join( "binary_c_executable": os.path.join(
...@@ -43,7 +47,7 @@ grid_options_defaults_dict = { ...@@ -43,7 +47,7 @@ grid_options_defaults_dict = {
# Store pre-loading: # Store pre-loading:
########################## ##########################
"store_memaddr": -1, # Contains the store object memory adress, useful for preloading. "store_memaddr": -1, # Contains the store object memory adress, useful for preloading.
# defaults to -1 and isnt used if thats the default then. # defaults to -1 and isnt used if thats the default then.
########################## ##########################
# Log args: logging of arguments # Log args: logging of arguments
########################## ##########################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment