You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorials/model_basics/configuration.md
+34-28Lines changed: 34 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,39 +1,35 @@
1
-
# Lesson 1: Configuring ngcsimlib
1
+
# Lesson 1: Configuring NGC-Sim-Lib
2
2
3
3
## Basics
4
4
5
-
There are various global configurations that can be made to ngcsimlib, the systems simulation backend for ngc-learn. These include the ability to point to custom locations for the `json_modules` files as well as setting up the logger. In both of these cases, the configuration will generally persist between different models that might be loaded and, thus, it will need to exist outside of the scope of the model's files. To solve this problem, ngcsimlib provides `config.json` as well as the `--config` flag mechanisms.
5
+
There are various global configurations that can be made to NGC-Sim-Lib, the
6
+
systems simulation backend for NGC-Learn. The primary built in use for a
7
+
configuration file is to modify the built-in logger. Generally to control the
8
+
configuration running any script with the flag
9
+
`--config="path/to/your/config.json`.
6
10
7
-
The `config.json` file contains one large json object with sections set up for different parts of the configuration, broke up into sub-objects. There is no limit to the size or the number of these objects, meaning that the user is free to define and use them as they so choose. However, there are some general design principals that govern ngcsimlib that are worth knowing about. Specifically, this mechanism will not configure any parts of individual models. `config.json` configurations should be used to select/generally set up experiments and control global level flags and not to set hyperparameters for models.
8
-
9
-
## Built-in Configurations
10
-
11
-
There are a couple configurations that ngcsimlib will look for while it is initializing. Specifically `modules` and `logging`. While neither of these is needed to get up and running some aspects of ngcsimlib, useful debugging tools such as logging to files and more verbosity are locked behind flags set up here.
12
-
13
-
### Modules
14
-
15
-
The modules configuration only contains one value, `module_path`. This value is the location of the `modules.json`, the model-level/experiments-level configuration file one should be setting up when building their experiments. For additional information for configuring this file please
16
-
see <ahref="../model_basics/json_modules.html">modules.json</a>.
The `config.json` file contains one large json object with sections set up for
12
+
different parts of the configuration, broke up into sub-objects. There is no
13
+
limit to the size or the number of these objects, meaning that the user is free
14
+
to define and use them as they so choose.
27
15
28
16
### Logging
29
17
30
-
The logging configuration mechanism sets up and controls the instance of the python logger built into ngcsimlib. This mechanism (or JSON section) has three values found within it. Specifically, `logging_level`, `logging_file`, and `hide_console`. The logging levels are the same ones built into the python logger and the value words used are either the standard Python string representation of the level or the numeric equivalent. The `logging file`, if defined, is a file that the logger will append all logging messages to for a more permanent history of all messages. Finally, `hide console`, if set to true, will hide all logging output to the console.
18
+
The logging configuration mechanism sets up and controls the instance of the
19
+
python logger built into ngcsimlib. This mechanism (or JSON section) has three
20
+
values found within it. Specifically, `logging_level`, `logging_file`,
21
+
and `hide_console`. The logging levels are the same ones built into the python
22
+
logger and the value words used are either the standard Python string
23
+
representation of the level or the numeric equivalent. The `logging file`, if
24
+
defined, is a file that the logger will append all logging messages to for a
25
+
more permanent history of all messages. Finally, `hide console`, if set to true,
26
+
will hide all logging output to the console.
31
27
32
28
> Default Config
33
29
> ```json
34
30
> {
35
31
> "logging": {
36
-
> "logging_level": "WARNING",
32
+
> "logging_level": "ERROR",
37
33
> "hide_console": false
38
34
> }
39
35
> }
@@ -52,21 +48,31 @@ The logging configuration mechanism sets up and controls the instance of the pyt
52
48
53
49
## Using a Configuration
54
50
55
-
To use a configuration, there are a few options. The first option is to simply use the configuration as a python dictionary. This is done by importing the `get_config` method from `ngcsimlib.configManager` and providing the name of the configuration section to the method.
51
+
To use a configuration, there are a few options. The first option is to simply
52
+
use the configuration as a python dictionary. This is done by importing
53
+
the `get_config` method from `ngclearn` and providing the name of
54
+
the configuration section to the method.
56
55
57
56
> Example get_config
58
57
>```python
59
-
>from ngcsimlib.configManager import get_config
58
+
>from ngclearn import get_config
60
59
>
61
60
>loggerConfig = get_config("logger")
62
61
>level = loggerConfig['logging_level']
63
62
>```
64
63
65
-
The other way you can access a configuration is through a provided namespace. This makes use of python's `SimpleNamespace` to map all the dictionary's key values to properties of an object to be used. One important note about namespaces is that, unlike a python dictionary where the `get` method can be provided a default value for missing keys, namespaces do not have this functionality. Therefore, if keys are missing it has the potential to cause errors. Below is an example of how one could use the namespace for logging configuration.
64
+
The other way you can access a configuration is through a provided namespace.
65
+
This makes use of python's `SimpleNamespace` to map all the dictionary's key
66
+
values to properties of an object to be used. One important note about
67
+
namespaces is that, unlike a python dictionary where the `get` method can be
68
+
provided a default value for missing keys, namespaces do not have this
69
+
functionality. Therefore, if keys are missing it has the potential to cause
70
+
errors. Below is an example of how one could use the namespace for logging
71
+
configuration.
66
72
67
73
> Example provide_namespace
68
74
> ```python
69
-
> from ngcsimlib.configManager import provide_namespace
0 commit comments