Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cudf._lib.text in favor of inlining pylibcudf #17408

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion python/cudf/cudf/_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ set(cython_sources
stream_compaction.pyx
string_casting.pyx
strings_udf.pyx
text.pyx
transform.pyx
types.pyx
utils.pyx
Expand Down
1 change: 0 additions & 1 deletion python/cudf/cudf/_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
string_casting,
strings,
strings_udf,
text,
)

MAX_COLUMN_SIZE = np.iinfo(np.int32).max
Expand Down
53 changes: 0 additions & 53 deletions python/cudf/cudf/_lib/text.pyx

This file was deleted.

45 changes: 34 additions & 11 deletions python/cudf/cudf/io/text.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Copyright (c) 2018-2024, NVIDIA CORPORATION.

from io import BytesIO, StringIO
from io import BytesIO, StringIO, TextIOBase

import pylibcudf as plc

import cudf
from cudf._lib import text as libtext
from cudf.utils import ioutils
from cudf.utils.performance_tracking import _performance_tracking

Expand Down Expand Up @@ -33,13 +34,35 @@ def read_text(
filepath_or_buffer, "read_text"
)

return cudf.Series._from_column(
libtext.read_text(
filepath_or_buffer,
delimiter=delimiter,
byte_range=byte_range,
strip_delimiters=strip_delimiters,
compression=compression,
compression_offsets=compression_offsets,
)
if compression is None:
if isinstance(filepath_or_buffer, TextIOBase):
datasource = plc.io.text.make_source(filepath_or_buffer.read())
else:
datasource = plc.io.text.make_source_from_file(filepath_or_buffer)
elif compression == "bgzip":
if isinstance(filepath_or_buffer, TextIOBase):
raise ValueError("bgzip compression requires a file path")
if compression_offsets is not None:
if len(compression_offsets) != 2:
raise ValueError(
"Compression offsets need to consist of two elements"
)
datasource = plc.io.text.make_source_from_bgzip_file(
filepath_or_buffer,
compression_offsets[0],
compression_offsets[1],
)
else:
datasource = plc.io.text.make_source_from_bgzip_file(
filepath_or_buffer,
)
else:
raise ValueError("Only bgzip compression is supported at the moment")

options = plc.io.text.ParseOptions(
byte_range=byte_range, strip_delimiters=strip_delimiters
)
plc_column = plc.io.text.multibyte_split(datasource, delimiter, options)
result = cudf._lib.column.Column.from_pylibcudf(plc_column)

return cudf.Series._from_column(result)
Loading