-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean_data.py
41 lines (37 loc) · 1.38 KB
/
clean_data.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
import os
import sys
import shutil
from config_file import config
def clean(config):
length = len(config['clean_list'])
count = 0
for i in range(length):
cp_dir = config['record config']['checkpoint_basic_dir'] + \
config['clean_list'][i]
log_dir = config['record config']['log_basic_dir'] + \
config['clean_list'][i]
excel_dir = config['record config']['excel_basic_dir'] + \
config['clean_list'][i]
config_dir = config['record config']['config_basic_dir'] + \
config['clean_list'][i]
if os.path.exists(log_dir):
print('-' * 10 + str(i) + '-' * 10)
print('C.L.E.A.N : {0}'.format(config['clean_list'][i]))
try:
shutil.rmtree(log_dir)
print('remove LOG success.')
shutil.rmtree(cp_dir)
print('remove CHECKPOINT success.')
shutil.rmtree(config_dir)
print('remove CONFIG success.')
shutil.rmtree(excel_dir)
print('remove EXCEL success.')
count += 1
except Exception as e:
print(e)
sys.exit()
else:
print('{0} is not exist, please check and run again...'.format(
config['clean_list'][i]))
print(f'total: {length}, clean: {count}')
clean(config)