Skip to content

Commit 1eb22c6

Browse files
feat(charts): plot rephrasing process
1 parent 4d6b356 commit 1eb22c6

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

charts/plot_rephrase_process.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,34 @@
66
from utils.log import parse_log
77
import plotly.express as px
88

9-
def analyse_log(log_info: dict) -> dict:
9+
def analyse_log(log_info: dict) -> list:
1010
"""
1111
Analyse the log information.
1212
1313
:param log_info
1414
:return
1515
"""
1616
logs = []
17+
current_message = None
18+
1719
for line in log_info:
1820
match = re.search(r'(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}) - (\w+) - (\w+) - (.+)', line)
19-
if not match:
20-
continue
21-
timestamp, logger_name, log_level, message = match.groups()
22-
logs.append({
23-
'timestamp': timestamp,
24-
'logger_name': logger_name,
25-
'log_level': log_level,
26-
'message': message
27-
})
21+
if match:
22+
if current_message:
23+
logs.append(current_message)
24+
25+
timestamp, logger_name, log_level, message = match.groups()
26+
current_message = {
27+
'timestamp': timestamp,
28+
'logger_name': logger_name,
29+
'log_level': log_level,
30+
'message': message
31+
}
32+
elif current_message:
33+
current_message['message'] += '\n' + line.strip()
34+
35+
if current_message:
36+
logs.append(current_message)
2837

2938
logs = [log_item for log_item in logs if log_item['log_level'] == 'INFO']
3039

@@ -67,7 +76,6 @@ async def plot_rephrase_process(stats: list[dict]):
6776
if __name__ == "__main__":
6877
log = parse_log('/home/PJLAB/chenzihong/Project/graphgen/cache/logs/graphgen.log')
6978
data = analyse_log(log)
70-
7179
tokenizer = Tokenizer(model_name='cl100k_base')
7280

7381
for item in tqdm(data):

0 commit comments

Comments
 (0)