The download.py module#
Summary#
Download a case from the remote repository using Zenodo REST API. |
|
Unpack the downloaded tarball file. |
|
Download all supported cases. |
|
Unpack a list of TAR files. |
Description#
Module containing methods to download cases from public databases.
Module detail#
- download.download_case_from_zenodo(database: str, case_number: int, download_folder: pathlib.Path, overwrite: bool = True, validate_hash: bool = True) pathlib.Path | None#
Download a case from the remote repository using Zenodo REST API.
- Parameters:
- database
str name of the database. Options are
'Strocchi2020'or'Rodero2021'.- case_number
int Case number to download.
- download_folder
Path Path to the folder to download the case to.
- overwritebool, default:
True Whether to overwrite existing files.
- validate_hashbool, default:
True Whether to validate file integrity using checksums.
- database
- Returns:
PathorNonePath to the tarball that contains the VTK/CASE files, or None if download failed.
- Raises:
DatabaseNotSupportedErrorIf database name is not recognized.
ValueErrorIf case number is invalid for the database.
Examples
Download case 1 from the public repository (
'Strocchi2020') of pathological hearts.>>> path_to_tar_file = download_case_from_zenodo( ... database="Strocchi2020", case_number=1, download_folder="my/download/folder" ... )
Download case 1 from the public repository (
'Rodero2021') of healthy hearts.>>> path_to_tar_file = download_case_from_zenodo( ... database="Rodero2021", case_number=1, download_folder="my/download/folder" ... )
- download.unpack_case(tar_path: pathlib.Path, reduce_size: bool = True) str | bool#
Unpack the downloaded tarball file.
- Parameters:
- Returns:
strPath to the CASE or VTK file.
Examples
>>> from ansys.health.heart.utils.download import unpack_case >>> path = unpack_case("Rodero2021\\01.tar.gz")
- download.download_all_cases(download_dir: str | None = None) list[str]#
Download all supported cases.
Notes
Note that depending on bandwidth, downloading all cases might take a lot of time.
Examples
>>> from ansys.health.heart.utils.download import download_all_cases >>> tar_files = download_all_cases("my-downloads")
To unpack all cases, you can use the
unpack_cases()method:>>> from ansys.health.heart.utils.download import unpack_cases >>> unpack_cases(tar_files)