From 179fcadf7b82df0e8ff3b671f04e4b102ae9964e Mon Sep 17 00:00:00 2001 From: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com> Date: Thu, 16 May 2024 16:55:21 -0500 Subject: [PATCH] fix dataset download (3) --- benchmarks/mpas_ocean.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/benchmarks/mpas_ocean.py b/benchmarks/mpas_ocean.py index b52f788c8..b180f48c5 100644 --- a/benchmarks/mpas_ocean.py +++ b/benchmarks/mpas_ocean.py @@ -18,11 +18,12 @@ filenames = [grid_filename_480, data_filename_480, grid_filename_120, data_filename_120] -for filename in filenames: - if not os.path.isfile(current_path / filename): - # downloads the files from Cookbook repo, if they haven't been downloaded locally yet - url = f"https://github.com/ProjectPythia/unstructured-grid-viz-cookbook/raw/main/meshfiles/{filename}" - _, headers = urllib.request.urlretrieve(url, filename=current_path / filename) +def _check_file_download(): + for filename in filenames: + if not os.path.isfile(current_path / filename): + # downloads the files from Cookbook repo, if they haven't been downloaded locally yet + url = f"https://github.com/ProjectPythia/unstructured-grid-viz-cookbook/raw/main/meshfiles/{filename}" + _, headers = urllib.request.urlretrieve(url, filename=current_path / filename) file_path_dict = {"480km": [current_path / grid_filename_480, current_path / data_filename_480], @@ -36,6 +37,7 @@ class Gradient: def setup(self, resolution): + _check_file_download() self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1]) def teardown(self, resolution): @@ -54,6 +56,7 @@ class Integrate: def setup(self, resolution): + _check_file_download() self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1]) def teardown(self, resolution): @@ -73,6 +76,7 @@ class GeoDataFrame: def setup(self, resolution, exclude_antimeridian): + _check_file_download() self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1]) def teardown(self, resolution, exclude_antimeridian): @@ -92,6 +96,7 @@ class ConnectivityConstruction: def setup(self, resolution): + _check_file_download() self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1]) def teardown(self, resolution):