-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransfer.py
34 lines (32 loc) · 1.35 KB
/
transfer.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
import os
import sys; sys.path.append('./..')
import pickle
from src.utils import load_pickle
from src.Tree import TreeNode
data_path = '/data/infinity-mirror/pickles'
base_path = '/home/danielgonzalez/repos/infinity-mirror/output/pickles'
for subdir, dirs, files in os.walk(data_path):
tail = subdir[30:]
for file in files:
if 'fast' in file:
infile = os.path.join(data_path, tail, file)
outfile = os.path.join(base_path, tail, file)
print(f'start\t{infile}')
try:
old_root = load_pickle(infile)
new_root = TreeNode(name=old_root.name,\
stats=old_root.stats,\
stats_seq={},\
graph=old_root.graph)
node = new_root
while len(old_root.children) > 0:
old_root = old_root.children[0]
node = TreeNode(name=old_root.name,\
stats=old_root.stats,\
graph=old_root.graph,\
parent=node)
with open(outfile, 'wb') as f:
pickle.dump(new_root, f)
print(f'done\t{outfile}')
except ModuleNotFoundError:
print(f'ERROR: {infile}')