From ead9c1e0237063db120faae7936f9f907531eeb5 Mon Sep 17 00:00:00 2001 From: su530201 <olivier.kaufmann@umons.ac.be> Date: Fri, 16 Jun 2023 18:07:38 +0200 Subject: [PATCH] Adds plot_exec_log in test --- ohmpi/utils.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ohmpi/utils.py b/ohmpi/utils.py index 2a5e5274..64fa8406 100644 --- a/ohmpi/utils.py +++ b/ohmpi/utils.py @@ -4,6 +4,7 @@ import shutil import collections.abc import numpy as np + def update_dict(d, u): """Updates a dictionary by adding elements to collection items associated to existing keys @@ -61,18 +62,23 @@ def change_config(config_file, verbose=True): except Exception as error: print(f'Could not change config file to {pwd}/{config_file}:\n{error}') + def parse_log(log): msg_started = False msg_tmp = '' s = 0 with open(log, "r") as file: time, process_id, msg, tag, session = [], [], [], [], [] - for i,line in enumerate(file): + for i, line in enumerate(file): if len(line.split(" | ")) > 1: time.append(line.split(" | ")[0]) process_id.append(line.split(" | ")[1]) msg.append(":".join(line.split(" | ")[2].split(":")[1:])) tag.append(line.split(" | ")[2].split(":")[0]) + if tag[i] == 'INFO': + if 'NEW SESSION' in msg[i]: + s += 1 + session.append(s) elif "{" in line or msg_started: msg_tmp = msg_tmp + line print(msg_tmp) @@ -81,13 +87,10 @@ def parse_log(log): msg[-1] = msg[-1] + msg_tmp msg_tmp = '' msg_started = False - if tag[i] == 'INFO': - if 'NEW SESSION' in msg[i]: - s+=1 - session.append(s) + time = np.array(time) process_id = np.array(process_id) tag = np.array(tag) msg = np.array(msg) session = np.array(session) - return time, process_id, tag, msg, session \ No newline at end of file + return time, process_id, tag, msg, session -- GitLab