From e47acfd51739642079b7eb24c0025f5a7ad0f77a Mon Sep 17 00:00:00 2001 From: travis Date: Mon, 15 Feb 2021 08:22:16 -0800 Subject: [PATCH] rebase and add download utility --- download.py | 53 +++++++++++++++++++++++++++ mosartwmpy/data_manifest.yaml | 2 +- mosartwmpy/utilities/download_data.py | 1 - 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 download.py diff --git a/download.py b/download.py new file mode 100644 index 0000000..ef915c8 --- /dev/null +++ b/download.py @@ -0,0 +1,53 @@ +import enum +import os + +from benedict import benedict + +from mosartwmpy.utilities.download_data import download_data + +available_data = benedict.from_yaml('./mosartwmpy/data_manifest.yaml') + +data_list = [] +data = [] + +for i, name in enumerate(available_data.keys()): + data_list.append(name) + data.append(f""" + {i + 1}) {name} - {available_data.get(f'{name}.description')}""") + +# clear the terminal +print(chr(27) + "[2J") + +print(f""" + 🎶 Welcome to the mosartwmpy download utility! 🎵 + + Please select the data you wish to download by typing the number: +""") + +for d in data: + print(f""" + {d}""") + +print(f""" + + 0) exit + +""") +try: + user_input = int(input(""" + Please select a number and press enter: """)) +except: + pass + +if not user_input or user_input == 0 or user_input > len(data): + print(""" + + Exiting... + + """) + +else: + print("") + print("") + download_data(data_list[user_input - 1]) + diff --git a/mosartwmpy/data_manifest.yaml b/mosartwmpy/data_manifest.yaml index 2d74bdb..1eade6e 100644 --- a/mosartwmpy/data_manifest.yaml +++ b/mosartwmpy/data_manifest.yaml @@ -7,7 +7,7 @@ sample_input: validation: description: Result datasets that can be used for validating the model; includes results with and without WM; covers 1981-1982. - url: TODO + url: https://zenodo.org/record/4539693/files/mosartwmpy_validation.zip?download=1 destination: ./validation # TODO add other weather files, demand files, etc as they become ready \ No newline at end of file diff --git a/mosartwmpy/utilities/download_data.py b/mosartwmpy/utilities/download_data.py index 1c6997d..bbea51d 100644 --- a/mosartwmpy/utilities/download_data.py +++ b/mosartwmpy/utilities/download_data.py @@ -6,7 +6,6 @@ import sys from benedict import benedict -from pkg_resources import get_distribution def download_data(dataset: str, destination: str = None, manifest: str = './mosartwmpy/data_manifest.yaml') -> None: