File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -268,9 +268,11 @@ def download_url(
268268 pass
269269 logger .info (f"Downloaded: { filepath } " )
270270 if not check_hash (filepath , hash_val , hash_type ):
271- raise RuntimeError (
272- f"{ hash_type } check of downloaded file failed: URL={ url } , "
273- f"filepath={ filepath } , expected { hash_type } ={ hash_val } ."
271+ raise ValueError (
272+ f"{ hash_type } hash check of downloaded file failed: URL={ url } , "
273+ f"filepath={ filepath } , expected { hash_type } ={ hash_val } , "
274+ f"The file may be corrupted or tampered with. "
275+ "Please retry the download or verify the source."
274276 )
275277
276278
Original file line number Diff line number Diff line change 7979 "unexpected EOF" , # incomplete download
8080 "network issue" ,
8181 "gdown dependency" , # gdown not installed
82- "md5 check" ,
82+ "hash check" , # check hash value of downloaded file
8383 "limit" , # HTTP Error 503: Egress is over the account limit
8484 "authenticate" ,
8585 "timed out" , # urlopen error [Errno 110] Connection timed out
@@ -180,8 +180,11 @@ def skip_if_downloading_fails():
180180 err_str = str (rt_e )
181181 if any (k in err_str for k in DOWNLOAD_FAIL_MSGS ):
182182 raise unittest .SkipTest (f"Error while downloading: { rt_e } " ) from rt_e # incomplete download
183-
183+
184184 raise rt_e
185+ except ValueError as v_e :
186+ if "hash check" in str (v_e ):
187+ raise unittest .SkipTest (f"Hash value error while downloading: { v_e } " ) from v_e
185188
186189
187190SAMPLE_TIFF = "https://huggingface.co/datasets/MONAI/testing_data/resolve/main/CMU-1.tiff"
You can’t perform that action at this time.
0 commit comments