remote read of NWB files using MATLAB #59
-
It is supposed to be possible to do a remote read of s3 hdf5 files in MATLAB, but when I try to get this: >> H5F.open('https://dandiarchive.s3.amazonaws.com/blobs/58c/537/58c53789-eec4-4080-ad3b-207cf2a1cac9')
Error using hdf5lib2
Unable to access
'https://dandiarchive.s3.amazonaws.com/blobs/58c/537/58c53789-eec4-4080-ad3b-207cf2a1cac9'.
The specified URL scheme is invalid. I am guessing that "The specified URL scheme is invalid." is referring to the fact that the url does not start with "s3://". Why doesn't it? Do we have an alternative url that fits this pattern? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 19 replies
-
this is because the you can replace: here is a bit of code: s3loc = [val for val in contenturl if ".s3.amazonaws" in val]
assert len(s3loc) == 1
bucket = s3loc[0].split("//")[1].split(".s3.amazonaws")[0] |
Beta Was this translation helpful? Give feedback.
-
The solution involved 2 fixes. First to use this url: s3_url = "s3://dandiarchive/blobs/e08/02c/e0802c3e-5492-42a6-960a-bcf5b3cfd239" Second, to fix a credentials issue, @nvishnoiMW proposed in another thread to delete stale credentials by deleting the file |
Beta Was this translation helpful? Give feedback.
-
@satra could you help me figure out what's going on here? from h5py import File
s3_url = "https://dandiarchive.s3.amazonaws.com/blobs/58c/537/58c53789-eec4-4080-ad3b-207cf2a1cac9"
file = File(s3_url, mode = "r", driver="ros3")
file.attrs['nwb_version']
bucket = s3_url.replace("https://dandiarchive.s3.amazonaws.com", "s3://dandiarchive")
print(bucket)
file = File(bucket, mode = "r", driver="ros3") ---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Input In [28], in <module>
9 bucket = s3_url.replace("https://dandiarchive.s3.amazonaws.com/", "s3://dandiarchive")
10 print(bucket)
---> 11 file = File(bucket, mode = "r", driver="ros3")
File /opt/conda/lib/python3.9/site-packages/h5py/_hl/files.py:507, in File.__init__(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, fs_strategy, fs_persist, fs_threshold, fs_page_size, page_buf_size, min_meta_keep, min_raw_keep, locking, **kwds)
502 fapl = make_fapl(driver, libver, rdcc_nslots, rdcc_nbytes, rdcc_w0,
503 locking, page_buf_size, min_meta_keep, min_raw_keep, **kwds)
504 fcpl = make_fcpl(track_order=track_order, fs_strategy=fs_strategy,
505 fs_persist=fs_persist, fs_threshold=fs_threshold,
506 fs_page_size=fs_page_size)
--> 507 fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
509 if isinstance(libver, tuple):
510 self._libver = libver
File /opt/conda/lib/python3.9/site-packages/h5py/_hl/files.py:220, in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
218 if swmr and swmr_support:
219 flags |= h5f.ACC_SWMR_READ
--> 220 fid = h5f.open(name, flags, fapl=fapl)
221 elif mode == 'r+':
222 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)
File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper()
File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper()
File h5py/h5f.pyx:106, in h5py.h5f.open()
OSError: Unable to open file (invalid SCHEME construction) |
Beta Was this translation helpful? Give feedback.
The solution involved 2 fixes.
First to use this url: s3_url = "s3://dandiarchive/blobs/e08/02c/e0802c3e-5492-42a6-960a-bcf5b3cfd239"
Second, to fix a credentials issue, @nvishnoiMW proposed in another thread to delete stale credentials by deleting the file
~/.aws/credentials
(on Windows something likeC:/Users/username/.aws/credentials
)