Skip to content

Commit 415cc59

Browse files
authored
Update extract_logs.py
1 parent 0302eb6 commit 415cc59

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

dev/extract_logs.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,29 @@ def extract_log_info_and_generate_csv(log_file_path, output_csv_path, target_dir
3737

3838
previous_task = [task_name, partial_task_path, None] # Placeholder for the next time_to_complete
3939

40-
# Ensure the last task is also included
4140
if previous_task:
4241
previous_task[2] = time_to_complete if time_to_complete else 'N/A'
4342
data.append(previous_task)
4443

45-
# Convert time strings to seconds for sorting
4644
for row in data:
4745
if row[2] != 'N/A':
4846
row[2] = convert_time_to_seconds(row[2])
4947

50-
# Sort the data by time (now in seconds)
5148
data.sort(key=lambda x: x[2], reverse=True)
5249

53-
# Convert times back to original string format
5450
for row in data:
5551
if isinstance(row[2], float):
5652
row[2] = f'{int(row[2] // 3600):02}:{int((row[2] % 3600) // 60):02}:{row[2] % 60:.3f}'
5753

58-
# Write the sorted data to a CSV file
5954
with open(output_csv_path, 'w', newline='') as csvfile:
6055
csvwriter = csv.writer(csvfile)
6156
csvwriter.writerow(['Task Name', 'Task Path', 'Time to Complete'])
6257
csvwriter.writerows(data)
6358

6459
print(f"Data extracted, sorted, and saved to {output_csv_path}")
60+
61+
log_file_path = './RL9-ofed-fatimage-177.txt' # Input workflow log name
62+
output_csv_path = 'RL9-ofed-fatimage-177.csv' # Output CSV name
63+
target_directory = '/ansible/' # Shared directory for task path
6564

66-
# File paths
67-
log_file_path = './RL9-ofed-fatimage-177.txt'
68-
output_csv_path = 'RL9-ofed-fatimage-177.csv'
69-
target_directory = '/ansible/'
70-
71-
# Run the function
7265
extract_log_info_and_generate_csv(log_file_path, output_csv_path, target_directory)

0 commit comments

Comments
 (0)