ConfigDict¶
- class mmengine.config.ConfigDict(*args, **kwargs)[source]¶
A dictionary for config which has the same interface as python’s built- in dictionary and can be used as a normal dictionary.
The Config class would transform the nested fields (dictionary-like fields) in config file into
ConfigDict.If the class attribute
lazyisFalse, users will get the object built byLazyObjectorLazyAttr, otherwise users will get theLazyObjectorLazyAttritself.The
lazyshould be set toTrueto avoid building the imported object during configuration parsing, and it should be set to False outside the Config to ensure that users do not experience theLazyObject.- build_lazy(value)[source]¶
If class attribute
lazyis False, the LazyObject will be built and returned.- Parameters:
value (Any) – The value to be built.
- Returns:
The built value.
- Return type:
Any
- copy() a shallow copy of D¶
- get(key, default=None)[source]¶
Get the value of the key. If class attribute
lazyis True, the LazyObject will be built and returned.- Parameters:
key (str) – The key.
default (any, optional) – The default value. Defaults to None.
- Returns:
The value of the key.
- Return type:
Any
- items()[source]¶
Yield the keys and values of the dictionary.
If class attribute
lazyis False, the value ofLazyObjectorLazyAttrwill be built and returned.
- merge(other)[source]¶
Merge another dictionary into current dictionary.
- Parameters:
other (dict) – Another dictionary.
- pop(key, default=None)[source]¶
Pop the value of the key. If class attribute
lazyis True, the LazyObject will be built and returned.- Parameters:
key (str) – The key.
default (any, optional) – The default value. Defaults to None.
- Returns:
The value of the key.
- Return type:
Any
- to_dict()[source]¶
Convert the ConfigDict to a normal dictionary recursively, and convert the
LazyObjectorLazyAttrto string.