Skip to content

Commit

Permalink
use always logger, not print
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-schick committed Feb 24, 2023
1 parent b926b32 commit 1a5628c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mara_pipelines/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ def run():
def exit_contexts(active_contexts: {str: contexts.ExecutionContext}, exception: Exception = None):
for context_alias, context in active_contexts.items():
try:
print(f"exit execution context '{context_alias}'")
logger.log(f"exit execution context '{context_alias}'",
format=logger.Format.ITALICS)
if exception:
context.__exit__(type(exception), exception, exception.__traceback__)
else:
context.__exit__(None, None, None)
except e:
print(f"failed to exit execution context '{context_alias}'. Exception: {e}")
pass
logger.log(f"failed to exit execution context '{context_alias}'.\nException: {e}",
format=logger.Format.ITALICS, is_error=False)

try:
# capture output of print statements and other unplanned output
Expand Down Expand Up @@ -263,7 +264,7 @@ def track_finished_pipelines():
except Exception as e:
event_queue.put(pipeline_events.NodeStarted(
node_path=next_node.path(), start_time=task_start_time, is_pipeline=True))
logger.log(message=f'Could not launch parallel tasks', format=logger.Format.ITALICS,
logger.log(message='Could not launch parallel tasks', format=logger.Format.ITALICS,
is_error=True)
logger.log(message=traceback.format_exc(),
format=pipeline_events.Output.Format.VERBATIM, is_error=True)
Expand Down Expand Up @@ -302,7 +303,7 @@ def track_finished_pipelines():

active_contexts[next_node_context] = new_context
except Exception as e:
logger.log(message=f"Could not initiate execution context", format=logger.Format.ITALICS,
logger.log(message="Could not initiate execution context", format=logger.Format.ITALICS,
is_error=True)
logger.log(message=traceback.format_exc(),
format=pipeline_events.Output.Format.VERBATIM, is_error=True)
Expand Down

0 comments on commit 1a5628c

Please sign in to comment.