Skip to content
Snippets Groups Projects
Commit e38e2cf9 authored by Matthijs van der Wild's avatar Matthijs van der Wild
Browse files

Improved error handling

Former-commit-id: 82018ffe [formerly 436d0cca]
Former-commit-id: c2b5e634
Former-commit-id: 93f1fd05
parent a8a1cffb
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,7 @@ def main(check, control): ...@@ -20,6 +20,7 @@ def main(check, control):
control_path : str control_path : str
Path to control results directory Path to control results directory
""" """
error = False
#Check that all expected output files are present #Check that all expected output files are present
dcmp = dircmp(check, control) dcmp = dircmp(check, control)
...@@ -30,6 +31,7 @@ def main(check, control): ...@@ -30,6 +31,7 @@ def main(check, control):
if len(dcmp.right_only) > 0: if len(dcmp.right_only) > 0:
print('ERROR: The following files are present in the control but not in the ' print('ERROR: The following files are present in the control but not in the '
'output: {}'.format(dcmp.right_only)) 'output: {}'.format(dcmp.right_only))
error = True
check_path = check + '/cal_values/cal_solutions.h5' check_path = check + '/cal_values/cal_solutions.h5'
control_path = control + '/cal_values/cal_solutions.h5' control_path = control + '/cal_values/cal_solutions.h5'
...@@ -65,6 +67,7 @@ def main(check, control): ...@@ -65,6 +67,7 @@ def main(check, control):
axis=freq_axis_index) axis=freq_axis_index)
if not np.allclose(check_soltabval, matching_vals, if not np.allclose(check_soltabval, matching_vals,
rtol=1e-03, atol=1e-03, equal_nan=True): rtol=1e-03, atol=1e-03, equal_nan=True):
error = True
print("Val array of soltab {} does not match the control".format(soltabname)) print("Val array of soltab {} does not match the control".format(soltabname))
with open("check_soltab.{}.val".format(soltabname), "w") as f: with open("check_soltab.{}.val".format(soltabname), "w") as f:
f.write(str(check_soltabval[:])) f.write(str(check_soltabval[:]))
...@@ -74,7 +77,7 @@ def main(check, control): ...@@ -74,7 +77,7 @@ def main(check, control):
print("Val array of soltab {} matches the control".format(soltabname)) print("Val array of soltab {} matches the control".format(soltabname))
check_h5.close() check_h5.close()
control_h5.close() control_h5.close()
sys.exit(0) sys.exit(error)
if __name__ == '__main__': if __name__ == '__main__':
descriptiontext = "Checks the output of a workflow run.\n" descriptiontext = "Checks the output of a workflow run.\n"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment