-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fix glob path in get_file_list #44
Conversation
Looks like the tests for older versions of Python are failing due to the way older versions of fsspec (2023.1.0 or below) handle globbing. Thoughts on bumping the fsspec dependency? |
"Thoughts on bumping the fsspec dependency?" do you mean dropping support for python less than 3.8 ? |
Hadn't considered that. I suppose requiring a newer version of fsspec would require Python>=3.8. |
@@ -42,7 +42,7 @@ def _get_file_list( | |||
path = make_path_absolute(path) | |||
fs, path_in_fs = fsspec.core.url_to_fs(path) | |||
prefix = path[: -len(path_in_fs)] | |||
glob_pattern = path.rstrip("/") + f"/**.{file_format}" | |||
glob_pattern = path.rstrip("/") + f"/**/*.{file_format}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works in both Python 3.7 and 3.8
glob_pattern = path.rstrip("/") + f"/**/*.{file_format}" | |
glob_pattern_root = path.rstrip("/") + f"/*.{file_format}" | |
glob_pattern_sub = path.rstrip("/") + f"/**/*.{file_format}" | |
file_path_root = fs.glob(glob_pattern_root) | |
file_path_sub = fs.glob(glob_pattern_sub) | |
file_paths = list(set(file_path_root + file_path_sub)) |
What do you think about the changes above? They support newer and older versions of fsspec without altering the behavior. |
sorry for the delay here let's drop support for 3.6 and 3.7 ; there are other reasons to do this anyway |
@rom1504 I think the issue people are having on auto-faiss it may be caused by the drop of support mentioned here. In fact I'm using Python 3.7.5. so I did something like if sys.version_info >= (3,8,0):
# LP: python > 3.8.x
glob_pattern = path.rstrip("/") + f"/**/*.{file_format}"
else:
# LP: python <= 3.7.x
glob_pattern = path.rstrip("/") + f"/**.{file_format}" in |
The 2023.12.0 release of fsspec introduced a change to the globbing of
**
. As a result,get_file_list
is broken:raises
This PR fixes this issue by changing
**.{file_format}
to**/*.{file_format}
, which should be backwards-compatible.