-
Notifications
You must be signed in to change notification settings - Fork 308
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
Integrate fsspec
to enable accessing WFDB files from cloud URIs
#523
base: main
Are you sure you want to change the base?
Conversation
@bemoody , could you suggest how to install |
@bemoody , I've updated this per our discussion:
|
I think the general idea makes sense: allow record_name to be either a (partial) path or a URL. In determining whether something is a URL, we should require it to begin with This code currently doesn't work because in line 1835 you are opening the file in binary mode ( (Note that, completely independent of this pull request, the use of |
Thanks @bemoody !
Makes sense, I've updated this.
Strange, I had already made this change on my local copy but it didn't make it to the remote. |
@bemoody , I'll continue with this PR by updating the following in a similar manner:
Do you think we should also integrate wfdb-python/wfdb/io/_signal.py Line 2511 in e5c6fe5
wfdb-python/wfdb/io/_signal.py Line 1925 in e5c6fe5
Please let me know if there are other areas where I should be integrating |
Currently, to read a signal file, we open it using open(filename, "rb"), right? And then the resulting file object is passed to the SoundFile constructor. Hopefully the same should work using an fsspec file object.
Yes, that would be ideal, but as a separate pull request. I haven't tried, but I assume you can use "w"/"wb" mode with fsspec.open if you have appropriate credentials to write to the specified location. |
As mentioned in #517, we want to be able to read WFDB files from within cloud environments using WFDB-Python. This PR enables using the
fsspec
library ( https://filesystem-spec.readthedocs.io/en/latest/ ) to read WFDB files from cloud URIs. It replaces the standard Pythonopen
withfsspec.open
. Also, it adds logic to differentiate between loading a file from a cloud URI or from a PhysioNet Database.In the initial commit, access has only been added for
rdheader
. We can expand this across all relevant WFDB functions once the approach has been agreed upon.I've tested this with a local
.hea
file, a file read from a PhysioNet Database (usingpn_dir
), and a file from a Datastore in the Azure AI / ML Studio.