From b032dccde617fe61ba0c33a89b75d72333d8b228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDafydd?= <“dafydd_stephenson@hotmail.com”> Date: Mon, 19 Aug 2024 13:21:04 -0600 Subject: [PATCH] update docstring for InputDataset.get() --- cstar_ocean/input_dataset.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cstar_ocean/input_dataset.py b/cstar_ocean/input_dataset.py index cc44974..b224388 100644 --- a/cstar_ocean/input_dataset.py +++ b/cstar_ocean/input_dataset.py @@ -100,9 +100,12 @@ def __repr__(self): def get(self, local_dir: str): """ - Fetch the file containing this input dataset and save it within `local_dir/input_datasets` using Pooch. + Make the file containing this input dataset available in `local_dir/input_datasets` - This method updates the `local_path` attribute of the calling InputDataset object + If InputDataset.source is... + - ...a local path: create a symbolic link to the file in `local_dir/input_datasets`. + - ...a URL: fetch the file to `local_dir/input_datasets` using Pooch + (updating the `local_path` attribute of the calling InputDataset) Parameters: ----------- @@ -114,6 +117,7 @@ def get(self, local_dir: str): os.makedirs(tgt_dir, exist_ok=True) tgt_path = tgt_dir + os.path.basename(self.source) + # If the file is somewhere else on the system, make a symbolic link where we want it if self.exists_locally: assert ( self.local_path is not None @@ -126,7 +130,6 @@ def get(self, local_dir: str): ) # TODO maybe this should check the hash and just `return` if it matches? else: - # If the file is somewhere else on the system, make a symbolic link where we want it os.symlink(self.local_path, tgt_path) return else: @@ -134,6 +137,7 @@ def get(self, local_dir: str): return else: + # Otherwise, download the file # NOTE: default timeout was leading to a lot of timeouterrors downloader = pooch.HTTPDownloader(timeout=120) to_fetch = pooch.create(