Skip to content

Commit ee34ef0

Browse files
committed
Updates to lessons
1 parent 2904040 commit ee34ef0

File tree

2 files changed

+34
-182
lines changed

2 files changed

+34
-182
lines changed

docs/tutorials/model_basics/configuration.md

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
1-
# Lesson 1: Configuring ngcsimlib
1+
# Lesson 1: Configuring NGC-Sim-Lib
22

33
## Basics
44

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`.
610

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 <a href="../model_basics/json_modules.html">modules.json</a>.
17-
18-
> Example Modules
19-
>
20-
> ```json
21-
> {
22-
> "modules": {
23-
> "module_path": "custom/path/to/json/files/modules.json"
24-
> }
25-
> }
26-
> ```
11+
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.
2715

2816
### Logging
2917

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.
3127

3228
> Default Config
3329
> ```json
3430
> {
3531
> "logging": {
36-
> "logging_level": "WARNING",
32+
> "logging_level": "ERROR",
3733
> "hide_console": false
3834
> }
3935
> }
@@ -52,21 +48,31 @@ The logging configuration mechanism sets up and controls the instance of the pyt
5248
5349
## Using a Configuration
5450
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.
5655
5756
> Example get_config
5857
>```python
59-
>from ngcsimlib.configManager import get_config
58+
>from ngclearn import get_config
6059
>
6160
>loggerConfig = get_config("logger")
6261
>level = loggerConfig['logging_level']
6362
>```
6463
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.
6672
6773
> Example provide_namespace
6874
> ```python
69-
> from ngcsimlib.configManager import provide_namespace
75+
> from ngclearn import provide_namespace
7076
>
7177
> loggerConfig = provide_namespace("logger")
7278
> level = loggerConfig.logging_level

docs/tutorials/model_basics/json_modules.md

Lines changed: 0 additions & 154 deletions
This file was deleted.

0 commit comments

Comments
 (0)