diff --git a/python/cudf/cudf/pandas/fast_slow_proxy.py b/python/cudf/cudf/pandas/fast_slow_proxy.py index 0aec7527f98..328ace66699 100644 --- a/python/cudf/cudf/pandas/fast_slow_proxy.py +++ b/python/cudf/cudf/pandas/fast_slow_proxy.py @@ -904,24 +904,39 @@ def _fast_slow_function_call(func: Callable, /, *args, **kwargs) -> Any: fast = True if get_option("mode.pandas_debugging"): - with nvtx.annotate( - "EXECUTE_SLOW_DEBUGGING", - color=_CUDF_PANDAS_NVTX_COLORS["EXECUTE_SLOW"], - domain="cudf_pandas", - ): - slow_args, slow_kwargs = _slow_arg(args), _slow_arg(kwargs) - with disable_module_accelerator(): - slow_result = func(*slow_args, **slow_kwargs) + try: + with nvtx.annotate( + "EXECUTE_SLOW", + color=_CUDF_PANDAS_NVTX_COLORS["EXECUTE_SLOW"], + domain="cudf_pandas", + ): + slow_args, slow_kwargs = ( + _slow_arg(args), + _slow_arg(kwargs), + ) + with disable_module_accelerator(): + slow_result = func(*slow_args, **slow_kwargs) + except Exception as e: + warnings.warn( + "The result from pandas couyld not be computed correctly. " + f"The exception was {e}." + ) + else: + try: print("FAST ", result, type(result)) print("SLOW ", slow_result, type(slow_result)) if type(result).__name__ in _CUDF_OBJ_FINAL_TYPES: assert_eq(result, slow_result) - except AssertionError: - warnings.warn( - "The results from cudf and pandas were different. " - f"The types were {type(result)} and {type(slow_result)} for cudf and pandas, respectively." - ) - return _maybe_wrap_result(result, func, *args, **kwargs), fast + except AssertionError as ae: + warnings.warn( + "The results from cudf and pandas were different. " + f"The exception was {ae}." + ) + except Exception as e: + warnings.warn( + "Pandas debugging mode failed. " + f"The exception was {e}." + ) except Exception: with nvtx.annotate( "EXECUTE_SLOW", diff --git a/python/cudf/cudf_pandas_tests/test_fast_slow_proxy.py b/python/cudf/cudf_pandas_tests/test_fast_slow_proxy.py index 8bc95f92214..39bf07c49de 100644 --- a/python/cudf/cudf_pandas_tests/test_fast_slow_proxy.py +++ b/python/cudf/cudf_pandas_tests/test_fast_slow_proxy.py @@ -9,7 +9,7 @@ import numpy as np import pytest -from cudf.pandas.fast_slow_proxy import ( # _fast_slow_function_call, +from cudf.pandas.fast_slow_proxy import ( _fast_arg, _FunctionProxy, _slow_arg,