Shortcuts

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 lazy is False, users will get the object built by LazyObject or LazyAttr, otherwise users will get the LazyObject or LazyAttr itself.

The lazy should be set to True to 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 the LazyObject.

build_lazy(value)[source]

If class attribute lazy is 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 lazy is 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 lazy is False, the value of LazyObject or LazyAttr will 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 lazy is 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 LazyObject or LazyAttr to string.

update(*args, **kwargs)[source]

Override this method to make sure the LazyObject will not be built during updating.

Return type:

None

values()[source]

Yield the values of the dictionary.

If class attribute lazy is False, the value of LazyObject or LazyAttr will be built and returned.

Read the Docs v: v0.10.4
Versions
latest
stable
v0.10.4
v0.10.3
v0.10.2
v0.10.1
v0.10.0
v0.9.1
v0.9.0
v0.8.5
v0.8.4
v0.8.3
v0.8.2
v0.8.1
v0.8.0
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.0
v0.5.0
v0.4.0
v0.3.0
v0.2.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.