Skip to content
Snippets Groups Projects
Commit 9f9af8e5 authored by lukas leufen's avatar lukas leufen
Browse files

Merge branch 'lukas_issue173_bug_mlair-in-logging' into 'develop'

Resolve "mlair started not appearing"

See merge request toar/mlair!149
parents d6f4c6d8 fb9136eb
No related branches found
No related tags found
4 merge requests!156include current development into release,!155Resolve "new release v0.12.1",!149Resolve "mlair started not appearing",!139Draft: Resolve "KZ filter"
Pipeline #46181 passed
...@@ -92,17 +92,18 @@ class RunEnvironment(object): ...@@ -92,17 +92,18 @@ class RunEnvironment(object):
logger = None logger = None
tracker_list = [] tracker_list = []
def __init__(self): def __init__(self, name=None):
"""Start time tracking automatically and logs as info.""" """Start time tracking automatically and logs as info."""
if RunEnvironment.data_store is None: if RunEnvironment.data_store is None:
RunEnvironment.data_store = DataStoreObject() RunEnvironment.data_store = DataStoreObject()
if RunEnvironment.logger is None: if RunEnvironment.logger is None:
RunEnvironment.logger = Logger() RunEnvironment.logger = Logger()
self.time = TimeTracking() self._name = name if name is not None else self.__class__.__name__
logging.info(f"{self.__class__.__name__} started") self.time = TimeTracking(name=name)
logging.info(f"{self._name} started")
# atexit.register(self.__del__) # atexit.register(self.__del__)
self.data_store.tracker.append({}) self.data_store.tracker.append({})
self.tracker_list.extend([{self.__class__.__name__: self.data_store.tracker[-1]}]) self.tracker_list.extend([{self._name: self.data_store.tracker[-1]}])
def __del__(self): def __del__(self):
""" """
...@@ -114,7 +115,7 @@ class RunEnvironment(object): ...@@ -114,7 +115,7 @@ class RunEnvironment(object):
""" """
if not self.del_by_exit: if not self.del_by_exit:
self.time.stop() self.time.stop()
logging.info(f"{self.__class__.__name__} finished after {self.time}") logging.info(f"{self._name} finished after {self.time}")
self.del_by_exit = True self.del_by_exit = True
# copy log file and clear data store only if called as base class and not as super class # copy log file and clear data store only if called as base class and not as super class
if self.__class__.__name__ == "RunEnvironment": if self.__class__.__name__ == "RunEnvironment":
......
...@@ -15,8 +15,9 @@ class Workflow: ...@@ -15,8 +15,9 @@ class Workflow:
method is sufficient. It must be taken care for inter-stage dependencies, this workflow class only handles the method is sufficient. It must be taken care for inter-stage dependencies, this workflow class only handles the
execution but not the dependencies (workflow would probably fail in this case).""" execution but not the dependencies (workflow would probably fail in this case)."""
def __init__(self): def __init__(self, name=None):
self._registry = OrderedDict() self._registry = OrderedDict()
self._name = name if name is not None else self.__class__.__name__
def add(self, stage, **kwargs): def add(self, stage, **kwargs):
"""Add a new stage with optional kwargs.""" """Add a new stage with optional kwargs."""
...@@ -24,6 +25,6 @@ class Workflow: ...@@ -24,6 +25,6 @@ class Workflow:
def run(self): def run(self):
"""Run workflow embedded in a run environment and according to the stage's ordering.""" """Run workflow embedded in a run environment and according to the stage's ordering."""
with RunEnvironment(): with RunEnvironment(name=self._name):
for stage, kwargs in self._registry.items(): for stage, kwargs in self._registry.items():
stage(**kwargs) stage(**kwargs)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment