|
7 | 7 | import pathlib |
8 | 8 | import re |
9 | 9 | import sys |
| 10 | +import traceback |
10 | 11 | from typing import cast |
11 | 12 | from typing import Dict |
12 | 13 | from typing import List |
|
18 | 19 | from vdk.internal.builtin_plugins.run import job_input_error_classifier |
19 | 20 | from vdk.internal.builtin_plugins.run.data_job import DataJobFactory |
20 | 21 | from vdk.internal.builtin_plugins.run.execution_results import ExecutionResult |
| 22 | +from vdk.internal.builtin_plugins.run.execution_results import StepResult |
21 | 23 | from vdk.internal.builtin_plugins.run.execution_tracking import ( |
22 | 24 | ExecutionTrackingPlugin, |
23 | 25 | ) |
@@ -143,15 +145,40 @@ def __log_exec_result(self, execution_result: ExecutionResult) -> None: |
143 | 145 | log.info(f"Data Job execution summary: {execution_result}") |
144 | 146 |
|
145 | 147 | @staticmethod |
146 | | - def __log_short_exec_result(execution_result): |
| 148 | + def __log_short_exec_result(execution_result: ExecutionResult): |
| 149 | + def extract_relevant_lines(step: StepResult) -> List[str]: |
| 150 | + out = [] |
| 151 | + if step.exception: |
| 152 | + call_list = traceback.format_tb(step.exception.__traceback__) |
| 153 | + |
| 154 | + for line_index, line in enumerate(call_list): |
| 155 | + # Check if the step name is in the line |
| 156 | + if step.name in line: |
| 157 | + out.append(line) |
| 158 | + next_line_index = line_index + 1 |
| 159 | + # Pull in subsequent relevant lines |
| 160 | + # that do not come from another file |
| 161 | + while next_line_index < len(call_list) and not re.match( |
| 162 | + r'^\s*File "', call_list[next_line_index] |
| 163 | + ): |
| 164 | + out.append(call_list[next_line_index]) |
| 165 | + next_line_index += 1 |
| 166 | + # add the exception type and message |
| 167 | + out.append(f"{type(step.exception).__name__}: {str(step.exception)}") |
| 168 | + return out |
| 169 | + |
147 | 170 | log.info( |
148 | 171 | "Job execution result: " |
149 | 172 | + execution_result.status.upper() |
150 | 173 | + "\n" |
151 | | - + "Steps list:\n" |
| 174 | + + "Step results:\n" |
152 | 175 | + "".join( |
153 | 176 | [ |
154 | | - step.name + " - " + step.status.upper() + "\n" |
| 177 | + step.name |
| 178 | + + " - " |
| 179 | + + step.status.upper() |
| 180 | + + "\n" |
| 181 | + + "".join(extract_relevant_lines(step)) |
155 | 182 | for step in execution_result.steps_list |
156 | 183 | ] |
157 | 184 | ) |
|
0 commit comments