forked from jugengawande/TSPsolverUsingEvolutionary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean_logs.py
71 lines (57 loc) · 1.8 KB
/
clean_logs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""
This script will delete all the logs generated by running the model.
Args:
a : (ALL)Will delete all log files
s : (SELECT) will delete logs of particular kind. Requires additional 4 boolean arguments
to select logs to delete.
1: Run logs
2: Fitness curve of each runs
3: Exported fitness curve graphs
4: Dataset benchmark records
example : python clean_logs.py s True False False False
"""
import os
import sys
def records():
for records in os.listdir("./logs/"):
if records.endswith('.csv'):
t = "./logs/"+records
os.unlink(t)
def log():
for log in os.listdir("./logs/test_log/"):
if log.endswith('.log'):
s = "./logs/test_log/"+log
os.unlink(s)
def curve():
for curve in os.listdir("./logs/output_curve/"):
if (curve.endswith('.png') or curve.endswith('.svg')):
y = "./logs/output_curve/"+curve
os.unlink(y)
def genfit():
for genfit in os.listdir("./logs/curve_log/"):
if genfit.endswith('.csv'):
j = "./logs/curve_log/"+genfit
os.unlink(j)
if(len(sys.argv) == 2 or len(sys.argv) == 6):
if(sys.argv[1] == 'a'):
print("Cleaned all logs")
records()
log()
curve()
genfit()
elif(sys.argv[1] == 's' and len(sys.argv) == 6 ):
if (sys.argv[2] == 'True'):
print("Cleaned run logs")
log()
if (sys.argv[3] == 'True'):
print("Cleaned generation fitness logs")
genfit()
if (sys.argv[4] == 'True'):
print("Deleted curve exports")
curve()
if (sys.argv[5] == 'True'):
print("Cleaned record logs")
records()
else:
print("Invalid argument")
sys.exit()