-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
60 lines (46 loc) · 1.43 KB
/
test.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import argparse
import os
import random
import numpy as np
import torch
import configs
import datasets
from ibydmt.tester import ConceptTester
def setup_logging(level):
import logging
formatter = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logging.root.setLevel(level)
loggers = [
logging.getLogger(name)
for name in logging.root.manager.loggerDict
if "ibydmt" in name
]
for logger in loggers:
logger.setLevel(level)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(formatter)
logging.root.addHandler(stream_handler)
def config():
parser = argparse.ArgumentParser()
parser.add_argument("--config_name", type=str)
parser.add_argument("--test_type", type=str)
parser.add_argument("--concept_type", type=str)
parser.add_argument(
"--workdir", type=str, default=os.path.dirname(os.path.realpath(__file__))
)
parser.add_argument("--log_level", type=str, default="INFO", help="Logging")
return parser.parse_args()
def main(args):
config_name = args.config_name
test_type = args.test_type
concept_type = args.concept_type
workdir = args.workdir
log_level = args.log_level
setup_logging(log_level)
tester = ConceptTester(config_name)
tester.test(test_type, concept_type, workdir=workdir)
if __name__ == "__main__":
args = config()
main(args)