Skip to content

Commit

Permalink
update docstring for InputDataset.get()
Browse files Browse the repository at this point in the history
  • Loading branch information
“Dafydd committed Aug 20, 2024
1 parent d0ba139 commit b032dcc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cstar_ocean/input_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
-----------
Expand All @@ -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
Expand All @@ -126,14 +130,14 @@ 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:
# nothing to do as file is already at tgt_path
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(
Expand Down

0 comments on commit b032dcc

Please sign in to comment.