44from . import commands
55from . import logger
66
7- import argparse , os , warnings , json , logging
7+ import argparse , os , warnings , json
88from types import SimpleNamespace
99from pathlib import Path
1010from sys import argv
1111from importlib import import_module
12- from ngcsimlib .configManager import GlobalConfig
12+ from ngcsimlib .configManager import init_config , get_config
1313
1414from pkg_resources import get_distribution
1515
1616__version__ = get_distribution ('ngcsimlib' ).version ## set software version
1717
1818
1919###### Preload Modules
20- def preload ():
21- parser = argparse .ArgumentParser (description = 'Build and run a model using ngclearn' )
22- parser .add_argument ("--modules" , type = str , help = 'location of modules.json file' )
23-
24- ## ngc-sim-lib only cares about --modules argument
25- args , unknown = parser .parse_known_args () # args = parser.parse_args()
26- try :
27- module_path = args .modules
28- except :
29- module_path = None
30-
31- if module_path is None :
32- module_config = GlobalConfig .get_config ("modules" )
33- if module_config is None :
34- module_path = "json_files/modules.json"
35- else :
36- module_path = module_config .get ("module_path" , "json_files/modules.json" )
20+ def preload_modules ():
21+ module_config = get_config ("modules" )
22+ if module_config is None :
23+ module_path = "json_files/modules.json"
24+ else :
25+ module_path = module_config .get ("module_path" , "json_files/modules.json" )
3726
3827 if not os .path .isfile (module_path ):
3928 warnings .warn ("\n Missing file to preload modules from. Attempted to locate file at \" " + str (module_path ) +
@@ -79,7 +68,7 @@ def configure():
7968 "\n See PUT LINK HERE for additional information" )
8069 return
8170
82- GlobalConfig . init_config (config_path )
71+ init_config (config_path )
8372
8473
8574
@@ -88,6 +77,5 @@ def configure():
8877 if "readthedocs" not in argv [0 ]: ## prevent readthedocs execution of preload
8978 configure ()
9079 logger .init_logging ()
91-
92- preload ()
80+ preload_modules ()
9381
0 commit comments