-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
44 lines (38 loc) · 1.38 KB
/
main.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
import glob
import os
from surrogateGeneration import SurrogateGeneration
import threading
import configparser
# threading
class PipeThread(threading.Thread):
def __init__(self, threadName, subset, sg):
threading.Thread.__init__(self)
self.threadName = threadName
self.subset = subset
self.sg = sg
# process files
def run(self):
print("starting {} with {} files".format(self.threadName, len(self.subset)))
self.sg.collectFiles(self.subset, self.threadName)
print('Exiting {}'.format(self.threadName))
# run surrogate generation for subsets of files
def runSurrogateGeneration(parameters):
sg = SurrogateGeneration(parameters)
files = glob.glob(os.path.join(parameters['settings']['path_input'], '**', '*.ann'), recursive=True)
print('{} files to process'.format(len(files)))
threadNr = int(parameters['settings']['threads'])
threads = []
for i in range(0, threadNr):
thread = PipeThread("Thread-{}".format(str(i)), files[i::threadNr], sg)
thread.start()
threads.append(thread)
for thread in threads:
thread.join()
print('{} files processed'.format(sg.nrFiles))
# get configuration
def getConfig():
config = configparser.ConfigParser()
config.read('param.conf')
return config
if __name__ == '__main__':
runSurrogateGeneration(getConfig())