From fa6e3bae752150e5537d0d980774073c02a24f62 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 14 Jan 2025 02:18:10 +0000 Subject: [PATCH] Deprecate protocol and update tests accordingly --- python/cudf/cudf/core/dataframe.py | 9 +++++++++ python/cudf/cudf/tests/test_df_protocol.py | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/dataframe.py b/python/cudf/cudf/core/dataframe.py index 5cea35ac0d6..1bddf8f4553 100644 --- a/python/cudf/cudf/core/dataframe.py +++ b/python/cudf/cudf/core/dataframe.py @@ -27,6 +27,7 @@ import pandas as pd import pyarrow as pa from nvtx import annotate +from packaging import version from pandas.io.formats import console from pandas.io.formats.printing import pprint_thing from typing_extensions import Self, assert_never @@ -5562,6 +5563,12 @@ def from_pandas(cls, dataframe, nan_as_null=no_default): elif hasattr(dataframe, "__dataframe__"): # TODO: Probably should be handled in the constructor as # this isn't pandas specific + assert version.parse(cudf.__version__) < version.parse("25.04.00") + warnings.warn( + "Support for loading dataframes via the `__dataframe__` interchange " + "protocol is deprecated", + FutureWarning, + ) return from_dataframe(dataframe, allow_copy=True) else: raise TypeError( @@ -7709,6 +7716,8 @@ def pct_change( def __dataframe__( self, nan_as_null: bool = False, allow_copy: bool = True ): + assert version.parse(cudf.__version__) < version.parse("25.04.00") + warnings.warn("Using `__dataframe__` is deprecated", FutureWarning) return df_protocol.__dataframe__( self, nan_as_null=nan_as_null, allow_copy=allow_copy ) diff --git a/python/cudf/cudf/tests/test_df_protocol.py b/python/cudf/cudf/tests/test_df_protocol.py index 44270d20d59..371db773805 100644 --- a/python/cudf/cudf/tests/test_df_protocol.py +++ b/python/cudf/cudf/tests/test_df_protocol.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024, NVIDIA CORPORATION. +# Copyright (c) 2021-2025, NVIDIA CORPORATION. from __future__ import annotations from typing import Any @@ -22,6 +22,10 @@ ) from cudf.testing import assert_eq +pytestmark = pytest.mark.filterwarnings( + "ignore:Using `__dataframe__` is deprecated:FutureWarning" +) + @pytest.fixture( params=[