Skip to content

parameter filepath of download_and_extract #5463

Closed
@wyli

Description

@wyli

Describe the bug

>>> 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=".")
2022-11-03 15:15:04,858 - INFO - Expected md5 is None, skip md5 check for file ..
2022-11-03 15:15:04,858 - INFO - File exists: ., skipped downloading.
2022-11-03 15:15:04,858 - INFO - Non-empty folder exists in ., skipped extracting.

>>> monai.apps.utils.download_and_extract(url, filepath="./test")
test: 59.0MB [00:09, 6.22MB/s]                                                                                                                                                                                     
2022-11-03 15:16:23,355 - INFO - Downloaded: test
2022-11-03 15:16:23,356 - INFO - Expected md5 is None, skip md5 check for file test.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/Documents/MONAI/monai/apps/utils.py", line 313, in download_and_extract
    extractall(filepath=filename, output_dir=output_dir, file_type=file_type, has_base=has_base)
  File "/Users/Documents/MONAI/monai/apps/utils.py", line 256, in extractall
    if cache_dir.exists() and next(cache_dir.iterdir(), None) is not None:
  File "/usr/local/anaconda3/envs/py38/lib/python3.8/pathlib.py", line 1122, in iterdir
    for name in self._accessor.listdir(self):
NotADirectoryError: [Errno 20] Not a directory: 'test'

it's not easy to set a valid filepath for download_and_extract and the error messages are not very intuitive.

would be great if the argument can be used to cache the downloaded file easily

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions