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

Update io util to convert path like object to string #8275

Merged
merged 2 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions python/cudf/cudf/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from uuid import uuid4

from fsspec.core import get_fs_token_paths
from fsspec.utils import stringify_path
from pyarrow import dataset as ds, parquet as pq

import cudf
Expand Down Expand Up @@ -203,7 +202,11 @@ def read_parquet(
for source in filepath_or_buffer:
if ioutils.is_directory(source, **kwargs):
fs = _ensure_filesystem(passed_filesystem=None, path=source)
source = stringify_path(source)
source = (
source.__fspath__()
if hasattr(source, "__fspath__")
else source
ayushdg marked this conversation as resolved.
Show resolved Hide resolved
)
source = fs.sep.join([source, "*.parquet"])

tmp_source, compression = ioutils.get_filepath_or_buffer(
Expand Down
18 changes: 15 additions & 3 deletions python/cudf/cudf/utils/ioutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,11 @@ def _is_local_filesystem(fs):
def ensure_single_filepath_or_buffer(path_or_data, **kwargs):
"""Return False if `path_or_data` resolves to multiple filepaths or buffers
"""
path_or_data = fsspec.utils.stringify_path(path_or_data)
path_or_data = (
path_or_data.__fspath__()
if hasattr(path_or_data, "__fspath__")
else path_or_data
)
if isinstance(path_or_data, str):
storage_options = kwargs.get("storage_options")
path_or_data = os.path.expanduser(path_or_data)
Expand All @@ -1076,7 +1080,11 @@ def ensure_single_filepath_or_buffer(path_or_data, **kwargs):
def is_directory(path_or_data, **kwargs):
"""Returns True if the provided filepath is a directory
"""
path_or_data = fsspec.utils.stringify_path(path_or_data)
path_or_data = (
path_or_data.__fspath__()
if hasattr(path_or_data, "__fspath__")
else path_or_data
)
if isinstance(path_or_data, str):
storage_options = kwargs.get("storage_options")
path_or_data = os.path.expanduser(path_or_data)
Expand Down Expand Up @@ -1121,7 +1129,11 @@ def get_filepath_or_buffer(
compression : str
Type of compression algorithm for the content
"""
path_or_data = fsspec.utils.stringify_path(path_or_data)
path_or_data = (
path_or_data.__fspath__()
if hasattr(path_or_data, "__fspath__")
else path_or_data
)

if isinstance(path_or_data, str):
storage_options = kwargs.get("storage_options")
Expand Down