kd.konfig

kd.konfig#

[[Source]]

Wrapper around ConfigDict to support auto-complete/type checking.

from kauldron import konfig

with konfig.imports():
  from flax import linen as nn

Inside the konfig.imports() contextmanager, imports are replaced with dummy proxy objects which return konfig.ConfigDict objects when called:

cfg = konfig.ConfigDict()
cfg.model = nn.Dense(features=16)  # `Dense` is actually a `ConfigDict`

cfg.model.features = 32  # ConfigDict can be mutated as usual

Finally, objects are resolved to their actual type with:

cfg = konfig.resolve(cfg)

Symbols#

Module#

kd.konfig._default_values

Default values and configuration.

Class#

kd.konfig.ConfigDict

Wrapper around ConfigDict.

kd.konfig.WithRef

Protocol to better access lazy fields.

Function#

kd.konfig.DEFINE_config_file

Defines flag for ConfigDict.

kd.konfig.imports

Contextmanager which replace import statements by configdicts.

kd.konfig.mock_modules

Contextmanager which replaces list of modules with ConfigDictProxyObjects.

kd.konfig.placeholder

Defines an entry in a ConfigDict that has no value yet.

kd.konfig.ref_copy

One-way recursive copy of the ConfigDict.

kd.konfig.ref_fn

Wrap a function for lazy-evaluation.

kd.konfig.register_aliases

Register module aliases for nicer display.

kd.konfig.register_default_values

Register default values when creating the ConfigDict.

kd.konfig.required

Defines a required attribute in the config that has no value yet.

kd.konfig.resolve

Recursively parses a nested ConfigDict and resolves module constructors.

kd.konfig.set_lazy_imported_modules

Set which modules inside with konfig.imports() will be lazy-imported.

Typing#