Skip to content

Commit

Permalink
add pandas debugging mode option
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt711 committed May 23, 2024
1 parent 9a0612b commit 6e5fcbf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
15 changes: 15 additions & 0 deletions python/cudf/cudf/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,21 @@ def _integer_and_none_validator(val):
_make_contains_validator([False, True]),
)

_register_option(
"mode.pandas_debugging",
False,
textwrap.dedent(
"""
If set to `False`, retains `cudf` specific behavior.
If set to `True`, enables pandas debugging mode,
which will raise a warning if the results from cudf
and pandas differ.
\tValid values are True or False. Default is False.
"""
),
_make_contains_validator([False, True]),
)


class option_context(ContextDecorator):
"""
Expand Down
13 changes: 13 additions & 0 deletions python/cudf/cudf/pandas/fast_slow_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Type,
)

from ..options import get_option
from .annotation import nvtx


Expand Down Expand Up @@ -898,6 +899,18 @@ def _fast_slow_function_call(func: Callable, /, *args, **kwargs) -> Any:
# try slow path
raise Exception()
fast = True

if get_option("mode.pandas_debugging"):
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():
result_slow = func(*slow_args, **slow_kwargs)
print(result_slow)
# TODO: Compare result and result slow and return a warning
except Exception:
with nvtx.annotate(
"EXECUTE_SLOW",
Expand Down
6 changes: 5 additions & 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 (
from cudf.pandas.fast_slow_proxy import ( # _fast_slow_function_call,
_fast_arg,
_FunctionProxy,
_slow_arg,
Expand Down Expand Up @@ -545,3 +545,7 @@ def test_tuple_with_attrs_transform():
assert b == bprime and b is not bprime
assert c == cprime and c is not cprime
assert d == dprime and d is not dprime


def test_fast_slow_function_call():
assert True

0 comments on commit 6e5fcbf

Please sign in to comment.