Skip to content

Commit

Permalink
Merge pull request #49 from WenjieDu/dev
Browse files Browse the repository at this point in the history
Fixing the bug that multiple links in a dataset cannot be all downloaded
  • Loading branch information
WenjieDu authored Nov 9, 2023
2 parents 9beff75 + 8af9cfb commit d926065
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 3 additions & 1 deletion tests/test_tsdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

DATASETS_TO_TEST = [
"ucr_uea_Wine",
"physionet_2012",
"beijing_multisite_air_quality",
]


Expand All @@ -40,7 +42,7 @@ def test_2_dataset_loading(self):
def test_3_dataset_purging(self):
cached_datasets = tsdb.list_cache()
assert isinstance(cached_datasets, list)
tsdb.delete_cache("ucr_uea_Wine") # delete single
tsdb.delete_cache("physionet_2012") # delete single
tsdb.delete_cache() # delete all

def test_4_logging(self):
Expand Down
10 changes: 3 additions & 7 deletions tsdb/utils/downloading.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _download_and_extract(url: str, saving_path: str) -> Optional[str]:
return saving_path


def download_and_extract(dataset_name: str, dataset_saving_path: str) -> Optional[str]:
def download_and_extract(dataset_name: str, dataset_saving_path: str) -> None:
"""Wrapper of _download_and_extract.
Parameters
Expand All @@ -96,15 +96,11 @@ def download_and_extract(dataset_name: str, dataset_saving_path: str) -> Optiona
dataset_saving_path : str,
The local path for dataset saving.
Returns
-------
saving_path if successful else None
"""
logger.info("Start downloading...")
os.makedirs(dataset_saving_path)
if isinstance(DATABASE[dataset_name], list):
for link in DATABASE[dataset_name]:
return _download_and_extract(link, dataset_saving_path)
_download_and_extract(link, dataset_saving_path)
else:
return _download_and_extract(DATABASE[dataset_name], dataset_saving_path)
_download_and_extract(DATABASE[dataset_name], dataset_saving_path)

0 comments on commit d926065

Please sign in to comment.