22 """Module which defines ConfigOverrides class and related methods. 25 __all__ = [
"ConfigOverrides"]
34 """Defines a set of overrides to be applied to a task config. 36 Overrides for task configuration need to be applied by activator when 37 creating task instances. This class represents an ordered set of such 38 overrides which activator receives from some source (e.g. command line 39 or some other configuration). 43 addFileOverride(filename) 44 Add overrides from a specified file. 45 addValueOverride(field, value) 46 Add override for a specific field. 48 Apply all overrides to a `config` instance. 52 Serialization support for this class may be needed, will add later if 60 """Add overrides from a specified file. 65 Path to the override file. 70 """Add override for a specific field. 72 This method is not very type-safe as it is designed to support 73 use cases where input is given as string, e.g. command line 74 activators. If `value` has a string type and setting of the field 75 fails with `TypeError` the we'll attempt `eval()` the value and 76 set the field with that value instead. 81 Fully-qualified field name. 83 Value to be given to a filed. 88 """Add keys and values to be used in formatting config nameTemplates 90 This method takes in a dictionary in the format of key:value which 91 will be used to format fields in all of the nameTemplates found in 92 a config object. I.E. a nameDictString = {'input': 'deep'} would be 93 used to format a nameTemplate of "{input}CoaddDatasetProduct". 98 a python dict used in formatting nameTemplates 103 """Apply all overrides to a task configuration object. 107 config : `pex.Config` 111 `Exception` is raised if operations on configuration object fail. 115 config.load(override)
116 elif otype ==
'value':
117 field, value = override
118 field = field.split(
'.')
121 for attr
in field[:-1]:
122 obj = getattr(obj, attr)
129 if isinstance(value, str)
and obj._fields[field[-1]].dtype
is not str:
132 value = ast.literal_eval(value)
138 setattr(obj, field[-1], value)
139 elif otype ==
'namesDict':
140 if not isinstance(config, PipelineTaskConfig):
142 "with a ConfigClass that is a subclass of " 143 "PipelineTaskConfig")
144 config.formatTemplateNames(override)
def addDatasetNameSubstitution(self, nameDict)
def applyTo(self, config)
def addFileOverride(self, filename)
Reports errors that are due to events beyond the control of the program.
def addValueOverride(self, field, value)