src.common.config namespace¶
Submodules¶
src.common.config.cli_parser module¶
src.common.config.global_config module¶
-
class
src.common.config.global_config.
AdvancedConfig
[source]¶ Bases:
object
This class provides “advanced config values” meaning it calculates some values which depend on other cfg values They are calculated here to
keep the configs clean
prevent calculating them multiple times during runtime which should make your code cleaner and improve performance
-
class
src.common.config.global_config.
Dummy
(name)[source]¶ Bases:
object
This is a simple dummy class (mock) which will always return a dummy string for every value its asked for This prevents errors if this applications is run under unusual circumstances (eg doc generation)
- Parameters
name – Name of the class/object this instantiation will replace. eg ‘cfg’
-
src.common.config.global_config.
init
()[source]¶ in the good old times this was a simple import and forget, but this behaviour breaks sphinx :/ Now the config has to be initialized once at start
-
src.common.config.global_config.
merge_config
() → src.common.config.util.Config[source]¶ combines default and user-config and cli arguments
src.common.config.util module¶
-
class
src.common.config.util.
Config
(cfg_dict=None, cfg_text=None, filename=None)[source]¶ Bases:
object
A facility for config and config files. It supports common file formats as configs: python/json/yaml. The interface is the same as a dict object and also allows access config values as attributes. .. rubric:: Example
>>> cfg = Config(dict(a=1, b=dict(b1=[0, 1]))) >>> cfg.a 1 >>> cfg.b {'b1': [0, 1]} >>> cfg.b.b1 [0, 1] >>> cfg = Config.fromfile('tests/data/config/a.py') >>> cfg.filename "/home/kchen/projects/mmcv/tests/data/config/a.py" >>> cfg.item4 'test' >>> cfg "Config [path: /home/kchen/projects/mmcv/tests/data/config/a.py]: " "{'item1': [1, 2], 'item2': {'a': 0}, 'item3': True, 'item4': 'test'}"
-
static
auto_argparser
(description=None)[source]¶ Generate argparser from config file automatically (experimental)
-
property
filename
¶
-
merge_from_dict
(options)[source]¶ Merge list into cfg_dict Merge the dict parsed by MultipleKVAction into this cfg. .. rubric:: Examples
>>> options = {'model.backbone.depth': 50, ... 'model.backbone.with_cp':True} >>> cfg = Config(dict(model=dict(backbone=dict(type='ResNet')))) >>> cfg.merge_from_dict(options) >>> cfg_dict = super(Config, self).__getattribute__('_cfg_dict') >>> assert cfg_dict == dict( ... model=dict(backbone=dict(depth=50, with_cp=True)))
- Parameters
options (dict) – dict of configs to merge from.
-
property
pretty_text
¶
-
property
text
¶
-
static
-
class
src.common.config.util.
DictAction
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶ Bases:
argparse.Action
argparse action to split an argument into KEY=VALUE form on the first = and append to a dictionary. List options should be passed as comma separated values, i.e KEY=V1,V2,V3