Skip to content

Commit a878f10

Browse files
committed
Config/logger inits
Readded the config for simlib. Changed default logging level to error.
1 parent f9e6f28 commit a878f10

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

ngcsimlib/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,28 @@
22
from ngcsimlib._src.process.methodProcess import MethodProcess
33
from ngcsimlib._src.process.jointProcess import JointProcess
44
from ngcsimlib._src.deprecators import deprecated, deprecate_args
5+
from ngcsimlib._src.configManager import init_config
6+
import argparse, os, json
7+
8+
def configure():
9+
parser = argparse.ArgumentParser(description='Build and run a model using ngclearn')
10+
parser.add_argument("--config", type=str, help='location of config.json file')
11+
12+
## ngc-sim-lib only cares about --config argument
13+
args, unknown = parser.parse_known_args() # args = parser.parse_args()
14+
try:
15+
config_path = args.modules
16+
except:
17+
config_path = None
18+
19+
if config_path is None:
20+
config_path = "json_files/config.json"
21+
22+
if not os.path.isfile(config_path):
23+
# warn("Missing configuration file. Attempted to locate file at \"" + str(config_path) +
24+
# "\". Default Config will be used. "
25+
# "\nSee https://ngc-learn.readthedocs.io/en/latest/tutorials/model_basics/configuration.html for "
26+
# "additional information")
27+
return
28+
29+
init_config(config_path)

ngcsimlib/_src/configManager.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
"""
22
ngc libraries have a need for global level configuration which will all be
33
handled here. It will also be possible to add custom configuration sections to
4-
this file with no issues or additional setup. However, the main purpose of these
5-
configurations are not control specific parts of the model but control ngc
6-
libraries at a high level.
4+
this file with no issues or additional setup.
75
"""
86
import json
97
from types import SimpleNamespace

ngcsimlib/_src/logger.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ def init_logging():
7373
loggingConfig = get_config("logging")
7474
if loggingConfig is None:
7575
loggingConfig = {"logging_file": None,
76-
"logging_level": logging.WARNING,
77-
"hide_console": False,
78-
"custom_levels": {"ANALYSIS": 25}}
76+
"logging_level": logging.ERROR,
77+
"hide_console": False}
7978

8079
if loggingConfig.get("custom_levels", None) is not None:
8180
for level_name, level_num in loggingConfig.get("custom_levels",

ngcsimlib/logger/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from ngcsimlib._src.logger import (
22
addLoggingLevel as add_logging_level,
3+
init_logging as init_logging,
34
warn as warn,
45
error as error,
56
critical as critical,

0 commit comments

Comments
 (0)