From 341ea7382360fa458acfacdbfc545db2842f4b90 Mon Sep 17 00:00:00 2001 From: Massimiliano Lupo Pasini Date: Thu, 24 Oct 2024 20:07:11 -0400 Subject: [PATCH] updated download script to move tar files into subdirectories --- examples/omat24/download_dataset.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/omat24/download_dataset.py b/examples/omat24/download_dataset.py index bafe2fddd..521aa0567 100644 --- a/examples/omat24/download_dataset.py +++ b/examples/omat24/download_dataset.py @@ -52,15 +52,17 @@ def get_data(datadir, task, split): ), f'{task}/{split}" split not defined, please specify one of the following: {list(DOWNLOAD_LINKS[task].keys())}' download_link = DOWNLOAD_LINKS[task][split] + os.makedirs(os.path.join(datadir, task), exist_ok=True) + os.system(f"wget {download_link} -P {datadir}") filename = os.path.join(datadir, os.path.basename(download_link)) - logging.info("Extracting contents...") - os.system(f"tar -xvf {filename} -C {datadir}") - filename_without_extension = filename.replace(".tar.gz", "") - os.makedirs(os.path.join(datadir, task), exist_ok=True) # Move the directory - shutil.move(filename_without_extension, os.path.join(datadir, task)) + new_filename = os.path.join(datadir, task, os.path.basename(download_link)) + shutil.move(filename, new_filename) + + logging.info("Extracting contents...") + os.system(f"tar -xvf {new_filename} -C {os.path.join(datadir, task)}") if __name__ == "__main__":