def on_update(self, changes): from taucmdr.error import ImmutableRecordError from taucmdr.model.experiment import Experiment expr_ctrl = Experiment.controller(self.storage) found = expr_ctrl.search({'application': self.eid}) using_app = [expr['name'] for expr in found if expr.data_size() > 0] if using_app: raise ImmutableRecordError( "Application '%s' cannot be modified because " "it is used by these experiments: %s" % (self['name'], ', '.join(using_app))) for expr in found: try: expr.verify() except IncompatibleRecordError as err: raise ConfigurationError( "Changing application '%s' in this way will create an invalid condition " "in experiment '%s':\n %s." % (self['name'], expr['name'], err), "Delete experiment '%s' and try again." % expr['name']) if self.is_selected(): for attr, change in changes.iteritems(): if self.attributes[attr].get('rebuild_required'): self.controller(self.storage).push_to_topic( 'rebuild_required', {attr: change})
def on_update(self, changes): from taucmdr.error import ImmutableRecordError from taucmdr.model.experiment import Experiment expr_ctrl = Experiment.controller() found = expr_ctrl.search({'target': self.eid}) used_by = [expr['name'] for expr in found if expr.data_size() > 0] if used_by: raise ImmutableRecordError( "Target '%s' cannot be modified because " "it is used by these experiments: %s" % (self['name'], ', '.join(used_by))) for expr in found: try: expr.verify() except IncompatibleRecordError as err: raise ConfigurationError( "Changing measurement '%s' in this way will create an invalid condition " "in experiment '%s':\n %s." % (self['name'], expr['name'], err), "Delete experiment '%s' and try again." % expr['name']) if self.is_selected(): for attr, change in changes.iteritems(): props = self.attributes[attr] if props.get('rebuild_required'): if props.get('model', None) == Compiler: old_comp = Compiler.controller(self.storage).one( change[0]) new_comp = Compiler.controller(self.storage).one( change[1]) message = {attr: (old_comp['path'], new_comp['path'])} else: message = {attr: change} self.controller(self.storage).push_to_topic( 'rebuild_required', message)
def delete(self, keys, context=True): # pylint: disable=unexpected-keyword-arg from taucmdr.error import ImmutableRecordError from taucmdr.model.experiment import Experiment changing = self.search(keys, context=context) for model in changing: expr_ctrl = Experiment.controller() found = expr_ctrl.search({'measurement': model.eid}) used_by = [expr['name'] for expr in found if expr.data_size() > 0] if used_by: raise ImmutableRecordError( "Measurement '%s' cannot be modified because " "it is used by these experiments: %s" % (model['name'], ', '.join(used_by))) return super(MeasurementController, self).delete(keys)
def on_update(self, changes): from taucmdr.error import ImmutableRecordError from taucmdr.model.experiment import Experiment expr_ctrl = Experiment.controller() found = expr_ctrl.search({'measurement': self.eid}) used_by = [expr['name'] for expr in found if expr.data_size() > 0] if used_by: raise ImmutableRecordError( "Measurement '%s' cannot be modified because " "it is used by these experiments: %s" % (self['name'], ', '.join(used_by))) for expr in found: try: expr.verify() except IncompatibleRecordError as err: raise ConfigurationError( "Changing measurement '%s' in this way will create an invalid condition " "in experiment '%s':\n %s." % (self['name'], expr['name'], err), "Delete experiment '%s' and try again." % expr['name']) self._check_select_file() self._check_metrics() if self.is_selected(): for attr, change in changes.iteritems(): if self.attributes[attr].get('rebuild_required'): if attr == 'metrics': old_value, new_value = change old_papi = [ metric for metric in old_value if 'PAPI' in metric ] new_papi = [ metric for metric in new_value if 'PAPI' in metric ] if bool(old_papi) != bool(new_papi): self.controller(self.storage).push_to_topic( 'rebuild_required', {attr: change}) else: self.controller(self.storage).push_to_topic( 'rebuild_required', {attr: change})