Skip to content

Commit

Permalink
Rename build_recipe() to build_<modelname>_recipe()
Browse files Browse the repository at this point in the history
  • Loading branch information
sverhoeven committed Sep 18, 2023
1 parent df523e9 commit 589515d
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/ewatercycle/plugins/hype/forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _build_recipe(
dataset: Dataset | str | dict,
**model_specific_options
):
return build_recipe(
return build_hype_recipe(
start_year=start_time.year,
end_year=end_time.year,
shape=shape,
Expand Down Expand Up @@ -85,7 +85,7 @@ def to_xarray(self) -> xr.Dataset:
return ds


def build_recipe(
def build_hype_recipe(
start_year: int,
end_year: int,
shape: Path,
Expand Down
4 changes: 2 additions & 2 deletions src/ewatercycle/plugins/lisflood/forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def generate( # type: ignore
# Cannot call super as we want recipe_output not forcing object
start_year = get_time(start_time).year
end_year = get_time(end_time).year
recipe = build_recipe(
recipe = build_lisflood_recipe(
start_year=start_year,
end_year=end_year,
shape=Path(shape),
Expand Down Expand Up @@ -222,7 +222,7 @@ def generate( # type: ignore
return generated_forcing


def build_recipe(
def build_lisflood_recipe(
start_year: int,
end_year: int,
shape: Path,
Expand Down
4 changes: 2 additions & 2 deletions src/ewatercycle/plugins/marrmot/forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _build_recipe(
dataset: Dataset | str | dict,
**model_specific_options,
):
return build_recipe(
return build_marrmot_recipe(
start_year=start_time.year,
end_year=end_time.year,
shape=shape,
Expand Down Expand Up @@ -137,7 +137,7 @@ def to_xarray(self) -> xr.Dataset:
)


def build_recipe(
def build_marrmot_recipe(
start_year: int,
end_year: int,
shape: Path,
Expand Down
4 changes: 2 additions & 2 deletions src/ewatercycle/plugins/pcrglobwb/forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def _build_recipe(
start_time_climatology = model_specific_options["start_time_climatology"]
end_time_climatology = model_specific_options["end_time_climatology"]
extract_region = model_specific_options["extract_region"]
return build_recipe(
return build_pcrglobwb_recipe(
start_year=start_time.year,
end_year=end_time.year,
shape=shape,
Expand All @@ -146,7 +146,7 @@ def _recipe_output_to_forcing_arguments(cls, recipe_output, model_specific_optio
}


def build_recipe(
def build_pcrglobwb_recipe(
start_year: int,
end_year: int,
shape: Path,
Expand Down
4 changes: 2 additions & 2 deletions src/ewatercycle/plugins/wflow/forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _build_recipe(
**model_specific_options
):
extract_region = model_specific_options["extract_region"]
return build_recipe(
return build_wflow_recipe(
start_year=start_time.year,
end_year=end_time.year,
shape=shape,
Expand All @@ -105,7 +105,7 @@ def _recipe_output_to_forcing_arguments(cls, recipe_output, model_specific_optio
}


def build_recipe(
def build_wflow_recipe(
start_year: int,
end_year: int,
shape: Path,
Expand Down
6 changes: 3 additions & 3 deletions tests/plugins/hype/test_forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from esmvalcore.experimental.recipe_output import RecipeOutput

from ewatercycle.base.forcing import FORCING_YAML
from ewatercycle.plugins.hype.forcing import HypeForcing, build_recipe
from ewatercycle.plugins.hype.forcing import HypeForcing, build_hype_recipe
from ewatercycle.testing.helpers import reyamlify


Expand Down Expand Up @@ -154,8 +154,8 @@ def test_with_directory(mock_recipe_run, sample_shape, tmp_path):
assert mock_recipe_run["session"].session_dir == forcing_dir


def test_build_recipe(sample_shape: str):
recipe = build_recipe(
def test_build_hype_recipe(sample_shape: str):
recipe = build_hype_recipe(
dataset="ERA5",
start_year=1990,
end_year=2001,
Expand Down
10 changes: 5 additions & 5 deletions tests/plugins/lisflood/test_forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from esmvalcore.experimental.recipe_output import DataFile, RecipeOutput

from ewatercycle.base.forcing import FORCING_YAML
from ewatercycle.plugins.lisflood.forcing import LisfloodForcing, build_recipe
from ewatercycle.plugins.lisflood.forcing import LisfloodForcing, build_lisflood_recipe
from ewatercycle.testing.helpers import reyamlify


Expand Down Expand Up @@ -240,8 +240,8 @@ def test_load_legacy_forcing(tmp_path):
assert result == expected


def test_build_recipe_with_targetgrid(sample_shape: str):
recipe = build_recipe(
def test_build_lisflood_recipe_with_targetgrid(sample_shape: str):
recipe = build_lisflood_recipe(
dataset="ERA5",
start_year=1990,
end_year=2001,
Expand Down Expand Up @@ -465,8 +465,8 @@ def test_build_recipe_with_targetgrid(sample_shape: str):
assert recipe_as_string == reyamlify(expected)


def test_build_recipe_without_targetgrid(sample_shape: str):
recipe = build_recipe(
def test_build_lisflood_recipe_without_targetgrid(sample_shape: str):
recipe = build_lisflood_recipe(
dataset="ERA5",
start_year=1990,
end_year=2001,
Expand Down
6 changes: 3 additions & 3 deletions tests/plugins/marrmot/test_forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from esmvalcore.experimental.recipe_output import RecipeOutput

from ewatercycle.base.forcing import FORCING_YAML
from ewatercycle.plugins.marrmot.forcing import MarrmotForcing, build_recipe
from ewatercycle.plugins.marrmot.forcing import MarrmotForcing, build_marrmot_recipe
from ewatercycle.testing.helpers import reyamlify


Expand Down Expand Up @@ -240,8 +240,8 @@ def test_load_legacy_forcing(tmp_path):
assert result == expected


def test_build_recipe(sample_shape: str):
recipe = build_recipe(
def test_build_marrmot_recipe(sample_shape: str):
recipe = build_marrmot_recipe(
dataset="ERA5",
start_year=1990,
end_year=2001,
Expand Down
13 changes: 8 additions & 5 deletions tests/plugins/pcrglobwb/test_forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
from esmvalcore.experimental.recipe_output import RecipeOutput

from ewatercycle.base.forcing import FORCING_YAML
from ewatercycle.plugins.pcrglobwb.forcing import PCRGlobWBForcing, build_recipe
from ewatercycle.plugins.pcrglobwb.forcing import (
PCRGlobWBForcing,
build_pcrglobwb_recipe,
)
from ewatercycle.testing.helpers import create_netcdf, reyamlify
from ewatercycle.util import get_extents

Expand Down Expand Up @@ -147,8 +150,8 @@ def test_load_legacy_forcing(tmp_path):
assert result == expected


def test_build_recipe(sample_shape: str):
recipe = build_recipe(
def test_build_pcrglobwb_recipe(sample_shape: str):
recipe = build_pcrglobwb_recipe(
start_year=1990,
end_year=2001,
shape=Path(sample_shape),
Expand Down Expand Up @@ -250,9 +253,9 @@ def test_build_recipe(sample_shape: str):
assert recipe_as_string == reyamlify(expected)


def test_build_recipe_with_region(sample_shape: str):
def test_build_pcrglobwb_recipe_with_region(sample_shape: str):
extents = get_extents(sample_shape, 2)
recipe = build_recipe(
recipe = build_pcrglobwb_recipe(
start_year=1990,
end_year=2001,
shape=Path(sample_shape),
Expand Down
6 changes: 3 additions & 3 deletions tests/plugins/wflow/test_forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from esmvalcore.experimental.recipe_output import RecipeOutput

from ewatercycle.base.forcing import FORCING_YAML
from ewatercycle.plugins.wflow.forcing import WflowForcing, build_recipe
from ewatercycle.plugins.wflow.forcing import WflowForcing, build_wflow_recipe
from ewatercycle.testing.helpers import create_netcdf, reyamlify


Expand Down Expand Up @@ -231,8 +231,8 @@ def test_load_legacy_forcing(tmp_path):
assert result == expected


def test_build_recipe(sample_shape: str):
recipe = build_recipe(
def test_build_wflow_recipe(sample_shape: str):
recipe = build_wflow_recipe(
dataset="ERA5",
start_year=1990,
end_year=2001,
Expand Down

0 comments on commit 589515d

Please sign in to comment.