Skip to content

Commit

Permalink
fail on fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt711 committed Sep 10, 2024
1 parent a57facb commit c0ba1e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
13 changes: 9 additions & 4 deletions python/cudf/cudf/pandas/fast_slow_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,12 @@ def _assert_fast_slow_eq(left, right):
assert_eq(left, right)


class CudfFallbackError(Exception):
"""Raised when fallback occurs"""

pass


def _fast_slow_function_call(
func: Callable,
/,
Expand Down Expand Up @@ -942,10 +948,9 @@ def _fast_slow_function_call(
f"The exception was {e}."
)
except Exception as err:
if _env_get_bool("CUDF_PANDAS_WARN_ON_FALLBACK", False):
warnings.warn(
"Falling back to the slow path. " f"The exception was {err}.",
UserWarning,
if _env_get_bool("CUDF_PANDAS_FAIL_ON_FALLBACK", False):
raise CudfFallbackError(
f"The operation failed with cuDF, the reason was {type(err)}: {err}."
)
with nvtx.annotate(
"EXECUTE_SLOW",
Expand Down
11 changes: 3 additions & 8 deletions python/cudf/cudf_pandas_tests/test_cudf_pandas_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@


@pytest.fixture(autouse=True)
def warn_on_fallback(monkeypatch):
monkeypatch.setenv("CUDF_PANDAS_WARN_ON_FALLBACK", "True")
def fail_on_fallback(monkeypatch):
monkeypatch.setenv("CUDF_PANDAS_FAIL_ON_FALLBACK", "True")


@pytest.fixture
Expand All @@ -33,9 +33,6 @@ def series(dataframe):
return (pdf["a"], df["a"])


@pytest.mark.filterwarnings(
"error::UserWarning:.*Falling back to the slow path.*"
)
@pytest.mark.parametrize(
"op",
[
Expand All @@ -56,9 +53,7 @@ def test_no_fallback_in_reduction_ops(series, op):
tm.assert_almost_equal(res, expect)


@pytest.mark.filterwarnings(
"error::UserWarning:.*Falling back to the slow path.*"
)
@pytest.mark.xfail(strict=True, reason="Fallback expected")
@pytest.mark.parametrize(
"op",
[
Expand Down

0 comments on commit c0ba1e0

Please sign in to comment.