-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
51 lines (44 loc) · 1.7 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
45
46
47
48
49
50
51
def main():
import logging
import os
from importlib import import_module
from qsprpred.benchmarks import BenchmarkSettings, BenchmarkRunner
from qsprpred.logs import logger
logger.setLevel(logging.INFO)
if "QSPBENCH_SETTINGS" not in os.environ:
raise ValueError(
"Please set the QSPBENCH_SETTINGS environment "
"variable with an import path to your settings module."
)
settings_module = os.environ["QSPBENCH_SETTINGS"]
os.environ["QSPBENCH_SETTINGS"] = settings_module
settings_module = import_module(settings_module)
settings = BenchmarkSettings(
name=settings_module.NAME,
n_replicas=settings_module.N_REPLICAS,
random_seed=settings_module.SEED,
data_sources=settings_module.DATA_SOURCES,
descriptors=settings_module.DESCRIPTORS,
target_props=settings_module.TARGET_PROPS,
prep_settings=settings_module.DATA_PREPS,
models=settings_module.MODELS,
assessors=settings_module.ASSESSORS,
)
if settings_module.RESET_MODELS and os.path.exists(settings_module.MODELS_DIR):
logger.warning("Resetting models directory.")
import shutil
shutil.rmtree(settings_module.MODELS_DIR)
if settings_module.RESET_MODELS and os.path.exists(settings_module.RESULTS_FILE):
logger.warning("Resetting results file.")
os.remove(settings_module.RESULTS_FILE)
runner = BenchmarkRunner(
settings,
settings_module.N_PROC,
settings_module.DATA_DIR,
settings_module.RESULTS_FILE,
settings_module.GPUS,
)
runner.run(raise_errors=True)
print("Benchmark finished.")
if __name__ == "__main__":
main()