Skip to content

Commit

Permalink
Merge pull request #57 from Daafip/dev
Browse files Browse the repository at this point in the history
Add local model option
  • Loading branch information
Daafip committed Apr 22, 2024
2 parents 30138b0 + fb0d652 commit 6807489
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 longer removes config on `finalize`, should be up to user
#### 1.8.3
- Local model: `HBVLocal` also availible in wrapper
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]" },
]
Expand All @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion src/ewatercycle_HBV/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.8.1"
__version__ = "1.8.3"
25 changes: 21 additions & 4 deletions src/ewatercycle_HBV/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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()

0 comments on commit 6807489

Please sign in to comment.