From 3fce84d9af2fa2dfb9c1a629a1465bacc24d77c9 Mon Sep 17 00:00:00 2001 From: tanner-andrulis Date: Wed, 24 Apr 2024 10:40:01 -0400 Subject: [PATCH] Better error message for Timeloop fail --- timeloopfe/common/backend_calls.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/timeloopfe/common/backend_calls.py b/timeloopfe/common/backend_calls.py index c23ba30..521fbab 100644 --- a/timeloopfe/common/backend_calls.py +++ b/timeloopfe/common/backend_calls.py @@ -147,17 +147,23 @@ def _parse_output( """ """ if isinstance(result, subprocess.Popen): return result + + m = "model" if for_model else "mapper" + errmsg = ( + f"Timeloop {m} failed with return code {result}. Please check the output files " + f"in {output_dir} for more information. To debug, you can edit the file " + f"{os.path.join(output_dir, 'parsed-processed-input.yaml')} and run " + f"tl {m} {os.path.join(output_dir, 'parsed-processed-input.yaml')} to see the error." + ) + if result != 0: - m = "model" if for_model else "mapper" - raise RuntimeError( - f"Timeloop {m} failed with return code {result}. Please check the output files " - f"in {output_dir} for more information. To debug, you can edit the file " - f"{os.path.join(output_dir, 'parsed-processed-input.yaml')} and run " - f"tl {m} {os.path.join(output_dir, 'parsed-processed-input.yaml')} to see the error." + raise RuntimeError(errmsg) + try: + specification._parse_timeloop_output( + output_dir, prefix="timeloop-model" if for_model else "timeloop-mapper" ) - return specification._parse_timeloop_output( - output_dir, prefix="timeloop-model" if for_model else "timeloop-mapper" - ) + except Exception as e: + raise RuntimeError(f"{errmsg}") from e def call_mapper(