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 os.path.relpath in resolve_patterns #6815

Merged
merged 2 commits into from
Apr 16, 2024
Merged
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
12 changes: 3 additions & 9 deletions src/datasets/data_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,7 @@ def resolve_pattern(
else:
base_path = ""
pattern, storage_options = _prepare_path_and_storage_options(pattern, download_config=download_config)
fs, *_ = url_to_fs(pattern, **storage_options)
fs_base_path = base_path.split("::")[0].split("://")[-1] or fs.root_marker
fs_pattern = pattern.split("::")[0].split("://")[-1]
fs, fs_pattern = url_to_fs(pattern, **storage_options)
files_to_ignore = set(FILES_TO_IGNORE) - {xbasename(pattern)}
protocol = fs.protocol if isinstance(fs.protocol, str) else fs.protocol[0]
protocol_prefix = protocol + "://" if protocol != "file" else ""
Expand All @@ -387,12 +385,8 @@ def resolve_pattern(
for filepath, info in fs.glob(pattern, detail=True, **glob_kwargs).items()
if info["type"] == "file"
and (xbasename(filepath) not in files_to_ignore)
and not _is_inside_unrequested_special_dir(
os.path.relpath(filepath, fs_base_path), os.path.relpath(fs_pattern, fs_base_path)
)
and not _is_unrequested_hidden_file_or_is_inside_unrequested_hidden_dir(
os.path.relpath(filepath, fs_base_path), os.path.relpath(fs_pattern, fs_base_path)
)
and not _is_inside_unrequested_special_dir(filepath, fs_pattern)
and not _is_unrequested_hidden_file_or_is_inside_unrequested_hidden_dir(filepath, fs_pattern)
] # ignore .ipynb and __pycache__, but keep /../
if allowed_extensions is not None:
out = [
Expand Down
Loading