22 """Module which defines ConfigOverrides class and related methods. 25 __all__ = [
"ConfigOverrides"]
32 """Defines a set of overrides to be applied to a task config. 34 Overrides for task configuration need to be applied by activator when 35 creating task instances. This class represents an ordered set of such 36 overrides which activator receives from some source (e.g. command line 37 or some other configuration). 41 addFileOverride(filename) 42 Add overrides from a specified file. 43 addValueOverride(field, value) 44 Add override for a specific field. 46 Apply all overrides to a `config` instance. 50 Serialization support for this class may be needed, will add later if 58 """Add overrides from a specified file. 63 Path to the override file. 68 """Add override for a specific field. 70 This method is not very type-safe as it is designed to support 71 use cases where input is given as string, e.g. command line 72 activators. If `value` has a string type and setting of the field 73 fails with `TypeError` the we'll attempt `eval()` the value and 74 set the field with that value instead. 79 Fully-qualified field name. 81 Value to be given to a filed. 86 """Apply all overrides to a task configuration object. 94 `Exception` is raised if operations on configuration object fail. 99 elif otype ==
'value':
100 field, value = override
101 field = field.split(
'.')
104 for attr
in field[:-1]:
105 obj = getattr(obj, attr)
111 if isinstance(getattr(obj, field[-1]), pexConfig.listField.List)
and isinstance(value, str):
113 value = eval(value, {})
117 raise pexExceptions.RuntimeError(f
"Unable to parse {value} into a valid list")
119 setattr(obj, field[-1], value)
121 if not isinstance(value, str):
124 value = eval(value, {})
125 setattr(obj, field[-1], value)
def applyTo(self, config)
def addFileOverride(self, filename)
def addValueOverride(self, field, value)