Skip to content

Commit 591e33f

Browse files
committed
short log
1 parent 0ca5bd3 commit 591e33f

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

backends/qualcomm/scripts/download_qnn_sdk.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,26 @@ def _download_qnn_sdk() -> Optional[pathlib.Path]:
5959
print(f"Downloading Qualcomm SDK from {qairt_url}...")
6060
try:
6161
# Use urlretrieve with a reporthook to show progress
62-
def report_progress(block_num, block_size, total_size):
63-
downloaded = block_num * block_size
64-
percent = downloaded / total_size * 100
65-
print(
66-
f"Downloaded: {downloaded}/{total_size} bytes ({percent:.2f}%)",
67-
end="\r",
68-
)
62+
def make_report_progress():
63+
last_reported = 0 # nonlocal variable
6964

65+
def report_progress(block_num, block_size, total_size):
66+
nonlocal last_reported
67+
downloaded = block_num * block_size
68+
percent = downloaded / total_size * 100
69+
70+
# Report every 20%
71+
if percent - last_reported >= 20 or percent >= 100:
72+
print(
73+
f"Downloaded: {downloaded}/{total_size} bytes ({percent:.2f}%)"
74+
)
75+
last_reported = percent
76+
77+
return report_progress
78+
79+
report_progress = make_report_progress()
7080
urllib.request.urlretrieve(qairt_url, archive_path, report_progress)
71-
print("\nDownload completed!")
81+
print("Download completed!")
7282

7383
# Check if file was downloaded successfully
7484
if archive_path.exists():

0 commit comments

Comments
 (0)