-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Error] Show pretty & intuitive stack traceback when ti.enable_excepthook() used #1405
[Error] Show pretty & intuitive stack traceback when ti.enable_excepthook() used #1405
Conversation
import taichi as ti
@ti.func
def func3():
ti.static_assert(1 + 1 == 3)
@ti.func
def func2():
func3()
@ti.func
def func1():
func2()
@ti.kernel
def func0():
func1()
ti.enable_excepthook()
func0() Before:
After:
and, with colors! |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'm not super familiar with the stack manipulation in Python, but the handler code LGTM.
Could you double check that my changes doesn't break your cool ODOP functions?
Thanks.. so long as ti.func
, ti.kernel
is not decorated with no_traceback
, and the tests passed, we should be fine?
print( | ||
f'In {Fore.LIGHTYELLOW_EX}{name}{Fore.RESET}() at {Fore.LIGHTMAGENTA_EX}{filename}{Fore.RESET}:{Fore.LIGHTCYAN_EX}{lineno}{Fore.RESET}:\n{bar}' | ||
) | ||
with open(filename) as f: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opt (maybe another PR, this one is not trivial already..): maybe we can cache the file content?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the ultimate solution is import inspect
..
Co-authored-by: Ye Kuang <k-ye@users.noreply.github.com>
Related issue = #
[Click here for the format server]
Didn't add
ti.init(excepthook=True)
yet to prevent conflict with #1396.@k-ye Could you double check that my changes doesn't break your cool ODOP functions? I didn't dear to use a decorator at all..