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

Introduce dedicated options for low memory readers #16289

Merged
merged 1 commit into from
Jul 16, 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
2 changes: 1 addition & 1 deletion python/cudf/cudf/_lib/json.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ cpdef read_json(object filepaths_or_buffers,
else:
raise TypeError("`dtype` must be 'list like' or 'dict'")

if cudf.get_option("mode.pandas_compatible") and lines:
if cudf.get_option("io.json.low_memory") and lines:
res_cols, res_col_names, res_child_names = plc.io.json.chunked_read_json(
plc.io.SourceInfo(filepaths_or_buffers),
processed_dtypes,
Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ def _read_parquet(
"cudf engine doesn't support the "
f"following positional arguments: {list(args)}"
)
if cudf.get_option("mode.pandas_compatible"):
if cudf.get_option("io.parquet.low_memory"):
return libparquet.ParquetReader(
filepaths_or_buffers,
columns=columns,
Expand Down
26 changes: 26 additions & 0 deletions python/cudf/cudf/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,32 @@ def _integer_and_none_validator(val):
_make_contains_validator([False, True]),
)

_register_option(
"io.parquet.low_memory",
False,
textwrap.dedent(
"""
If set to `False`, reads entire parquet in one go.
If set to `True`, reads parquet file in chunks.
\tValid values are True or False. Default is False.
"""
),
_make_contains_validator([False, True]),
)

_register_option(
"io.json.low_memory",
False,
textwrap.dedent(
"""
If set to `False`, reads entire json in one go.
If set to `True`, reads json file in chunks.
\tValid values are True or False. Default is False.
"""
),
_make_contains_validator([False, True]),
)


class option_context(ContextDecorator):
"""
Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,6 @@ def test_chunked_json_reader():
df.to_json(buf, lines=True, orient="records", engine="cudf")
buf.seek(0)
df = df.to_pandas()
with cudf.option_context("mode.pandas_compatible", True):
with cudf.option_context("io.json.low_memory", True):
gdf = cudf.read_json(buf, lines=True)
assert_eq(df, gdf)
2 changes: 1 addition & 1 deletion python/cudf/cudf/tests/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3772,6 +3772,6 @@ def test_parquet_reader_pandas_compatibility():
)
buffer = BytesIO()
df.to_parquet(buffer)
with cudf.option_context("mode.pandas_compatible", True):
with cudf.option_context("io.parquet.low_memory", True):
expected = cudf.read_parquet(buffer)
assert_eq(expected, df)
Loading