diff --git a/CHANGELOG.md b/CHANGELOG.md index 09141a7..71e14e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,4 +45,6 @@ Adding `.finalize()` method - clears up the directory. Especially useful for DA. #### 1.8.1 - Rename `LumpedCamelsForcing` to `CamelsForcing` #### 1.8.2 -- No longer removes config on `finalize`, should be up to user \ No newline at end of file +- No longer removes config on `finalize`, should be up to user +#### 1.8.3 +- Local model: `HBVLocal` also availible in wrapper \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index c6db872..924ea8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ name = "ewatercycle-HBV" description = "Implementation of HBV for eWaterCycle" readme = "README.md" license = "Apache-2.0" -version = "1.8.2" +version = "1.8.3" authors = [ { name = "David Haasnoot", email = "davidhaasnoot@gmail.com" }, ] @@ -32,6 +32,7 @@ dependencies = [ # This registers the plugin such that it is discoverable by eWaterCycle [project.entry-points."ewatercycle.models"] HBV = "ewatercycle_HBV.model:HBV" +HBVLocal= "ewatercycle_HBV.model:HBVLocal" [project.entry-points."ewatercycle.forcings"] HBVForcing = "ewatercycle_HBV.forcing:HBVForcing" diff --git a/src/ewatercycle_HBV/__init__.py b/src/ewatercycle_HBV/__init__.py index 440840d..b468435 100644 --- a/src/ewatercycle_HBV/__init__.py +++ b/src/ewatercycle_HBV/__init__.py @@ -1 +1 @@ -__version__ = "1.8.1" +__version__ = "1.8.3" diff --git a/src/ewatercycle_HBV/model.py b/src/ewatercycle_HBV/model.py index 304acb9..1e1399a 100644 --- a/src/ewatercycle_HBV/model.py +++ b/src/ewatercycle_HBV/model.py @@ -11,8 +11,24 @@ from ewatercycle.forcing import GenericLumpedForcing from ewatercycle_HBV.forcing import HBVForcing # Use custom forcing instead -from ewatercycle.base.model import ContainerizedModel, eWaterCycleModel +from ewatercycle.base.model import ( + ContainerizedModel, + eWaterCycleModel, + LocalModel, + ) from ewatercycle.container import ContainerImage +from bmipy import Bmi +def import_bmi(): + """"Import BMI, raise useful exception if not found""" + try: + from HBV import HBV as HBV_bmi + except ModuleNotFoundError: + msg = ( + "HBV bmi package not found, install using: `pip install HBV`" + ) + raise ModuleNotFoundError(msg) + + return HBV_bmi HBV_PARAMS = ( "Imax", @@ -198,17 +214,18 @@ def finalize(self) -> None: """Perform tear-down tasks for the model. After finalization, the model should not be used anymore. - """ - # remove bmi self._bmi.finalize() del self._bmi - class HBV(ContainerizedModel, HBVMethods): """The HBV eWaterCycle model, with the Container Registry docker image.""" bmi_image: ContainerImage = ContainerImage( "ghcr.io/daafip/hbv-bmi-grpc4bmi:v1.5.0" ) + +class HBVLocal(LocalModel, HBVMethods): + """The HBV eWaterCycle model, with the local BMI.""" + bmi_class: Type[Bmi] = import_bmi()