the-virtual-brain / tvb-root

Main TVB codebase
https://thevirtualbrain.org
Other
121 stars 99 forks source link

[WIP] Framework to download entities from Zenodo #675

Closed abhi-glitchhg closed 1 year ago

abhi-glitchhg commented 1 year ago

Using Pyzenodo3 to download the repositories.

Still work in progress. Could think of using Pooch to handle the downloading and remove the utils.py.

i-Zaak commented 1 year ago

Oh that is super simple:

import pooch

files = pooch.retrieve(
    url='doi:10.5281/zenodo.4263723/tvb_data.zip',
    known_hash=None,
    downloader=pooch.DOIDownloader(),
    processor=pooch.Unzip()
)

The download is cached, and you can also substitute the None with actual hash which gets printed out on first download...

abhi-glitchhg commented 1 year ago

I will improve the docs and tests soon.

an example how user can download and fetch the data.


from tvb.datasets import TVB_Data

tvb_data = TVB_Data(version = "2.0.3")
connectivity_66_path = tvb_data.fetch_data("connectivity_66.zip") 
print(connectivity_66_path, connectivity_66_path.is_file())

ql_bold_path = tvb_data.fetch_data("QL_BOLD_regiontimecourse.mat")
print(ql_bold_path, ql_bold_path.is_file())

output of the above script.

file tvb_data.zip is downloaded at /home/abhijit/.cache/pooch/df068f14e199441033182c2ea36820e8-tvb_data.zip
/home/abhijit/oss/gsoc/tvb-root/tvb_library/tvb_data/connectivity/connectivity_66.zip True
/home/abhijit/oss/gsoc/tvb-root/tvb_library/tvb_data/berlinSubjects/QL_20120814/QL_BOLD_regiontimecourse.mat True