Add retry in downloading IREE artifacts. Bug: 202732343 Change-Id: I002f4e8c5b8c1de3f11e73305b7ce27a7bee7a46
diff --git a/download_iree_compiler.py b/download_iree_compiler.py index ab5939f..fe827d7 100755 --- a/download_iree_compiler.py +++ b/download_iree_compiler.py
@@ -4,8 +4,10 @@ import os import sys import tarfile +import time import argparse import requests +import urllib import wget from pathlib import Path @@ -29,7 +31,17 @@ if not os.path.isdir(out_dir): os.mkdir(out_dir) out_file = os.path.join(out_dir, artifact_name) - wget.download(download_url, out=out_file) + + num_retries = 3 + for i in range(num_retries + 1): + try: + wget.download(download_url, out=out_file) + break + except urllib.error.HTTPError as e: + if i == num_retries: + raise + print(f"{e}\nDownload failed. Retrying...") + time.sleep(5) return out_file