Skip to content

Commit

Permalink
change subprocessRuntimePodWrapper to instantiate object from POD arg…
Browse files Browse the repository at this point in the history
…ument passed to init method (#538)

fix abstractenvironmentmanager run method
clean up dead lines in environment_manager
  • Loading branch information
wrongkindofdoctor authored Apr 15, 2024
1 parent 9c30d47 commit c05e9f1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/environment_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,15 @@ def setup(self):
pass

@abc.abstractmethod
def run(self): pass
def run(self, cases: dict, log: logging.log):
pass

@abc.abstractmethod
def tear_down(self): pass


@util.mdtf_dataclass
class SubprocessRuntimePODWrapper(object):
class SubprocessRuntimePODWrapper:
"""Wrapper for :class:`diagnostic.multirunDiagnostic` that adds fields and methods
used by :class:`SubprocessRuntimeManager`.
"""
Expand All @@ -279,6 +280,9 @@ class SubprocessRuntimePODWrapper(object):
env_vars: dict = dataclasses.field(default_factory=dict)
process: typing.Any = dataclasses.field(default=None, init=False)

def __init__(self, pod):
self.pod = pod

def set_pod_env_vars(self, pod, cases: dict):
"""Sets all environment variables for the POD: paths and names of each
variable and coordinate. Raise a :class:`~src.util.exceptions.WormKeyError`
Expand Down Expand Up @@ -338,8 +342,6 @@ def _envvar_format(x):
self.env_vars = {k: _envvar_format(v)
for k, v in self.pod.pod_env_vars.items() if k not in skip_items}

self.pod.pod_env_vars

# append varlist env vars for backwards compatibility with single-run PODs
if len(self.pod.multi_case_dict['CASE_LIST']) == 1:
for case_name, case_info in self.pod.multi_case_dict['CASE_LIST'].items():
Expand Down Expand Up @@ -484,7 +486,7 @@ class SubprocessRuntimeManager(AbstractRuntimeManager):

def __init__(self, pod_dict: dict, config: util.NameSpace, _log: logging.log):
# transfer all pods, even failed ones, because we need to call their
self.pods = [self._PodWrapperClass(pod=p) for p in pod_dict.values()]
self.pods = [self._PodWrapperClass(p) for p in pod_dict.values()]
# init object-level logger
self.env_mgr = self._EnvironmentManagerClass(config, log=_log)

Expand Down

0 comments on commit c05e9f1

Please sign in to comment.