Configurable¶
- class omnifig.configurable.Configurable¶
Bases:
AbstractConfigurable
,Modifiable
Mix-in class for objects that can be constructed with a config object.
It is strongly recommended that components and modifiers inherit from this class to seamlessly fill in missing arguments with the config object.
- classmethod init_from_config(config, args=None, kwargs=None, *, silent=None)¶
Constructor to initialize a class informed by the config object config. This will run the usual constructor
__init__
, except any arguments that are missing from the signature will be filled in from the config.- Parameters:
config (
AbstractConfig
) – Config object to useargs (
Optional
[Tuple
]) – Manually specified argumentskwargs (
Optional
[Dict
[str
,Any
]]) – Manually specified keyword argumentssilent (
Optional
[bool
]) – If True, no messages are reported when querying the config object.
- Return type:
Any
- Returns:
The initialized object
- class omnifig.configurable.Certifiable¶
Bases:
Configurable
,AbstractCertifiable
Simple mix-in to make the initialization of classes through the config a two-stage process. The first stage calls the
__init__
method, and then after that is complete, the__certify__
method is called, which can return a new object to replace the original one.Note, that
__certify__
is only called if the object is initialized through the config (e.g. throughpull()
).
- class omnifig.configurable.silent_config_args(*args)¶
Bases:
object
Decorator to silence the config when extracting arguments from the config
- __init__(*args)¶
- class omnifig.configurable.config_aliases(**aliases)¶
Bases:
object
Method decorator to add aliases to the config arguments of a method
- __init__(**aliases)¶
Config aliases to store for the method
- Parameters:
**aliases (
Union
[Sequence
[str
],str
]) – Mapping of aliases: keys should be the name of the argument in the method signature,object. (and the values should be the name of the argument to query in the config) –