From e51831383484d25551634ebe3c0f07b5a56f25c5 Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Wed, 11 Dec 2024 11:21:39 -0500 Subject: [PATCH 1/3] version check in to_cudf for API change fixes #3335 --- src/awkward/contents/listoffsetarray.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/awkward/contents/listoffsetarray.py b/src/awkward/contents/listoffsetarray.py index 030d35a344..37615f555a 100644 --- a/src/awkward/contents/listoffsetarray.py +++ b/src/awkward/contents/listoffsetarray.py @@ -2009,12 +2009,19 @@ def _to_arrow( ) def _to_cudf(self, cudf: Any, mask: Content | None, length: int): + from packaging.version import parse as parse_version cupy = Cupy.instance() index = self._offsets.raw(cupy).astype("int32") buf = cudf.core.buffer.as_buffer(index) - ind_buf = cudf.core.column.numerical.NumericalColumn( - data=buf, dtype=index.dtype, mask=None, size=len(index) - ) + + if parse_version(cupy._version.__version__) >= parse_version("24.10.00"): + ind_buf = cudf.core.column.numerical.NumericalColumn( + data=buf, dtype=index.dtype, mask=None, size=len(index) + ) + else: + ind_buf = cudf.core.column.numerical.NumericalColumn( + buf, index.dtype, None, size=len(index) + ) cont = self._content._to_cudf(cudf, None, len(self._content)) if mask is not None: m = np._module.packbits(mask, bitorder="little") From e70a97c5b49d3fd72afad13d6a99737aa23dbdab Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:22:52 +0000 Subject: [PATCH 2/3] style: pre-commit fixes --- src/awkward/contents/listoffsetarray.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/awkward/contents/listoffsetarray.py b/src/awkward/contents/listoffsetarray.py index 37615f555a..630406a8e1 100644 --- a/src/awkward/contents/listoffsetarray.py +++ b/src/awkward/contents/listoffsetarray.py @@ -2010,6 +2010,7 @@ def _to_arrow( def _to_cudf(self, cudf: Any, mask: Content | None, length: int): from packaging.version import parse as parse_version + cupy = Cupy.instance() index = self._offsets.raw(cupy).astype("int32") buf = cudf.core.buffer.as_buffer(index) From c43f364fa3f18f1496fd746eb9d9200c6944e8c1 Mon Sep 17 00:00:00 2001 From: mdurant Date: Thu, 12 Dec 2024 14:28:02 -0500 Subject: [PATCH 3/3] Fix --- src/awkward/contents/listoffsetarray.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/awkward/contents/listoffsetarray.py b/src/awkward/contents/listoffsetarray.py index 630406a8e1..f261717b87 100644 --- a/src/awkward/contents/listoffsetarray.py +++ b/src/awkward/contents/listoffsetarray.py @@ -2015,7 +2015,7 @@ def _to_cudf(self, cudf: Any, mask: Content | None, length: int): index = self._offsets.raw(cupy).astype("int32") buf = cudf.core.buffer.as_buffer(index) - if parse_version(cupy._version.__version__) >= parse_version("24.10.00"): + if parse_version(cudf.__version__) >= parse_version("24.10.00"): ind_buf = cudf.core.column.numerical.NumericalColumn( data=buf, dtype=index.dtype, mask=None, size=len(index) ) @@ -2042,13 +2042,21 @@ def _to_cudf(self, cudf: Any, mask: Content | None, length: int): mask=m, ) - return cudf.core.column.lists.ListColumn( - size=length, - data=None, - mask=m, - children=(ind_buf, cont), - dtype=cudf.core.dtypes.ListDtype(cont.dtype), - ) + if parse_version(cudf.__version__) >= parse_version("24.10.00"): + return cudf.core.column.lists.ListColumn( + size=length, + data=None, + mask=m, + children=(ind_buf, cont), + dtype=cudf.core.dtypes.ListDtype(cont.dtype), + ) + else: + return cudf.core.column.lists.ListColumn( + length, + mask=m, + children=(ind_buf, cont), + dtype=cudf.core.dtypes.ListDtype(cont.dtype), + ) def _to_backend_array(self, allow_missing, backend): array_param = self.parameter("__array__")