Skip to content

Commit

Permalink
Merge pull request #1 from gleize/gleize-traceback-exception-report
Browse files Browse the repository at this point in the history
Embed original traceback in Hydra's exception report.
  • Loading branch information
gleize authored Mar 1, 2024
2 parents 4db334b + 3b8ed34 commit 1004cad
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions hydra/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def run_job(
ret.return_value = task_function(task_cfg)
ret.status = JobStatus.COMPLETED
except Exception as e:
ret.return_value = e
ret.return_value = traceback.TracebackException(*sys.exc_info())
ret.status = JobStatus.FAILED

ret.task_name = JobRuntime.instance().get("name")
Expand Down Expand Up @@ -237,6 +237,14 @@ class JobStatus(Enum):
COMPLETED = 1
FAILED = 2

class JobException(Exception):
def __init__(self, traceback_exception: traceback.TracebackException) -> None:
super().__init__()
self.traceback_exception = traceback_exception

def __str__(self) -> str:
body = "".join(self.traceback_exception.format())
return f"JobException(\n{body})\n"

@dataclass
class JobReturn:
Expand All @@ -257,7 +265,7 @@ def return_value(self) -> Any:
sys.stderr.write(
f"Error executing job with overrides: {self.overrides}" + os.linesep
)
raise self._return_value
raise JobException(self._return_value)

@return_value.setter
def return_value(self, value: Any) -> None:
Expand Down

0 comments on commit 1004cad

Please sign in to comment.