From 3df48f10c0556d99d97658b0438f06e798ec3584 Mon Sep 17 00:00:00 2001
From: David Hendriks <davidhendriks93@gmail.com>
Date: Sun, 8 Aug 2021 17:49:04 +0100
Subject: [PATCH] changed levels of verbosity

---
 binarycpython/utils/grid.py                  | 27 +++++++++++++-------
 binarycpython/utils/grid_options_defaults.py |  1 +
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py
index c2ef2fea3..0d35b58d5 100644
--- a/binarycpython/utils/grid.py
+++ b/binarycpython/utils/grid.py
@@ -48,6 +48,7 @@ from binarycpython.utils.grid_options_defaults import (
     moe_di_stefano_default_options,
     _MS_VERBOSITY_LEVEL,
     _CUSTOM_LOGGING_VERBOSITY_LEVEL,
+    _LOGGER_VERBOSITY_LEVEL,
 )
 
 from binarycpython.utils.custom_logging_functions import (
@@ -909,7 +910,8 @@ class Population:
         """
 
         stream_logger = self.get_stream_logger()
-        stream_logger.debug(f"setting up the system_queue_filler now")
+        if self.grid_options['verbosity'] >= _LOGGER_VERBOSITY_LEVEL:
+            stream_logger.debug(f"setting up the system_queue_filler now")
 
         # Setup of the generator
         self._generate_grid_code(dry_run=False)
@@ -925,7 +927,6 @@ class Population:
             job_queue.put((system_number, system_dict))
 
             # Print some info
-            # stream_logger.debug(f"producing: {system_number}")  # DEBUG
             verbose_print(
                 "Queue produced system {}".format(system_number),
                 self.grid_options["verbosity"],
@@ -947,7 +948,9 @@ class Population:
             #     print("\tsystem_queue_filler: Size dir(self): {}".format(convert_bytes(bytes_size_self)))
 
         # Send closing signal to workers. When they receive this they will terminate
-        stream_logger.debug(f"Signaling stop to processes")  # DEBUG
+        if self.grid_options['verbosity'] >= _LOGGER_VERBOSITY_LEVEL:
+            stream_logger.debug(f"Signaling stop to processes")  # DEBUG
+    
         for _ in range(amt_cores):
             job_queue.put("STOP")
 
@@ -1145,7 +1148,8 @@ class Population:
         )
 
         stream_logger = self.get_stream_logger()
-        stream_logger.debug(f"Setting up processor: process-{self.process_ID}")
+        if self.grid_options['verbosity'] >= _LOGGER_VERBOSITY_LEVEL:
+            stream_logger.debug(f"Setting up processor: process-{self.process_ID}")
 
         # Set the process names
         name = 'binarycpython population thread {}'.format(ID)
@@ -1174,7 +1178,7 @@ class Population:
                 self.grid_options["_store_memaddr"],
             ),
             self.grid_options["verbosity"],
-            0,
+            1,
         )
 
         # Set the ensemble memory address
@@ -1191,7 +1195,7 @@ class Population:
             verbose_print(
                 "\tUsing persistent_data memaddr: {}".format(persistent_data_memaddr),
                 self.grid_options["verbosity"],
-                0,
+                1,
             )
 
         # Set up local variables
@@ -1359,7 +1363,10 @@ class Population:
             "w",
         ) as f:
             f.write("FINISHING")
-        stream_logger.debug(f"Process-{self.process_ID} is finishing.")
+
+        if self.grid_options['verbosity'] >= _LOGGER_VERBOSITY_LEVEL:
+            stream_logger.debug(f"Process-{self.process_ID} is finishing.")
+
 
         # Handle ensemble output: is ensemble==1, then either directly write that data to a file, or combine everything into 1 file.
         ensemble_json = {}  # Make sure it exists already
@@ -1458,7 +1465,7 @@ class Population:
 
             ),
             self.grid_options["verbosity"],
-            0,
+            1,
         )
 
         # Write summary
@@ -1499,7 +1506,9 @@ class Population:
             f.write("FINISHED")
 
         result_queue.put(output_dict)
-        stream_logger.debug(f"Process-{self.process_ID} is finished.")
+
+        if self.grid_options['verbosity'] >= _LOGGER_VERBOSITY_LEVEL:
+            stream_logger.debug(f"Process-{self.process_ID} is finished.")
 
         # Clean up the interpolators if they exist
 
diff --git a/binarycpython/utils/grid_options_defaults.py b/binarycpython/utils/grid_options_defaults.py
index e74f9c395..37585f2e4 100644
--- a/binarycpython/utils/grid_options_defaults.py
+++ b/binarycpython/utils/grid_options_defaults.py
@@ -18,6 +18,7 @@ import os
 from binarycpython.utils.custom_logging_functions import temp_dir
 from binarycpython.utils.functions import return_binary_c_version_info
 
+_LOGGER_VERBOSITY_LEVEL = 1
 _CUSTOM_LOGGING_VERBOSITY_LEVEL = 2
 _MS_VERBOSITY_LEVEL = 5
 _MS_VERBOSITY_INTERPOLATOR_LEVEL = 6
-- 
GitLab