From 63d03c14540e3fe45f22c36b2fb7ee63c3819ca9 Mon Sep 17 00:00:00 2001 From: HyunGeun Lee <52870444+hglee98@users.noreply.github.com> Date: Sat, 11 Nov 2023 09:26:11 +0900 Subject: [PATCH 1/3] Update README.rst This commit address the issue #7 that some people couldn't download datasets by facing the error like " AttributeError: module 'crcnsget' has no attribute 'download' " --- README.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.rst b/README.rst index 06e10b1..6ddbcf6 100644 --- a/README.rst +++ b/README.rst @@ -54,6 +54,15 @@ For example, Will download the from the `data_structure_ANM218457.tar.gz` file from the `alm-1` dataset. +In case of getting error of "AttributeError: module 'crcnsget' has no attribute 'download'", here is an alternative way to download the dataset. + +.. code-block:: console + + $ git clone https://github.com/neuromusic/crcnsget.git + $ cd crcnsget + $ pip install -e . + $ crcnsget --username --dataset + Credits --------- From 6d5a6faba774cefdabd656df6170b5a52296f620 Mon Sep 17 00:00:00 2001 From: HyunGeun Lee <52870444+hglee98@users.noreply.github.com> Date: Sat, 11 Nov 2023 10:46:08 +0900 Subject: [PATCH 2/3] Update crcnsget.py This commit aims for adding feature of progress bar using tqdm --- crcnsget/crcnsget.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crcnsget/crcnsget.py b/crcnsget/crcnsget.py index 6c09bd5..9c0e2c1 100644 --- a/crcnsget/crcnsget.py +++ b/crcnsget/crcnsget.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import requests +from tqdm import tqdm URL = 'https://portal.nersc.gov/project/crcns/download/index.php' @@ -16,8 +17,16 @@ def download(datafile,username,password): with requests.Session() as s: local_filename = login_data['fn'].split('/')[-1] r = s.post(URL,data=login_data,stream=True) - with open(local_filename, 'wb') as f: + total_size = int(r.headers.get('Content-Length', 0)) + + with open(local_filename, 'wb') as f, tqdm( + desc=local_filename, + total=total_size, + unit='B', + unit_scale=True, + unit_divisor=1024) as bar: for chunk in r.iter_content(chunk_size=1024): if chunk: f.write(chunk) - print(local_filename) + bar.update(len(chunk)) + print(f"{local_filename} downloaded successfully.") From 56feb6ce877794fdb932f70e8823417aaa4e3d86 Mon Sep 17 00:00:00 2001 From: HyunGeun Lee <52870444+hglee98@users.noreply.github.com> Date: Sat, 11 Nov 2023 10:46:44 +0900 Subject: [PATCH 3/3] Update requirements_dev.txt --- requirements_dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements_dev.txt b/requirements_dev.txt index e680ed0..560e6f2 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -6,5 +6,6 @@ flake8==2.6.0 tox==2.3.1 coverage==4.1 Sphinx==1.4.4 +tqdm==4.64.1