Skip to content

Commit

Permalink
address code review
Browse files Browse the repository at this point in the history
  • Loading branch information
rjzamora committed Oct 6, 2021
1 parent 965c0aa commit 95d2e83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion python/cudf/cudf/tests/test_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def mock_size(*args):
# Since we are monkey-patching, we cannot use
# use_python_file_object=True, because the pyarrow
# `open_input_file` command will fail (since it doesn't
# use the monkey-pathced `open` definition)
# use the monkey-patched `open` definition)
got = cudf.read_csv("gcs://{}".format(fpath), use_python_file_object=False)
assert_eq(pdf, got)

Expand Down
22 changes: 6 additions & 16 deletions python/cudf/cudf/tests/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ def test_read_csv_arrow_nativefile(s3_base, s3so, pdf):


@pytest.mark.parametrize("bytes_per_thread", [32, 1024])
def test_read_csv_byte_range(s3_base, s3so, pdf, bytes_per_thread):
@pytest.mark.parametrize("use_python_file_object", [True, False])
def test_read_csv_byte_range(
s3_base, s3so, pdf, bytes_per_thread, use_python_file_object
):
# Write to buffer
fname = "test_csv_reader_byte_range.csv"
bname = "csv"
buffer = pdf.to_csv(index=False)
expect = pdf.iloc[-2:].reset_index(drop=True)

# Use fsspec file object
with s3_context(s3_base=s3_base, bucket=bname, files={fname: buffer}):
Expand All @@ -184,22 +186,10 @@ def test_read_csv_byte_range(s3_base, s3so, pdf, bytes_per_thread):
bytes_per_thread=bytes_per_thread,
header=None,
names=["Integer", "Float", "Integer2", "String", "Boolean"],
use_python_file_object=False,
use_python_file_object=use_python_file_object,
)
assert_eq(expect, got)

# Use Arrow PythonFile object
with s3_context(s3_base=s3_base, bucket=bname, files={fname: buffer}):
got = cudf.read_csv(
"s3://{}/{}".format(bname, fname),
storage_options=s3so,
byte_range=(74, 73),
bytes_per_thread=bytes_per_thread,
header=None,
names=["Integer", "Float", "Integer2", "String", "Boolean"],
use_python_file_object=True,
)
assert_eq(expect, got)
assert_eq(pdf.iloc[-2:].reset_index(drop=True), got)


@pytest.mark.parametrize("chunksize", [None, 3])
Expand Down

0 comments on commit 95d2e83

Please sign in to comment.