Skip to content
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

Improve error reporting for calling user-defined functions from the Python scope #521

Open
shi-eric opened this issue Feb 11, 2025 · 0 comments

Comments

@shi-eric
Copy link
Contributor

Calling a user-defined function from the Python scope that throws an exception gives an indecipherable error message:

import warp as wp


@wp.func
def bad_function(origin: wp.vec3):
    val = origin / 0
    return val


origin = wp.vec3()
result = bad_function(origin)
print(result)

Output:

  File "/home/eshi/code-projects/warp/warp/context.py", line 333, in __call__
    raise RuntimeError(f"Error calling function '{self.key}', no overload found for arguments {args}")
RuntimeError: Error calling function 'bad_function', no overload found for arguments (<warp.types.vec3f object at 0x74881af6f150>,)

Removing the wp.func decorator gives:

  File "/home/eshi/code-projects/warp/ershi-tests/ignored-user-function-errors/test_2.py", line 5, in bad_function
    val = origin / 0
          ~~~~~~~^~~
  File "/home/eshi/code-projects/warp/warp/types.py", line 253, in __truediv__
    return warp.div(self, y)
           ^^^^^^^^^^^^^^^^^
  File "/home/eshi/code-projects/warp/warp/context.py", line 307, in __call__
    raise RuntimeError(
RuntimeError: Couldn't find a function 'div' compatible with the arguments 'vec3f, int'

In these cases, we should give an error message more like the above.

This is due to the ignoring of exceptions here:

warp/warp/context.py

Lines 330 to 331 in 56a290b

except Exception:
continue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant