diff --git a/ohmpi/plots.py b/ohmpi/plots.py index a4b03ac767af5ac7e7b7f47e736ddbdd800c4b32..170ea01af787fccf007c8875022ccd0c07f69fb0 100644 --- a/ohmpi/plots.py +++ b/ohmpi/plots.py @@ -4,10 +4,13 @@ from utils import parse_log from datetime import datetime import matplotlib -def plot_exec_log(exec_log,names=None): - time, process_id, tag, msg = parse_log(exec_log) +def plot_exec_log(exec_log,names=None,last_session=True): + time, process_id, tag, msg, session = parse_log(exec_log) + print(session) + if last_session: + time, process_id, tag, msg = time[session==max(session)], process_id[session==max(session)], tag[session==max(session)], msg[session==max(session)] events = msg[tag == 'EVENT'] - + print(time) category, name, state, time = np.empty(events.shape[0]).astype(str), np.empty(events.shape[0]).astype(str), \ np.empty(events.shape[0]).astype(str), np.empty(events.shape[0]).astype(str) diff --git a/ohmpi/utils.py b/ohmpi/utils.py index 8645e7ad49b1e8148c33752bfe860f60561ebfec..2a5e52742b3a4344c031cd8b4d65b3abbc854414 100644 --- a/ohmpi/utils.py +++ b/ohmpi/utils.py @@ -64,8 +64,9 @@ def change_config(config_file, verbose=True): def parse_log(log): msg_started = False msg_tmp = '' + s = 0 with open(log, "r") as file: - time, process_id, msg, tag = [], [], [], [] + time, process_id, msg, tag, session = [], [], [], [], [] for i,line in enumerate(file): if len(line.split(" | ")) > 1: time.append(line.split(" | ")[0]) @@ -80,9 +81,13 @@ 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) - - return time, process_id, tag, msg \ No newline at end of file + session = np.array(session) + return time, process_id, tag, msg, session \ No newline at end of file