Skip to content

Commit

Permalink
Add warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt711 committed May 24, 2024
1 parent 8228359 commit a24d271
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
43 changes: 29 additions & 14 deletions python/cudf/cudf/pandas/fast_slow_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf_pandas_tests/test_fast_slow_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a24d271

Please sign in to comment.