diff --git a/wa/framework/configuration/core.py b/wa/framework/configuration/core.py index 05a7f3db..bd80758d 100644 --- a/wa/framework/configuration/core.py +++ b/wa/framework/configuration/core.py @@ -700,8 +700,10 @@ class RunConfiguration(Configuration): meta_pod[cfg_point.name] = pod.pop(cfg_point.name, None) device_config = pod.pop('device_config', None) + augmentations = pod.pop('augmentations', {}) instance = super(RunConfiguration, cls).from_pod(pod) instance.device_config = device_config + instance.augmentations = augmentations for cfg_point in cls.meta_data: cfg_point.set_value(instance, meta_pod[cfg_point.name]) @@ -712,6 +714,7 @@ class RunConfiguration(Configuration): for confpoint in self.meta_data: confpoint.set_value(self, check_mandatory=False) self.device_config = None + self.augmentations = {} def merge_device_config(self, plugin_cache): """ @@ -725,9 +728,15 @@ class RunConfiguration(Configuration): self.device_config = plugin_cache.get_plugin_config(self.device, generic_name="device_config") + def add_augmentation(self, aug): + if aug.name in self.augmentations: + raise ValueError('Augmentation "{}" already added.'.format(aug.name)) + self.augmentations[aug.name] = aug.get_config() + def to_pod(self): pod = super(RunConfiguration, self).to_pod() pod['device_config'] = dict(self.device_config or {}) + pod['augmentations'] = self.augmentations return pod diff --git a/wa/framework/execution.py b/wa/framework/execution.py index 5906ba3f..1819e615 100644 --- a/wa/framework/execution.py +++ b/wa/framework/execution.py @@ -191,6 +191,9 @@ class ExecutionContext(object): def write_job_specs(self): self.run_output.write_job_specs(self.cm.job_specs) + def add_augmentation(self, aug): + self.cm.run_config.add_augmentation(aug) + def get_resource(self, resource, strict=True): result = self.resolver.get(resource, strict) if result is None: diff --git a/wa/framework/instrument.py b/wa/framework/instrument.py index d13f63e7..ced8c620 100644 --- a/wa/framework/instrument.py +++ b/wa/framework/instrument.py @@ -345,6 +345,7 @@ def install(instrument, context): instrument.logger.context = context installed.append(instrument) + context.add_augmentation(instrument) def uninstall(instrument): diff --git a/wa/framework/output_processor.py b/wa/framework/output_processor.py index a08046f3..76654083 100644 --- a/wa/framework/output_processor.py +++ b/wa/framework/output_processor.py @@ -60,6 +60,7 @@ class ProcessorManager(object): self.logger.debug('Installing {}'.format(processor.name)) processor.logger.context = context self.processors.append(processor) + context.add_augmentation(processor) def disable_all(self): for output_processor in self.processors: