Skip to content

Commit

Permalink
Better error message for Timeloop fail
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner-andrulis committed Apr 24, 2024
1 parent d16f739 commit 4ec83f0
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions timeloopfe/common/backend_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
return 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(
Expand Down

0 comments on commit 4ec83f0

Please sign in to comment.