dmlcloud.obj_from_cfg
- dmlcloud.obj_from_cfg(config, *args, **kwargs)
Creates an object from a configuration dictionary or a string.
This is equivalent to calling factory_from_cfg(config)(*args, **kwargs).
If a string is provided, it is assumed to be the path to the object (class). If a dictionary is provided, it must contain a “factory” key with the path to the object.
Additional keys in the dictionary are passed as keyword arguments to the object constructor.
- Parameters:
config (Mapping | str) – Configuration dictionary or string with the path to the object.
*args – Additional positional arguments to pass to the object constructor.
**kwargs – Additional keyword arguments to pass to the object constructor.
- Returns:
The created object.
- Return type:
Any
- Raises:
ImportError – If the object cannot be imported.
KeyError – If the configuration dictionary does not contain the “factory” key.
Example
>>> dml.obj_from_cfg('datetime.date', 2025, month=1, day=1) datetime.date(2025, 1, 1)