From 5c2fac83b74fdf82720e503ccc91461ed388dc5d Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 7 Oct 2024 17:22:01 -0700 Subject: [PATCH] Add wrappers.durations/timestamps namespace to pylibcudf --- python/cudf/cudf/_lib/scalar.pyx | 4 ++-- python/pylibcudf/pylibcudf/CMakeLists.txt | 1 + python/pylibcudf/pylibcudf/__init__.pxd | 2 ++ .../pylibcudf/libcudf/wrappers/durations.pxd | 7 ++++-- .../pylibcudf/libcudf/wrappers/timestamps.pxd | 7 ++++-- .../pylibcudf/wrappers/CMakeLists.txt | 22 +++++++++++++++++++ .../pylibcudf/pylibcudf/wrappers/__init__.pxd | 3 +++ .../pylibcudf/pylibcudf/wrappers/__init__.py | 1 + .../pylibcudf/wrappers/durations.pxd | 11 ++++++++++ .../pylibcudf/wrappers/timestamps.pxd | 11 ++++++++++ 10 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 python/pylibcudf/pylibcudf/wrappers/CMakeLists.txt create mode 100644 python/pylibcudf/pylibcudf/wrappers/__init__.pxd create mode 100644 python/pylibcudf/pylibcudf/wrappers/__init__.py create mode 100644 python/pylibcudf/pylibcudf/wrappers/durations.pxd create mode 100644 python/pylibcudf/pylibcudf/wrappers/timestamps.pxd diff --git a/python/cudf/cudf/_lib/scalar.pyx b/python/cudf/cudf/_lib/scalar.pyx index 0dde91316fb..bda97dfa019 100644 --- a/python/cudf/cudf/_lib/scalar.pyx +++ b/python/cudf/cudf/_lib/scalar.pyx @@ -32,13 +32,13 @@ from pylibcudf.libcudf.scalar.scalar cimport ( struct_scalar, timestamp_scalar, ) -from pylibcudf.libcudf.wrappers.durations cimport ( +from pylibcudf.wrappers.durations cimport ( duration_ms, duration_ns, duration_s, duration_us, ) -from pylibcudf.libcudf.wrappers.timestamps cimport ( +from pylibcudf.wrappers.timestamps cimport ( timestamp_ms, timestamp_ns, timestamp_s, diff --git a/python/pylibcudf/pylibcudf/CMakeLists.txt b/python/pylibcudf/pylibcudf/CMakeLists.txt index 1d72eacac12..925a423424e 100644 --- a/python/pylibcudf/pylibcudf/CMakeLists.txt +++ b/python/pylibcudf/pylibcudf/CMakeLists.txt @@ -67,3 +67,4 @@ add_subdirectory(libcudf) add_subdirectory(strings) add_subdirectory(io) add_subdirectory(nvtext) +add_subdirectory(wrappers) diff --git a/python/pylibcudf/pylibcudf/__init__.pxd b/python/pylibcudf/pylibcudf/__init__.pxd index b98b37fe0fd..0440cee7ead 100644 --- a/python/pylibcudf/pylibcudf/__init__.pxd +++ b/python/pylibcudf/pylibcudf/__init__.pxd @@ -34,6 +34,7 @@ from . cimport ( transpose, types, unary, + wrappers, ) from .column cimport Column from .gpumemoryview cimport gpumemoryview @@ -79,5 +80,6 @@ __all__ = [ "transpose", "types", "unary", + "wrappers", "nvtext", ] diff --git a/python/pylibcudf/pylibcudf/libcudf/wrappers/durations.pxd b/python/pylibcudf/pylibcudf/libcudf/wrappers/durations.pxd index 7c648425eb5..a2d3c74adb8 100644 --- a/python/pylibcudf/pylibcudf/libcudf/wrappers/durations.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/wrappers/durations.pxd @@ -1,9 +1,12 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. -from libc.stdint cimport int64_t +from libc.stdint cimport int32_t, int64_t cdef extern from "cudf/wrappers/durations.hpp" namespace "cudf" nogil: + ctypedef int32_t duration_D + ctypedef int32_t duration_h + ctypedef int32_t duration_m ctypedef int64_t duration_s ctypedef int64_t duration_ms ctypedef int64_t duration_us diff --git a/python/pylibcudf/pylibcudf/libcudf/wrappers/timestamps.pxd b/python/pylibcudf/pylibcudf/libcudf/wrappers/timestamps.pxd index 50d37fd0a68..a1c108da800 100644 --- a/python/pylibcudf/pylibcudf/libcudf/wrappers/timestamps.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/wrappers/timestamps.pxd @@ -1,9 +1,12 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. -from libc.stdint cimport int64_t +from libc.stdint cimport int32_t, int64_t cdef extern from "cudf/wrappers/timestamps.hpp" namespace "cudf" nogil: + ctypedef int32_t timestamp_D + ctypedef int32_t timestamp_h + ctypedef int32_t timestamp_m ctypedef int64_t timestamp_s ctypedef int64_t timestamp_ms ctypedef int64_t timestamp_us diff --git a/python/pylibcudf/pylibcudf/wrappers/CMakeLists.txt b/python/pylibcudf/pylibcudf/wrappers/CMakeLists.txt new file mode 100644 index 00000000000..f9818dd99f4 --- /dev/null +++ b/python/pylibcudf/pylibcudf/wrappers/CMakeLists.txt @@ -0,0 +1,22 @@ +# ============================================================================= +# Copyright (c) 2024, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources) + +set(linked_libraries cudf::cudf) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX pylibcudf_wrappers_ ASSOCIATED_TARGETS cudf +) diff --git a/python/pylibcudf/pylibcudf/wrappers/__init__.pxd b/python/pylibcudf/pylibcudf/wrappers/__init__.pxd new file mode 100644 index 00000000000..617231b54ab --- /dev/null +++ b/python/pylibcudf/pylibcudf/wrappers/__init__.pxd @@ -0,0 +1,3 @@ +# Copyright (c) 2024, NVIDIA CORPORATION. + +from . cimport timestamps diff --git a/python/pylibcudf/pylibcudf/wrappers/__init__.py b/python/pylibcudf/pylibcudf/wrappers/__init__.py new file mode 100644 index 00000000000..3c827d4ff59 --- /dev/null +++ b/python/pylibcudf/pylibcudf/wrappers/__init__.py @@ -0,0 +1 @@ +# Copyright (c) 2024, NVIDIA CORPORATION. diff --git a/python/pylibcudf/pylibcudf/wrappers/durations.pxd b/python/pylibcudf/pylibcudf/wrappers/durations.pxd new file mode 100644 index 00000000000..6178350fb3e --- /dev/null +++ b/python/pylibcudf/pylibcudf/wrappers/durations.pxd @@ -0,0 +1,11 @@ +# Copyright (c) 2024, NVIDIA CORPORATION. + +from pylibcudf.libcudf.wrappers.durations cimport ( + duration_D, + duration_h, + duration_m, + duration_ms, + duration_ns, + duration_s, + duration_us, +) diff --git a/python/pylibcudf/pylibcudf/wrappers/timestamps.pxd b/python/pylibcudf/pylibcudf/wrappers/timestamps.pxd new file mode 100644 index 00000000000..07e7ab68803 --- /dev/null +++ b/python/pylibcudf/pylibcudf/wrappers/timestamps.pxd @@ -0,0 +1,11 @@ +# Copyright (c) 2024, NVIDIA CORPORATION. + +from pylibcudf.libcudf.wrappers.timestamps cimport ( + timestamp_D, + timestamp_h, + timestamp_m, + timestamp_ms, + timestamp_ns, + timestamp_s, + timestamp_us, +)