Skip to content

Commit 8885fcb

Browse files
authored
Make Fuzzy Gdown Argument Version-dependent (#8986)
### Description Gdown has dropped the "fuzzy" argument in version 6.0.0. This PR makes the argument dependent on the Gdown version being below this, and removes it where it's not needed. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
1 parent 5da2472 commit 8885fcb

3 files changed

Lines changed: 3 additions & 4 deletions

File tree

monai/apps/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def download_url(
240240
if urlparse(url).netloc == "drive.google.com":
241241
if not has_gdown:
242242
raise RuntimeError("To download files from Google Drive, please install the gdown dependency.")
243-
if "fuzzy" not in gdown_kwargs:
243+
if "fuzzy" not in gdown_kwargs and not min_version(gdown, "6.0.0"): # "fuzzy" dropped in gdown 6.0.0
244244
gdown_kwargs["fuzzy"] = True # default to true for flexible url
245245
gdown.download(url, f"{tmp_name}", quiet=not progress, **gdown_kwargs)
246246
elif urlparse(url).netloc == "cloud-api.yandex.net":

monai/bundle/scripts.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2005,7 +2005,6 @@ def download_large_files(bundle_path: str | None = None, large_file_name: str |
20052005
parser.read_config(large_file_path)
20062006
large_files_list = parser.get()["large_files"]
20072007
for lf_data in large_files_list:
2008-
lf_data["fuzzy"] = True
20092008
if "hash_val" in lf_data and lf_data.get("hash_val", "") == "":
20102009
lf_data.pop("hash_val")
20112010
if "hash_type" in lf_data and lf_data.get("hash_type", "") == "":

monai/networks/nets/hovernet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ def _remap_preact_resnet_model(model_url: str):
632632
pattern_bna = re.compile(r"^(.+\.d\d+)\.blk_bna\.(.+)")
633633
# download the pretrained weights into torch hub's default dir
634634
weights_dir = os.path.join(torch.hub.get_dir(), "preact-resnet50.pth")
635-
download_url(model_url, fuzzy=True, filepath=weights_dir, progress=False)
635+
download_url(model_url, filepath=weights_dir, progress=False)
636636
map_location = None if torch.cuda.is_available() else torch.device("cpu")
637637
state_dict = torch.load(weights_dir, map_location=map_location, weights_only=True)["desc"]
638638

@@ -667,7 +667,7 @@ def _remap_standard_resnet_model(model_url: str, state_dict_key: str | None = No
667667
pattern_downsample1 = re.compile(r"^(res_blocks.d\d+).+\.downsample\.1\.(.+)")
668668
# download the pretrained weights into torch hub's default dir
669669
weights_dir = os.path.join(torch.hub.get_dir(), "resnet50.pth")
670-
download_url(model_url, fuzzy=True, filepath=weights_dir, progress=False)
670+
download_url(model_url, filepath=weights_dir, progress=False)
671671
map_location = None if torch.cuda.is_available() else torch.device("cpu")
672672
state_dict = torch.load(weights_dir, map_location=map_location, weights_only=True)
673673
if state_dict_key is not None:

0 commit comments

Comments
 (0)