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

Hide traceback for epyccel and lambdify errors #1869

Merged
merged 8 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file.
- #1844 : Add line numbers and code to errors from built-in function calls.
- #1867 : Add a `use_out` parameter to `pyccel.lambdify` to avoid unnecessary memory allocation.
- #1867 : Auto-generate a docstring for functions generated via calls to `pyccel.lambdify`.
- #1868 : Hide traceback for `epyccel` and `lambdify` errors.
- \[INTERNALS\] Added `container_rank` property to `ast.datatypes.PyccelType` objects.
- \[DEVELOPER\] Added an improved traceback to the developer-mode errors for errors in function calls.

Expand Down
9 changes: 7 additions & 2 deletions pyccel/commands/epyccel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pyccel.utilities.strings import random_string
from pyccel.codegen.pipeline import execute_pyccel
from pyccel.errors.errors import ErrorsMode
from pyccel.errors.errors import ErrorsMode, PyccelError

__all__ = ['get_source_function', 'epyccel_seq', 'epyccel']

Expand Down Expand Up @@ -359,6 +359,8 @@ def epyccel( python_function_or_module, **kwargs ):
fun_name = python_function_or_module.__name__ if fun else None
success = True
# error handling carried out after broadcast to prevent deadlocks
except PyccelError as e:
raise type(e)(str(e)) from None
except BaseException as e: # pylint: disable=broad-except
exc_info = e
success = False
Expand Down Expand Up @@ -396,7 +398,10 @@ def epyccel( python_function_or_module, **kwargs ):

# Serial version
else:
mod, fun = epyccel_seq( python_function_or_module, **kwargs )
try:
mod, fun = epyccel_seq( python_function_or_module, **kwargs )
except PyccelError as e:
raise type(e)(str(e)) from None

# Return Fortran function (if any), otherwise module
return fun or mod
9 changes: 7 additions & 2 deletions pyccel/commands/lambdify.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import sympy as sp
from packaging import version

from pyccel.commands.epyccel import epyccel
from pyccel.commands.epyccel import epyccel
yguclu marked this conversation as resolved.
Show resolved Hide resolved
from pyccel.utilities.strings import random_string
from pyccel.errors.errors import PyccelError

if version.parse(sp.__version__) >= version.parse('1.8'):
from sympy.printing.numpy import NumPyPrinter
Expand Down Expand Up @@ -117,6 +118,10 @@ def lambdify(expr : sp.Expr, args : 'dict[sp.Symbol, str]', *, result_type : str
docstring += '\n """'

func = '\n'.join((numpy_import, decorators, signature, docstring, code))
package = epyccel(func, **kwargs)
try:
package = epyccel(func, **kwargs)
except PyccelError as e:
raise type(e)(str(e)) from None

return getattr(package, func_name)

Loading