From 4513dfb8c15cd537c33d26da6d3f600f4dbc2858 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Wed, 8 Feb 2023 11:10:18 +0000 Subject: [PATCH 1/5] Removed flake8 and black Nox sessions. --- noxfile.py | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/noxfile.py b/noxfile.py index c541521f..9c82d033 100644 --- a/noxfile.py +++ b/noxfile.py @@ -275,44 +275,6 @@ def update_lockfiles(session: nox.sessions.Session): print(f"Conda lock file created: {lockfile_path}") -@nox.session -def flake8(session: nox.sessions.Session): - """ - Perform flake8 linting of the code-base. - - Parameters - ---------- - session: object - A `nox.sessions.Session` object. - - """ - # Pip install the session requirements. - session.install("flake8", "flake8-docstrings", "flake8-import-order") - # Execute the flake8 linter on the package. - session.run("flake8", PACKAGE) - # Execute the flake8 linter on this file. - session.run("flake8", __file__) - - -@nox.session -def black(session: nox.sessions.Session): - """ - Perform black format checking of the code-base. - - Parameters - ---------- - session: object - A `nox.sessions.Session` object. - - """ - # Pip install the session requirements. - session.install("black==22.3.0") - # Execute the black format checker on the package. - session.run("black", "--check", PACKAGE) - # Execute the black format checker on this file. - session.run("black", "--check", __file__) - - @nox.session(python=PY_VER, venv_backend="conda") def tests(session: nox.sessions.Session): """ From 1a31971d40a237084e96ac6e75a884fb4e260b4d Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Wed, 8 Feb 2023 11:21:24 +0000 Subject: [PATCH 2/5] Remove linting Cirrus session. --- .cirrus.yml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 613aa82d..2f227a6c 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -16,7 +16,6 @@ container: env: # Skip specific tasks by name. Set to a non-empty string to skip. - SKIP_LINT_TASK: "" SKIP_TEST_TASK: "" SKIP_BENCHMARK_TASK: "" # Maximum cache period (in weeks) before forcing a new cache upload. @@ -81,27 +80,6 @@ LINUX_CONDA_TEMPLATE: &LINUX_CONDA_TEMPLATE - conda install --quiet --name base ${CONDA_CACHE_PACKAGES} -# -# Linting -# -lint_task: - only_if: ${SKIP_LINT_TASK} == "" - auto_cancellation: true - name: "${CIRRUS_OS}: flake8 and black" - pip_cache: - folder: ~/.cache/pip - fingerprint_script: - - echo "${CIRRUS_TASK_NAME} py${PYTHON_VERSION}" - - echo "${PIP_CACHE_PACKAGES}" - - echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${PIP_CACHE_BUILD}" - lint_script: - - pip list - - python -m pip install --retries 3 --upgrade ${PIP_CACHE_PACKAGES} - - pip list - - nox --session flake8 - - nox --session black - - # # Testing (Linux) # From c161f2e46312b355ddd633cd5dde9ef5c9529758 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Thu, 9 Feb 2023 12:27:29 +0000 Subject: [PATCH 3/5] Include flake8 plugins in pre-commit. --- .pre-commit-config.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 831945c0..2a304c3e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,3 +29,7 @@ repos: # Run flake8. - id: flake8 args: [--config=./.flake8] + additional_dependencies: [ + 'flake8-docstrings==1.6.0', + 'flake8-import-order==0.18.2', + ] From 532f69bc97ab91cb2284566533f0b6c278d92e3d Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Thu, 9 Feb 2023 12:28:34 +0000 Subject: [PATCH 4/5] Update dependency requirements. --- requirements/py310.yml | 4 ---- requirements/py38.yml | 4 ---- requirements/py39.yml | 4 ---- 3 files changed, 12 deletions(-) diff --git a/requirements/py310.yml b/requirements/py310.yml index 782db31f..fe836d6b 100644 --- a/requirements/py310.yml +++ b/requirements/py310.yml @@ -19,11 +19,7 @@ dependencies: # Test dependencies. - asv - - black=22.3.0 - codecov - - flake8 - - flake8-docstrings - - flake8-import-order - nox - pre-commit - pytest diff --git a/requirements/py38.yml b/requirements/py38.yml index d56f9264..54f08799 100644 --- a/requirements/py38.yml +++ b/requirements/py38.yml @@ -19,11 +19,7 @@ dependencies: # Test dependencies. - asv - - black=22.3.0 - codecov - - flake8 - - flake8-docstrings - - flake8-import-order - nox - pre-commit - pytest diff --git a/requirements/py39.yml b/requirements/py39.yml index 00eb99e1..9a1c909e 100644 --- a/requirements/py39.yml +++ b/requirements/py39.yml @@ -19,11 +19,7 @@ dependencies: # Test dependencies. - asv - - black=22.3.0 - codecov - - flake8 - - flake8-docstrings - - flake8-import-order - nox - pre-commit - pytest From 01bfcdbbaa8f9bdd4ec8208f6c5c2443afd89064 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Thu, 9 Feb 2023 17:02:34 +0000 Subject: [PATCH 5/5] Fix benchmark flake8 non-compliances. --- benchmarks/asv_delegated_conda.py | 8 +-- benchmarks/benchmarks/__init__.py | 8 +-- .../benchmarks/esmf_regridder/__init__.py | 53 +++++++++++++-- .../benchmarks/esmf_regridder/scalability.py | 66 ++++++++++++++++++- benchmarks/benchmarks/generate_data.py | 6 +- 5 files changed, 120 insertions(+), 21 deletions(-) diff --git a/benchmarks/asv_delegated_conda.py b/benchmarks/asv_delegated_conda.py index d274fad5..d136662c 100644 --- a/benchmarks/asv_delegated_conda.py +++ b/benchmarks/asv_delegated_conda.py @@ -1,8 +1,4 @@ -""" -ASV plug-in providing an alternative :class:`asv.plugins.conda.Conda` -subclass that manages the Conda environment via custom user scripts. - -""" +"""ASV plug-in - managing Conda environment via custom user scripts.""" from os import environ from os.path import getmtime @@ -41,6 +37,8 @@ def __init__( tagged_env_vars: dict, ) -> None: """ + Create the instance. + Parameters ---------- conf : Config instance diff --git a/benchmarks/benchmarks/__init__.py b/benchmarks/benchmarks/__init__.py index 1804f935..f398f985 100644 --- a/benchmarks/benchmarks/__init__.py +++ b/benchmarks/benchmarks/__init__.py @@ -1,4 +1,4 @@ -"""Benchmark tests for iris-esmf-regrid""" +"""Benchmark tests for iris-esmf-regrid.""" from os import environ @@ -6,7 +6,7 @@ def disable_repeat_between_setup(benchmark_object): """ - Decorator for benchmarks where object persistence would be inappropriate. + Decorate benchmarks where object persistence would be inappropriate. E.g: * Data is realised during testing. @@ -32,7 +32,7 @@ def disable_repeat_between_setup(benchmark_object): def skip_benchmark(benchmark_object): """ - Decorator for benchmarks skipping benchmarks. + Decorate benchmarks to be skipped. Simply doesn't return the object. @@ -49,7 +49,7 @@ def skip_benchmark(benchmark_object): def on_demand_benchmark(benchmark_object): """ - Decorator. Disables these benchmark(s) unless ON_DEMAND_BENCHARKS env var is set. + Decorate benchmark(s) that are disabled unless ON_DEMAND_BENCHARKS env var is set. For benchmarks that, for whatever reason, should not be run by default. E.g: diff --git a/benchmarks/benchmarks/esmf_regridder/__init__.py b/benchmarks/benchmarks/esmf_regridder/__init__.py index 743507da..aa399e2e 100644 --- a/benchmarks/benchmarks/esmf_regridder/__init__.py +++ b/benchmarks/benchmarks/esmf_regridder/__init__.py @@ -3,11 +3,11 @@ import os from pathlib import Path -import numpy as np import dask.array as da import iris from iris.cube import Cube from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD +import numpy as np from esmf_regrid.esmf_regridder import GridInfo from esmf_regrid.experimental.unstructured_scheme import ( @@ -15,16 +15,13 @@ MeshToGridESMFRegridder, ) from esmf_regrid.schemes import ESMFAreaWeightedRegridder - from ..generate_data import _grid_cube, _gridlike_mesh_cube def _make_small_grid_args(): - """ - Not importing the one in test_GridInfo - if that changes, these benchmarks - would 'invisibly' change too. + # Not importing the one in test_GridInfo - if that changes, these benchmarks + # would 'invisibly' change too. - """ small_x = 2 small_y = 3 small_grid_lon = np.array(range(small_x)) / (small_x + 1) @@ -41,12 +38,15 @@ def _make_small_grid_args(): class TimeGridInfo: + """Basic benchmarking for :class:~esmf_regrid.esmf_regridder.GridInfo`.""" + def setup(self): + """ASV setup method.""" lon, lat, lon_bounds, lat_bounds = _make_small_grid_args() self.grid = GridInfo(lon, lat, lon_bounds, lat_bounds) def time_make_grid(self): - """Basic test for :meth:`~esmf_regrid.esmf_regridder.GridInfo.make_esmf_field`.""" + """Benchmark :meth:`~esmf_regrid.esmf_regridder.GridInfo.make_esmf_field` time.""" esmf_grid = self.grid.make_esmf_field() esmf_grid.data[:] = 0 @@ -54,10 +54,13 @@ def time_make_grid(self): class MultiGridCompare: + """Mixin to prepare common arguments for benchmarking between different grid sizes.""" + params = ["similar", "large_source", "large_target", "mixed"] param_names = ["source/target difference"] def get_args(self, tp): + """Prepare common arguments.""" lon_bounds = (-180, 180) lat_bounds = (-90, 90) n_lons_src = 20 @@ -86,7 +89,10 @@ def get_args(self, tp): class TimeRegridding(MultiGridCompare): + """Benchmarks for :class:`~esmf_regrid.esmf_regrid.schemes.ESMFAreaWeightedRegridder`.""" + def setup(self, tp): + """ASV setup method.""" ( lon_bounds, lat_bounds, @@ -117,14 +123,19 @@ def setup(self, tp): self.tgt = tgt def time_prepare_regridding(self, tp): + """Benchmark the prepare time.""" _ = self.regrid_class(self.src, self.tgt) def time_perform_regridding(self, tp): + """Benchmark the perform time.""" _ = self.regridder(self.src) class TimeLazyRegridding: + """Lazy benchmarks for :class:`~esmf_regrid.esmf_regrid.schemes.ESMFAreaWeightedRegridder`.""" + def setup_cache(self): + """ASV setup_cache method.""" SYNTH_DATA_DIR = Path().cwd() / "tmp_data" SYNTH_DATA_DIR.mkdir(exist_ok=True) file = str(SYNTH_DATA_DIR.joinpath("chunked_cube.nc")) @@ -159,17 +170,20 @@ def setup_cache(self): return regridder, file def setup(self, cache): + """ASV setup method.""" regridder, file = cache self.src = iris.load_cube(file) cube = iris.load_cube(file) self.result = regridder(cube) def time_lazy_regridding(self, cache): + """Benchmark the construction time of the lazy regridding operation.""" assert self.src.has_lazy_data() regridder, _ = cache _ = regridder(self.src) def time_regridding_realisation(self, cache): + """Benchmark the final regridding operation time.""" # Don't touch result.data - permanent realisation plays badly with # ASV's re-run strategy. assert self.result.has_lazy_data() @@ -177,7 +191,10 @@ def time_regridding_realisation(self, cache): class TimeMeshToGridRegridding(TimeRegridding): + """Benchmarks for :class:`~esmf_regrid.esmf_regrid.schemes.MeshToGridESMFRegridder`.""" + def setup(self, tp): + """ASV setup method.""" ( lon_bounds, lat_bounds, @@ -209,7 +226,10 @@ def setup(self, tp): class TimeLazyMeshToGridRegridding: + """Lazy benchmarks for :class:`~esmf_regrid.esmf_regrid.schemes.MeshToGridESMFRegridder`.""" + def setup_cache(self): + """ASV setup_cache method.""" SYNTH_DATA_DIR = Path().cwd() / "tmp_data" SYNTH_DATA_DIR.mkdir(exist_ok=True) file = str(SYNTH_DATA_DIR.joinpath("chunked_cube.nc")) @@ -239,6 +259,7 @@ def setup_cache(self): return regridder, file def setup(self, cache): + """ASV setup method.""" regridder, file = cache with PARSE_UGRID_ON_LOAD.context(): self.src = iris.load_cube(file) @@ -246,11 +267,13 @@ def setup(self, cache): self.result = regridder(cube) def time_lazy_regridding(self, cache): + """Benchmark the construction time of the lazy regridding operation.""" assert self.src.has_lazy_data() regridder, _ = cache _ = regridder(self.src) def time_regridding_realisation(self, cache): + """Benchmark the final regridding operation time.""" # Don't touch result.data - permanent realisation plays badly with # ASV's re-run strategy. assert self.result.has_lazy_data() @@ -258,7 +281,10 @@ def time_regridding_realisation(self, cache): class TimeGridToMeshRegridding(TimeRegridding): + """Benchmarks for :class:`~esmf_regrid.esmf_regrid.schemes.GridToMeshESMFRegridder`.""" + def setup(self, tp): + """ASV setup method.""" ( lon_bounds, lat_bounds, @@ -290,7 +316,10 @@ def setup(self, tp): class TimeLazyGridToMeshRegridding: + """Lazy benchmarks for :class:`~esmf_regrid.esmf_regrid.schemes.GridToMeshESMFRegridder`.""" + def setup_cache(self): + """ASV setup_cache method.""" SYNTH_DATA_DIR = Path().cwd() / "tmp_data" SYNTH_DATA_DIR.mkdir(exist_ok=True) file = str(SYNTH_DATA_DIR.joinpath("chunked_cube.nc")) @@ -317,17 +346,20 @@ def setup_cache(self): return regridder, file def setup(self, cache): + """ASV setup method.""" regridder, file = cache self.src = iris.load_cube(file) cube = iris.load_cube(file) self.result = regridder(cube) def time_lazy_regridding(self, cache): + """Benchmark the construction time of the lazy regridding operation.""" assert self.src.has_lazy_data() regridder, _ = cache _ = regridder(self.src) def time_regridding_realisation(self, cache): + """Benchmark the final regridding operation time.""" # Don't touch result.data - permanent realisation plays badly with # ASV's re-run strategy. assert self.result.has_lazy_data() @@ -335,10 +367,13 @@ def time_regridding_realisation(self, cache): class TimeRegridderIO(MultiGridCompare): + """Benchmarks for regridder saving and loading.""" + params = [MultiGridCompare.params, ["mesh_to_grid", "grid_to_mesh"]] param_names = MultiGridCompare.param_names + ["regridder type"] def setup_cache(self): + """ASV setup_cache method.""" from esmf_regrid.experimental.io import save_regridder SYNTH_DATA_DIR = Path().cwd() / "tmp_data" @@ -395,6 +430,7 @@ def setup_cache(self): return file_dict def setup(self, file_dict, tp, rgt): + """ASV setup method.""" from esmf_regrid.experimental.io import load_regridder, save_regridder self.load_regridder = load_regridder @@ -405,11 +441,14 @@ def setup(self, file_dict, tp, rgt): self.regridder = load_regridder(self.source_file) def teardown(self, _, tp, rgt): + """ASV teardown method.""" if os.path.exists(self.destination_file): os.remove(self.destination_file) def time_save(self, _, tp, rgt): + """Benchmark the saving time.""" self.save_regridder(self.regridder, self.destination_file) def time_load(self, _, tp, rgt): + """Benchmark the loading time.""" _ = self.load_regridder(self.source_file) diff --git a/benchmarks/benchmarks/esmf_regridder/scalability.py b/benchmarks/benchmarks/esmf_regridder/scalability.py index 7500cd59..9e776ff9 100644 --- a/benchmarks/benchmarks/esmf_regridder/scalability.py +++ b/benchmarks/benchmarks/esmf_regridder/scalability.py @@ -3,10 +3,10 @@ import os from pathlib import Path -import numpy as np import dask.array as da import iris from iris.cube import Cube +import numpy as np from esmf_regrid.experimental.io import load_regridder, save_regridder from esmf_regrid.experimental.unstructured_scheme import ( @@ -14,12 +14,13 @@ MeshToGridESMFRegridder, ) from esmf_regrid.schemes import ESMFAreaWeightedRegridder - from .. import on_demand_benchmark, skip_benchmark from ..generate_data import _grid_cube, _gridlike_mesh_cube class PrepareScalabilityMixin: + """Mixin to prepare common arguments for benchmarking the prepare step's scalability.""" + timeout = 180 params = [50, 100, 200, 400, 600, 800] param_names = ["grid width"] @@ -27,40 +28,51 @@ class PrepareScalabilityMixin: regridder = ESMFAreaWeightedRegridder def src_cube(self, n): + """Cube to regrid from.""" lon_bounds = (-180, 180) lat_bounds = (-90, 90) src = _grid_cube(n, n, lon_bounds, lat_bounds) return src def tgt_cube(self, n): + """Cube containing the regridding target grid.""" lon_bounds = (-180, 180) lat_bounds = (-90, 90) grid = _grid_cube(n + 1, n + 1, lon_bounds, lat_bounds) return grid def setup(self, n): + """ASV setup method.""" self.src = self.src_cube(n) self.tgt = self.tgt_cube(n) def _time_prepare(self, n): + """Run the prepare step - this is called by actual benchmarks.""" _ = self.regridder(self.src, self.tgt) @on_demand_benchmark class PrepareScalabilityGridToGrid(PrepareScalabilityMixin): + """Benchmarks for the prepare step of :class:`~esmf_regrid.esmf_regrid.schemes.ESMFAreaWeightedRegridder`.""" + def time_prepare(self, n): + """Benchmark the prepare time.""" super()._time_prepare(n) @on_demand_benchmark class PrepareScalabilityMeshToGrid(PrepareScalabilityMixin): + """Benchmarks for the prepare step of :class:`~esmf_regrid.esmf_regrid.schemes.MeshToGridESMFRegridder`.""" + regridder = MeshToGridESMFRegridder def src_cube(self, n): + """Cube to regrid from.""" src = _gridlike_mesh_cube(n, n) return src def setup_cache(self): + """ASV setup_cache method.""" SYNTH_DATA_DIR = Path().cwd() / "tmp_data" SYNTH_DATA_DIR.mkdir(exist_ok=True) destination_file = str(SYNTH_DATA_DIR.joinpath("dest_rg.nc")) @@ -74,34 +86,43 @@ def setup_cache(self): return file_dict def setup(self, file_dict, n): + """ASV setup method.""" super().setup(n) self.source_file = file_dict[n] self.destination_file = file_dict["destination"] self.rg = load_regridder(self.source_file) def teardown(self, _, n): + """ASV teardown method.""" if os.path.exists(self.destination_file): os.remove(self.destination_file) def time_load(self, _, n): + """Benchmark the loading time.""" load_regridder(self.source_file) def time_save(self, _, n): + """Benchmark the saving time.""" save_regridder(self.rg, self.destination_file) def time_prepare(self, _, n): + """Benchmark the prepare time.""" super()._time_prepare(n) @on_demand_benchmark class PrepareScalabilityGridToMesh(PrepareScalabilityMixin): + """Benchmarks for the prepare step of :class:`~esmf_regrid.esmf_regrid.schemes.GridToMeshESMFRegridder`.""" + regridder = GridToMeshESMFRegridder def tgt_cube(self, n): + """Cube containing the regridding target grid.""" tgt = _gridlike_mesh_cube(n + 1, n + 1) return tgt def setup_cache(self): + """ASV setup_cache method.""" SYNTH_DATA_DIR = Path().cwd() / "tmp_data" SYNTH_DATA_DIR.mkdir(exist_ok=True) destination_file = str(SYNTH_DATA_DIR.joinpath("dest_rg.nc")) @@ -115,26 +136,33 @@ def setup_cache(self): return file_dict def setup(self, file_dict, n): + """ASV setup method.""" super().setup(n) self.source_file = file_dict[n] self.destination_file = file_dict["destination"] self.rg = load_regridder(self.source_file) def teardown(self, _, n): + """ASV teardown method.""" if os.path.exists(self.destination_file): os.remove(self.destination_file) def time_load(self, _, n): + """Benchmark the loading time.""" load_regridder(self.source_file) def time_save(self, _, n): + """Benchmark the saving time.""" save_regridder(self.rg, self.destination_file) def time_prepare(self, _, n): + """Benchmark the prepare time.""" super()._time_prepare(n) class PerformScalabilityMixin: + """Mixin to prepare common arguments for benchmarking the perform step's scalability.""" + params = [100, 200, 400, 600, 800, 1000] param_names = ["height"] grid_size = 400 @@ -148,11 +176,13 @@ class PerformScalabilityMixin: file_name = "chunked_cube.nc" def src_cube(self, height): + """Cube to regrid from.""" data = da.ones([self.grid_size, self.grid_size, height], chunks=self.chunk_size) src = Cube(data) return src def add_src_metadata(self, cube): + """Add appropriate DimCoords from _grid_cube to the given `cube`.""" lon_bounds = (-180, 180) lat_bounds = (-90, 90) grid = _grid_cube(self.grid_size, self.grid_size, lon_bounds, lat_bounds) @@ -161,6 +191,7 @@ def add_src_metadata(self, cube): return cube def tgt_cube(self): + """Cube containing the regridding target grid.""" lon_bounds = (-180, 180) lat_bounds = (-90, 90) grid = _grid_cube( @@ -169,6 +200,7 @@ def tgt_cube(self): return grid def setup_cache(self): + """ASV setup_cache method.""" SYNTH_DATA_DIR = Path().cwd() / "tmp_data" SYNTH_DATA_DIR.mkdir(exist_ok=True) file = str(SYNTH_DATA_DIR.joinpath(self.file_name)) @@ -184,6 +216,7 @@ def setup_cache(self): return rg, file def setup(self, cache, height): + """ASV setup method.""" regridder, file = cache src = iris.load_cube(file)[..., :height] self.src = self.add_src_metadata(src) @@ -194,11 +227,13 @@ def setup(self, cache, height): self.result = regridder(cube) def _time_perform(self, cache, height): + """Run the perform step - this is called by actual benchmarks.""" assert not self.src.has_lazy_data() rg, _ = cache _ = rg(self.src) def _time_lazy_perform(self, cache, height): + """Run the perform step via Dask - this is called by actual benchmarks.""" # Don't touch result.data - permanent realisation plays badly with # ASV's re-run strategy. assert self.result.has_lazy_data() @@ -207,23 +242,31 @@ def _time_lazy_perform(self, cache, height): @on_demand_benchmark class PerformScalabilityGridToGrid(PerformScalabilityMixin): + """Benchmarks for the perform step of :class:`~esmf_regrid.esmf_regrid.schemes.ESMFAreaWeightedRegridder`.""" + def time_perform(self, cache, height): + """Benchmark the perform time.""" super()._time_perform(cache, height) def time_lazy_perform(self, cache, height): + """Benchmark the perform time going via Dask.""" super()._time_lazy_perform(cache, height) @on_demand_benchmark class PerformScalabilityMeshToGrid(PerformScalabilityMixin): + """Benchmarks for the perform step of :class:`~esmf_regrid.esmf_regrid.schemes.MeshToGridESMFRegridder`.""" + regridder = MeshToGridESMFRegridder chunk_size = [PerformScalabilityMixin.grid_size ^ 2, 10] file_name = "chunked_cube_1d.nc" def setup_cache(self): + """ASV setup_cache method.""" return super().setup_cache() def src_cube(self, height): + """Cube to regrid from.""" data = da.ones( [self.grid_size * self.grid_size, height], chunks=self.chunk_size ) @@ -231,6 +274,7 @@ def src_cube(self, height): return src def add_src_metadata(self, cube): + """Add appropriate MeshCoords from _gridlike_mesh to the given `cube`.""" from esmf_regrid.tests.unit.experimental.unstructured_scheme.test__mesh_to_MeshInfo import ( _gridlike_mesh, ) @@ -242,20 +286,26 @@ def add_src_metadata(self, cube): return cube def time_perform(self, cache, height): + """Benchmark the perform time.""" super()._time_perform(cache, height) def time_lazy_perform(self, cache, height): + """Benchmark the perform time going via Dask.""" super()._time_lazy_perform(cache, height) @on_demand_benchmark class PerformScalabilityGridToMesh(PerformScalabilityMixin): + """Benchmarks for the perform step of :class:`~esmf_regrid.esmf_regrid.schemes.GridToMeshESMFRegridder`.""" + regridder = GridToMeshESMFRegridder def setup_cache(self): + """ASV setup_cache method.""" return super().setup_cache() def tgt_cube(self): + """Cube containing the regridding target grid.""" from esmf_regrid.tests.unit.experimental.unstructured_scheme.test__mesh_to_MeshInfo import ( _gridlike_mesh, ) @@ -268,9 +318,11 @@ def tgt_cube(self): return tgt def time_perform(self, cache, height): + """Benchmark the perform time.""" super()._time_perform(cache, height) def time_lazy_perform(self, cache, height): + """Benchmark the perform time going via Dask.""" super()._time_lazy_perform(cache, height) @@ -278,6 +330,8 @@ def time_lazy_perform(self, cache, height): # They can be run by manually removing the skip. @skip_benchmark class PerformScalability1kGridToGrid(PerformScalabilityMixin): + """Large benchmarks for the perform step of :class:`~esmf_regrid.esmf_regrid.schemes.ESMFAreaWeightedRegridder`.""" + timeout = 600 grid_size = 1100 chunk_size = [grid_size, grid_size, 10] @@ -288,12 +342,15 @@ class PerformScalability1kGridToGrid(PerformScalabilityMixin): target_grid_size = 111 def setup_cache(self): + """ASV setup_cache method.""" return super().setup_cache() def time_perform(self, cache, height): + """Benchmark the perform time.""" super()._time_perform(cache, height) def time_lazy_perform(self, cache, height): + """Benchmark the perform time going via Dask.""" super()._time_lazy_perform(cache, height) @@ -301,6 +358,8 @@ def time_lazy_perform(self, cache, height): # They can be run by manually removing the skip. @skip_benchmark class PerformScalability2kGridToGrid(PerformScalabilityMixin): + """Large benchmarks for the perform step of :class:`~esmf_regrid.esmf_regrid.schemes.ESMFAreaWeightedRegridder`.""" + timeout = 600 grid_size = 2200 chunk_size = [grid_size, grid_size, 10] @@ -311,10 +370,13 @@ class PerformScalability2kGridToGrid(PerformScalabilityMixin): target_grid_size = 221 def setup_cache(self): + """ASV setup_cache method.""" return super().setup_cache() def time_perform(self, cache, height): + """Benchmark the perform time.""" super()._time_perform(cache, height) def time_lazy_perform(self, cache, height): + """Benchmark the perform time going via Dask.""" super()._time_lazy_perform(cache, height) diff --git a/benchmarks/benchmarks/generate_data.py b/benchmarks/benchmarks/generate_data.py index 467399bf..bcabac8b 100644 --- a/benchmarks/benchmarks/generate_data.py +++ b/benchmarks/benchmarks/generate_data.py @@ -12,10 +12,10 @@ """ from inspect import getsource -from subprocess import CalledProcessError, check_output, run from os import environ from pathlib import Path import re +from subprocess import CalledProcessError, check_output, run from textwrap import dedent from warnings import warn @@ -104,7 +104,7 @@ def _grid_cube( circular=False, alt_coord_system=False, ): - """Wrapper for calling _grid_cube via :func:`run_function_elsewhere`.""" + """Call _grid_cube via :func:`run_function_elsewhere`.""" def external(*args, **kwargs): """ @@ -162,7 +162,7 @@ def external(*args, **kwargs): def _gridlike_mesh_cube(n_lons, n_lats): - """Wrapper for calling _gridlike_mesh via :func:`run_function_elsewhere`.""" + """Call _gridlike_mesh via :func:`run_function_elsewhere`.""" def external(*args, **kwargs): """