@@ -44,7 +44,7 @@ class ConfigParser:
44
44
# in the example $@my_dims + 1 is an expression, which adds 1 to the value of @my_dims
45
45
parser = ConfigParser(config)
46
46
47
- # get/set configuration content
47
+ # get/set configuration content, the set method should happen before calling parse()
48
48
print(parser["my_net"]["<args>"]["in_channels"]) # original input channels 1
49
49
parser["my_net"]["<args>"]["in_channels"] = 4 # change input channels to 4
50
50
print(parser["my_net"]["<args>"]["in_channels"])
@@ -117,7 +117,8 @@ def __getitem__(self, id: Union[str, int]):
117
117
118
118
def __setitem__ (self , id : Union [str , int ], config : Any ):
119
119
"""
120
- Set config by ``id``.
120
+ Set config by ``id``. Note that this method should be used before ``parse()`` or ``get_parsed_content()``
121
+ to ensure the updates are included in the parsed content.
121
122
122
123
Args:
123
124
id: id of the ``ConfigItem``, ``"#"`` in id are interpreted as special characters to
@@ -164,8 +165,6 @@ def set(self, config: Any, id: str = ""):
164
165
def _do_parse (self , config , id : str = "" ):
165
166
"""
166
167
Recursively parse the nested data in config source, add every item as `ConfigItem` to the resolver.
167
- Note that the configuration content of every `ConfigItem` will be decoupled from the config source
168
- of parser during parsing.
169
168
170
169
Args:
171
170
config: config source to parse.
@@ -210,9 +209,6 @@ def get_parsed_content(self, id: str = "", **kwargs):
210
209
- If the item is ``ConfigExpression`` and ``eval_expr=True``, the result is the evaluated output.
211
210
- Else, the result is the configuration content of `ConfigItem`.
212
211
213
- Note that the configuration content of every `ConfigItem` is decoupled from the config source of parser
214
- during parsing.
215
-
216
212
Args:
217
213
id: id of the ``ConfigItem``, ``"#"`` in id are interpreted as special characters to
218
214
go one level further into the nested structures.
0 commit comments