From 856e96e4c5112c38f8e5d021a7d7cc52542dcb44 Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Mon, 14 Dec 2020 23:58:22 +0000 Subject: [PATCH] trying to fix the system errors --- binarycpython/utils/grid.py | 30 ++++++++++++++++++++ binarycpython/utils/grid_options_defaults.py | 1 + 2 files changed, 31 insertions(+) diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index e647a0f25..b05cc4c68 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -2211,5 +2211,35 @@ class Population: # Function to join the result dictionaries # """ + def _check_binary_c_error(self, binary_c_output, argstring): + """ + Function to check whether binary_c throws an error and handle accordingly. + + TODO: build mechanism to stop the run if too many failing systems found + """ + + # print(binary_c_output) + # print(argstring) + + if binary_c_output.startswith("SYSTEM_ERROR"): + # print('error found') + + # Write arglines to file + with open(os.path.join(self.grid_options['tmp_dir'], 'failed_systems.txt'), 'a+') as f: + f.write(argstring) + + try: + error_code = int(binary_c_output.splitlines()[0].split("with error code")[-1].split(":")[0].strip()) + + print(int(error_code)) + # print(binary_c_output.splitlines()[0].split("with error code")[-1].split(":")[0]) + if not error_code in self.grid_options['failing_systems_error_codes']: + self.grid_options['failing_systems_error_codes'].apppend(error_code) + except ValueError: + print("failed to extract the error-code") + + self.grid_options['failed_count'] += 1 + self.grid_options[''] + ################################################################################################ diff --git a/binarycpython/utils/grid_options_defaults.py b/binarycpython/utils/grid_options_defaults.py index 659245e1d..8c6b81d21 100644 --- a/binarycpython/utils/grid_options_defaults.py +++ b/binarycpython/utils/grid_options_defaults.py @@ -83,6 +83,7 @@ grid_options_defaults_dict = { "error": 0, # error? "failed_count": 0, # amt of failed systems "failed_prob": 0, # Summed probability of failed systems + "failed_systems_error_codes": [], "id": 0, # Random id of this grid/population run, "modulo": 1, # run modulo n of the grid. ## Grid type evolution -- GitLab