-
Notifications
You must be signed in to change notification settings - Fork 56
/
run_fp.py
40 lines (34 loc) · 1.2 KB
/
run_fp.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
from os import chdir
import subprocess
import argparse
from parse_config import *
fpCommand= 'python gen_fp.py %s'
idxCommand = 'python global_index.py %s'
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config',
help='name of the global config file', default='config.json')
args = parser.parse_args()
config = parse_json(args.config)
# Get fingerprint parameter files
fp_params = []
param_dir = "../" + config["io"]["fp_param_dir"]
fp_params = [param_dir + f for f in config["io"]["fp_params"]]
# Fingerprinting
chdir('fingerprint')
for param in fp_params:
print("Fingerprinting %s" % param)
process = subprocess.Popen((fpCommand % (param)),
stdout=subprocess.PIPE, shell=True)
output, error = process.communicate()
print(output.decode('UTF-8'))
# Generate global index
idx_dir = get_global_index_dir(config)
print("Writing global index to %s" % idx_dir)
idx_config = {"index_folder": "../" + idx_dir,
"fp_param_dir": param_dir,
"fp_params": fp_params}
idx_config_fname = param_dir + "global_indices.json"
process = subprocess.Popen((idxCommand % (idx_config_fname)),
stdout=subprocess.PIPE, shell=True)
output, error = process.communicate()