This repository was archived by the owner on Jul 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessor.py
More file actions
85 lines (77 loc) · 2.05 KB
/
processor.py
File metadata and controls
85 lines (77 loc) · 2.05 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import argparse
from processor.main import main as processor_main
from common.log import log
logger = log.logger()
class InvalidConfigError(Exception):
def __init__(self, config_option_key, err_msg):
super().__init__(
"invalid value for flag '{}': {}".format(
config_option_key, err_msg,
)
)
def parse_args():
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument(
'-i',
dest='index_file',
action='store',
required=True,
type=str,
help='path to index file'
)
parser.add_argument(
'-q',
dest='queries',
action='store',
required=True,
type=str,
help='path to a file with a list of queries to process'
)
parser.add_argument(
'-r',
dest='ranker',
action='store',
required=True,
type=str,
help="['TFIDF' | 'BM25'] ranking function to score documents with"
)
parser.add_argument(
'-log-level',
dest='log_level',
action='store',
required=False,
type=str,
help="logging level"
)
parser.add_argument(
'-parallelism',
dest='parallelism',
action='store',
required=False,
type=int,
help="Maximum number of processes or threads to use"
)
parser.add_argument(
'-benchmarking',
dest='benchmarking',
action='store',
required=False,
type=bool,
help="Print only benchmarking (timing) information"
)
args = parser.parse_args()
return args
def main():
try:
args = parse_args()
if args.log_level != None:
log.set_level(args.log_level)
processor_main(args)
except MemoryError:
sys.stderr.write('\n\nERROR: Memory Exception\n')
sys.exit(1)
except Exception as e:
logger.critical(f"Encountered fatal error: "+
f"{e}", exc_info=True)
if __name__ == "__main__":
main()