Skip to content

Commit

Permalink
refactor: register default ngen plugins in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
aaraney committed Aug 15, 2024
1 parent 29b1bfb commit b9103c8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions python/ngen_cal/src/ngen/cal/ngen.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from .parameter import Parameter, Parameters
from .calibration_cathment import CalibrationCatchment, AdjustableCatchment
from .calibration_set import CalibrationSet, UniformCalibrationSet
from .ngen_hooks.ngen_output import TrouteOutput
#HyFeatures components
from hypy.hydrolocation import NWISLocation
from hypy.nexus import Nexus
Expand Down Expand Up @@ -67,6 +66,7 @@ def _map_params_to_realization(params: Mapping[str, Parameters], realization: Re
else:
return _params_as_df(params, module.model_name)


class NgenBase(ModelExec):
"""
Data class specific for Ngen
Expand Down Expand Up @@ -113,10 +113,10 @@ def __init__(self, **kwargs):
#Let pydantic work its magic
super().__init__(**kwargs)
#now we work ours
# Register the default ngen output hook
self._plugin_manager.register(TrouteOutput(self.routing_output))
#Make a copy of the config file, just in case
shutil.copy(self.realization, str(self.realization)+'_original')

self._register_default_ngen_plugins()

# Read the catchment hydrofabric data
if self.hydrofabric is not None:
Expand All @@ -132,6 +132,12 @@ def __init__(self, **kwargs):
data = json.load(fp)
self.ngen_realization = NgenRealization(**data)

def _register_default_ngen_plugins(self):
from .ngen_hooks.ngen_output import TrouteOutput

# t-route outputs
self._plugin_manager.register(TrouteOutput(self.routing_output))

@staticmethod
def _is_legacy_gpkg_hydrofabric(hydrofabric: Path) -> bool:
"""Return True if legacy (<=v2.1) gpkg hydrofabric."""
Expand Down

0 comments on commit b9103c8

Please sign in to comment.