-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcleanup.py
30 lines (27 loc) · 907 Bytes
/
cleanup.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
import os
import re
import shutil
# initial cleanup - delete all working files in case of crash recovery
reg_compile = re.compile(r"^\d{1,3}-\d{1,3}-\d{1,3}-\d{1,3}$")
for root, dirnames, filenames in os.walk("."):
for filename in filenames:
if filename.startswith("gpujob.zip_"):
os.remove(filename)
for dir in dirnames:
if reg_compile.match(dir):
shutil.rmtree(dir)
re_uuid = re.compile(r'[0-9a-f]{32}', re.I)
for root, dirnames, filenames in os.walk("."):
for dir in dirnames:
if re_uuid.match(dir):
shutil.rmtree(dir)
re_gz = re.compile(r'.*.tar.gz.*', re.I)
for root, dirnames, filenames in os.walk("."):
for file in filenames:
if re_gz.match(file):
os.remove(file)
for i in range(24):
os.system(f"rm -rf ./{i}")
os.system(f"rm -rf ./save")
os.system(f"rm -rf ./stats")
os.system(f"rm ./shard.wat")