[d986f2]: / check_config.py

Download this file

34 lines (24 with data), 813 Bytes

 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
import sys
import subprocess
import os
import pickle
import json
import importlib.util
def write_config_params(config_path):
cf_file = import_module('cf_file',config_path)
cf = cf_file.configs(None)
print ("Root Dir: "+cf.root_dir)
def import_module(name, path):
"""
correct way of importing a module dynamically in python 3.
:param name: name given to module instance.
:param path: path to module.
:return: module: returned module instance.
"""
spec = importlib.util.spec_from_file_location(name, path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
if __name__ == "__main__":
config_path = '/home/marinb02/mdtk/medicaldetectiontoolkit/experiments/toy_exp/configs.py'
write_config_params(config_path)