Skip to content

Commit

Permalink
add except hook override to write traceback to file
Browse files Browse the repository at this point in the history
Signed-off-by: Ayush Kamat <[email protected]>
  • Loading branch information
ayushkamat committed Feb 10, 2025
1 parent 51700b4 commit be25d44
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/latch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
Latch platform.
"""

import os
import sys
import traceback
from pathlib import Path

from latch.functions.messages import message
from latch.functions.operators import (
combine,
Expand All @@ -20,17 +25,30 @@
from latch.resources.tasks import (
custom_memory_optimized_task,
custom_task,
g6e_xlarge_task,
g6e_2xlarge_task,
g6e_4xlarge_task,
g6e_8xlarge_task,
g6e_12xlarge_task,
g6e_16xlarge_task,
g6e_24xlarge_task,
g6e_xlarge_task,
large_gpu_task,
large_task,
medium_task,
small_gpu_task,
small_task,
)
from latch.resources.workflow import workflow


def _except_hook(type, value, tb):
traceback_path = Path(os.environ.get("latch_traceback_path", "~/traceback.txt"))
traceback_path.parent.mkdir(exist_ok=True)

with traceback_path.open("w") as f:
traceback.print_tb(tb, file=f)

return sys.__excepthook__(type, value, tb)


sys.excepthook = _except_hook

0 comments on commit be25d44

Please sign in to comment.