Commit 4b06ed02 authored by Dan Baston's avatar Dan Baston

Allow one config to derive from another

parent e9a60006
Pipeline #76013649 passed with stages
in 22 minutes and 58 seconds
from typing import List, Optional
from config_cfs import CFSConfig
from wsim_workflow import dates
class CFSConfigFast(CFSConfig):
# Skip 6-month, >12-month integration periods:
......@@ -10,7 +13,10 @@ class CFSConfigFast(CFSConfig):
# Use only the first 3 forecast ensemble members:
def forecast_ensemble_members(self, yearmon, *, lag_hours: Optional[int] = None):
return CFSConfig.forecast_ensemble_members(self, yearmon, lag_hours=lag_hours)[:2]
# Forecast out only 3 months instead of 9:
def forecast_targets(self, yearmon):
return dates.get_next_yearmons(yearmon, 3)
config = CFSConfigFast
\ No newline at end of file
......@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function # Avoid bombing in Python 2 before we even hit our version check
from __future__ import print_function # Avoid bombing in Python 2 before we even hit our version check
import sys
......@@ -27,13 +27,33 @@ import argparse
from wsim_workflow import workflow
import importlib
import importlib.util
import types
from importlib.machinery import SourceFileLoader
import sys
def load_module(module):
return importlib.import_module('wsim_workflow.output.{}'.format(module))
def load_config(path, source, derived):
return SourceFileLoader("config", path).load_module().config(source, derived)
dirname = os.path.dirname(path)
# Temporarily add config module directory to the system path
# This feels wrong, but I can't find another method that allows
# one config to derive from another (as config_fast inherits from
# config_cfs)
sys.path.insert(0, dirname)
loader = SourceFileLoader("config", path)
mod = types.ModuleType(loader.name)
loader.exec_module(mod)
sys.path.remove(dirname)
return mod.config(source, derived)
def parse_args(args):
parser = argparse.ArgumentParser('Generate a Makefile for WSIM data processing')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment