json parsing error handling
$ ./runRadarGUI_analyze.py
Traceback (most recent call last):
File "/home/vys0053/radar/SGS18-READEX/src/main_menu_analyze.py", line 44, in __init__
self.raw_data = data_load.DataLoad(config_path, meric_config_path).data
File "/home/vys0053/radar/SGS18-READEX/src/data_load.py", line 77, in __init__
self.meric_config_energy_data = json.loads(meric_config_energy_str)
File "/apps/all/Python/3.9.6-GCCcore-11.2.0/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/apps/all/Python/3.9.6-GCCcore-11.2.0/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/apps/all/Python/3.9.6-GCCcore-11.2.0/lib/python3.9/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ':' delimiter: line 2 column 18 (char 19)
INFO: Creating Evaluator object...
INFO: Creating DataReader object...
INFO: DataReader object successfully created.
INFO: Reading settings from config file...
INFO: Settings succesfully loaded.
INFO: Reading data from CSV files...
INFO: Reading data of the main region iPic3D_static...
Traceback (most recent call last):
File "/home/vys0053/radar/SGS18-READEX/src/main_menu_analyze.py", line 44, in __init__
self.raw_data = data_load.DataLoad(config_path, meric_config_path).data
File "/home/vys0053/radar/SGS18-READEX/src/data_load.py", line 77, in __init__
self.meric_config_energy_data = json.loads(meric_config_energy_str)
File "/apps/all/Python/3.9.6-GCCcore-11.2.0/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/apps/all/Python/3.9.6-GCCcore-11.2.0/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/apps/all/Python/3.9.6-GCCcore-11.2.0/lib/python3.9/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ':' delimiter: line 2 column 18 (char 19)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/vys0053/radar/SGS18-READEX/src/radarGUI_analyze.py", line 680, in __save_and_run
self.main_menu = main_menu_analyze.MainMenu(self.save_file_path, self.meric_config_path, self.tree_data_selected)
File "/home/vys0053/radar/SGS18-READEX/src/main_menu_analyze.py", line 103, in __init__
self.radar_data = DataHandler(self.config_path, self.meric_config_path)
File "/home/vys0053/radar/SGS18-READEX/src/main_menu_analyze.py", line 48, in __init__
self.__run_old_radar(config_path)
File "/home/vys0053/radar/SGS18-READEX/src/main_menu_analyze.py", line 64, in __run_old_radar
self.raw_data = run_path(path_to_radar + "/get_data_for_gui.py")
File "/apps/all/Python/3.9.6-GCCcore-11.2.0/lib/python3.9/runpy.py", line 268, in run_path
return _run_module_code(code, init_globals, run_name,
File "/apps/all/Python/3.9.6-GCCcore-11.2.0/lib/python3.9/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/apps/all/Python/3.9.6-GCCcore-11.2.0/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/vys0053/radar/readex-radar//get_data_for_gui.py", line 228, in <module>
default_optimal_vals_main = loaded_data_main.get_optimal_and_default_vals('avg',
File "/home/vys0053/radar/readex-radar/mericVisualizer.py", line 1457, in get_optimal_and_default_vals
assert (isinstance(default_label_val_or_parent_reg, OptimalAndDefaultValsContainer))
AssertionError
Aborted (core dumped)
I had a bug in meric.opts (missing colon). The error when parsing invalid json is correct. However, there is no error handling in the radar. It should be RADAR that produces an error msg that json parsing failed and ends the application without any additional error messages.
In the code there is another issue, clearly visible from the error message - the json is being parsed for each region, instead of parsing the json just once.