Add progress bar for downlaod
Browse files
ecoset.py
CHANGED
@@ -133,9 +133,35 @@ class Ecoset(datasets.GeneratorBasedBuilder):
|
|
133 |
member_list = zip_file.namelist()
|
134 |
for member in tqdm(member_list, total=len(member_list), desc="Extracting ecoset to disc"):
|
135 |
zip_file.extract(member, target_dir, pwd=password.encode("ascii"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
|
138 |
-
def
|
139 |
"""Moderately slow download"""
|
140 |
# ask password
|
141 |
password = getpass(_PWD_MSG)
|
|
|
133 |
member_list = zip_file.namelist()
|
134 |
for member in tqdm(member_list, total=len(member_list), desc="Extracting ecoset to disc"):
|
135 |
zip_file.extract(member, target_dir, pwd=password.encode("ascii"))
|
136 |
+
|
137 |
+
|
138 |
+
def subprocess_download(source_url, target_dir):
|
139 |
+
"""Moderately slow download"""
|
140 |
+
# ask password
|
141 |
+
password = getpass(_PWD_MSG)
|
142 |
+
check_pass(password)
|
143 |
+
# download
|
144 |
+
print('Using native OS unzipping. This will take about 15h on a typical Linux/Mac and 8h on a typical Windows Computer.')
|
145 |
+
urlinfo = urlparse(source_url, allow_fragments=False)
|
146 |
+
# create destination path if not existing
|
147 |
+
if not op.exists(target_dir):
|
148 |
+
os.makedirs(target_dir)
|
149 |
+
# download zip file if not existing
|
150 |
+
zip_path = op.join(target_dir, "ecoset.zip")
|
151 |
+
if not op.exists(zip_path):
|
152 |
+
s3 = boto3.client(urlinfo.scheme, config=Config(signature_version=UNSIGNED))
|
153 |
+
object_size = s3.head_object()["ContentLength"]
|
154 |
+
with tqdm.tqdm(total=object_size, unit="B", unit_scale=True, desc=filename) as pbar:
|
155 |
+
s3.download_file(urlinfo.netloc, urlinfo.path[1:], zip_path,
|
156 |
+
Callback=lambda bytes_transferred: pbar.update(bytes_transferred))
|
157 |
+
# unzip using platform-based subprocess
|
158 |
+
if platform.system() in ("Linux", "Darwin"):
|
159 |
+
subprocess.call(["unzip", "-n", "-P", password.encode("ascii"), "-o", zip_path, "-d", target_dir], shell=False)
|
160 |
+
else:
|
161 |
+
subprocess.call(["tar.exe", "-xf", zip_path, "-C", target_dir, "--passphrase", password], shell=False)
|
162 |
|
163 |
|
164 |
+
def subprocess_download2(source_url, target_dir):
|
165 |
"""Moderately slow download"""
|
166 |
# ask password
|
167 |
password = getpass(_PWD_MSG)
|