From b9103c8018fcea3222c7d4f4d9879b3683d5b903 Mon Sep 17 00:00:00 2001 From: Austin Raney Date: Mon, 5 Aug 2024 12:02:52 -0400 Subject: [PATCH] refactor: register default ngen plugins in one place --- python/ngen_cal/src/ngen/cal/ngen.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/python/ngen_cal/src/ngen/cal/ngen.py b/python/ngen_cal/src/ngen/cal/ngen.py index 661d92c9..68822bcb 100644 --- a/python/ngen_cal/src/ngen/cal/ngen.py +++ b/python/ngen_cal/src/ngen/cal/ngen.py @@ -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 @@ -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 @@ -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: @@ -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."""