Skip to content

Commit bda1298

Browse files
committed
Adding some timing information to download of example files
1 parent 02d2fe4 commit bda1298

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

bigwig_loader/download_example_data.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import hashlib
33
import logging
44
import shutil
5+
import time
56
import urllib.request
67
from pathlib import Path
78
from typing import BinaryIO
@@ -57,7 +58,11 @@ def _download_genome(
5758
uncompressed_file_path: Path,
5859
md5_checksum: str,
5960
) -> Path:
61+
LOGGER.info(f"Downloading {url} to {compressed_file_path}")
62+
start_time = time.time()
6063
urllib.request.urlretrieve(url, compressed_file_path)
64+
elapsed_time = time.time() - start_time
65+
LOGGER.info(f"Download completed in {elapsed_time:.2f} seconds")
6166
# subprocess.run(["bgzip", "-d", compressed_file])
6267
unzip_gz_file(compressed_file_path, uncompressed_file_path)
6368
this_checksum = checksum_md5_for_path(uncompressed_file_path)
@@ -86,7 +91,7 @@ def unzip_gz_file(compressed_file_path: Path, output_file_path: Path) -> Path:
8691
),
8792
"mc_Late_Childhood_GLU_BS.bins128.bw": (
8893
"https://brainome.ucsd.edu/emukamel/PEC_igv/binc_bigwig/mc_Late_Childhood_GLU_BS.bins128.bw",
89-
"c91eee81f11e4dc7cecaae72abd14c66",
94+
"fc4c48b0f8df80f6e7680df47c37142f",
9095
),
9196
}
9297

@@ -109,11 +114,15 @@ def checksum_md5(f: BinaryIO, *, chunk_size: int = 10 * 1024 * 1024) -> str:
109114
def get_example_bigwigs_files(bigwig_dir: Path = config.bigwig_dir) -> Path:
110115
bigwig_dir.mkdir(parents=True, exist_ok=True)
111116
available_files = [pth.name for pth in get_bigwig_files_from_path(bigwig_dir)]
112-
if len(available_files) < 2:
117+
if len(available_files) < 3:
113118
for fn, (url, md5) in EXAMPLE_FILES.items():
114119
file = bigwig_dir / fn
115120
if not file.exists():
121+
LOGGER.info(f"Downloading {url} to {file}")
122+
start_time = time.time()
116123
urllib.request.urlretrieve(url, file)
124+
elapsed_time = time.time() - start_time
125+
LOGGER.info(f"Download completed in {elapsed_time:.2f} seconds")
117126
checksum = checksum_md5_for_path(file)
118127
if checksum != md5:
119128
raise RuntimeError(f"{fn} has incorrect checksum: {checksum} vs. {md5}")

0 commit comments

Comments
 (0)