navis-org/navis-flybrains

Issue with saalfeldlab_transforms download

dokato opened this issue · 2 comments

PTAL at error message below:

> flybrains.download_saalfeldlab_transforms()
Downloading Saalfeld lab transforms into /Users/dominik/flybrain-data
---------------------------------------------------------------------------     
KeyError                                  Traceback (most recent call last)
<ipython-input-6-205a66d97e28> in <module>
----> 1 flybrains.download_saalfeldlab_transforms()

~/anaconda3/envs/pyg/lib/python3.8/site-packages/flybrains/download.py in download_saalfeldlab_transforms(data_home, skip_existing)
    233         if skip_existing and os.path.exists(dst):
    234             continue
--> 235         _ = download_from_url(url, dst)
    236 
    237 

~/anaconda3/envs/pyg/lib/python3.8/site-packages/flybrains/download.py in download_from_url(url, dst, resume)
    255 
    256     """
--> 257     file_size = int(requests.head(url, allow_redirects=True).headers["Content-Length"])
    258     if os.path.exists(dst) and resume:
    259         first_byte = os.path.getsize(dst)

~/anaconda3/envs/pyg/lib/python3.8/site-packages/requests/structures.py in __getitem__(self, key)
     52 
     53     def __getitem__(self, key):
---> 54         return self._store[key.lower()][1]
     55 
     56     def __delitem__(self, key):

KeyError: 'content-length'

The issue is that figshare (which is where the Saalfeld transforms are hosted) has either moved their backend to AWS or AWS itself has changed things under the hood. In any event: AWS does not allow HEAD queries to get the file size before starting the download which means we can't show a nice progress bar.

I already adjusted the code with 0dd559d to be robust against failed file size queries. Can you check if you have the most recent version 0.1.11 of navis-flybrains?

Yes, I was on version 0.1.9 still. V 0.1.11 indeed solves the problem, thanks !