rom1504 / embedding-reader

Efficiently read embedding in streaming from any filesystem
MIT License
92 stars 19 forks source link

Fix glob path in get_file_list #44

Closed bencwallace closed 7 months ago

bencwallace commented 8 months ago

The 2023.12.0 release of fsspec introduced a change to the globbing of **. As a result, get_file_list is broken:

from embedding_reader.get_file_list import get_file_list
get_file_list(".", "py")

raises

ValueError: Invalid pattern: '**' can only be an entire path component

This PR fixes this issue by changing **.{file_format} to **/*.{file_format}, which should be backwards-compatible.

bencwallace commented 8 months ago

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?

rom1504 commented 8 months ago

"Thoughts on bumping the fsspec dependency?" do you mean dropping support for python less than 3.8 ?

bencwallace commented 8 months ago

Hadn't considered that. I suppose requiring a newer version of fsspec would require Python>=3.8. Instead, I should be able to fix the errors in older versions (without compromising newer versions using the latest fsspec release) by merging the results of globbing *.{file_format} and **/*.{file_format}.

bencwallace commented 8 months ago

What do you think about the changes above? They support newer and older versions of fsspec without altering the behavior.

rom1504 commented 7 months ago

sorry for the delay here

let's drop support for 3.6 and 3.7 ; there are other reasons to do this anyway

loretoparisi commented 5 months ago

@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 get_file_list._get_file_list to make it working back, beucase unfortunately I cannot upgrade the python version in the short term.