Project-MONAI / MONAI

AI Toolkit for Healthcare Imaging
https://monai.io/
Apache License 2.0
5.93k stars 1.09k forks source link

enhance download_and_extract #8214

Closed Jerome-Hsieh closed 1 week ago

Jerome-Hsieh commented 1 week ago

Fixes #5463

Description

@wyli @KumoLiu @ericspod

According to issue, the error messages are not very intuitive. I think maybe we can check if the file name matches the downloaded file’s base name before starting the download. If it doesn’t match, it will notify user.

>>> import monai
>>> url = "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/MedNIST.tar.gz"
>>> monai.apps.utils.download_and_extract(url, filepath="./test")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/yuan/Desktop/OSS/MONAI/monai/apps/utils.py", line 363, in download_and_extract
    raise NotImplementedError(
NotImplementedError: The file types do not match: url=.tar.gz, but filepath=

Types of changes