Skip to content

Commit 3738057

Browse files
committed
simplify code structure
1 parent bec301f commit 3738057

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

graph_net/analysis_util.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ def detect_sample_status(log_text: str) -> str:
4343
shape_match = True
4444
elif "[DataType]" in line and "match:True" in line:
4545
type_match = True
46+
else:
47+
# Do nothing
48+
pass
4649

4750
if any("Exception:" in line or "Error:" in line for line in lines):
4851
runtime_fail = True
@@ -166,31 +169,30 @@ def parse_logs_to_data(log_file: str) -> list:
166169

167170
samples, current_lines, processing_lines = [], [], []
168171

169-
for line in lines:
170-
if "[Processing]" in line:
171-
if current_lines: # Process previous sample
172-
data = parse_single_sample_log_to_data(current_lines)
173-
# Find matching processing line for model_path
174-
for p_line in processing_lines:
175-
if data.get("configuration", {}).get("model") in p_line:
176-
data["model_path"] = p_line.split()[-1]
177-
break
178-
samples.append(data)
179-
180-
processing_lines.append(line)
181-
current_lines = [line]
182-
elif current_lines:
183-
current_lines.append(line)
184-
185-
# Process final sample
186-
if current_lines:
172+
def process_a_sample():
187173
data = parse_single_sample_log_to_data(current_lines)
188174
for p_line in processing_lines:
189175
if data.get("configuration", {}).get("model") in p_line:
190176
data["model_path"] = p_line.split()[-1]
191177
break
192178
samples.append(data)
193179

180+
for line in lines:
181+
if not "[Processing]" in line:
182+
if current_lines:
183+
current_lines.append(line)
184+
continue
185+
186+
if current_lines:
187+
process_a_sample()
188+
189+
processing_lines.append(line)
190+
current_lines = [line]
191+
192+
# Process final sample
193+
if current_lines:
194+
process_a_sample()
195+
194196
print(f"Parsed {len(samples)} samples from {log_file}")
195197
return samples
196198

0 commit comments

Comments
 (0)