Exemplo n.º 1
0
    def __setitem__(self, key, value):
        from Ganga.GPIDev.Lib.Job.Job import Job
        if key in Job._schema.datadict:
            raise GangaAttributeError(
                '\'%s\' is a reserved key name and cannot be used in the metadata'
                % key)
        if not isinstance(key, str):
            raise GangaAttributeError(
                'Metadata key must be of type \'str\' not %s' % type(key))
        if isinstance(value, GangaObject):
            raise GangaAttributeError(
                'Metadata doesn\'t support nesting of GangaObjects at the moment'
            )

        self.data[key] = value
        self._setDirty()
Exemplo n.º 2
0
 def __getitem__(self, name):
     if name in self.datadict:
         return self.datadict[name]
     else:
         err_str = "Ganga Cannot find: %s in Object: %s" % (name, self.name)
         logger.error(err_str)
         raise GangaAttributeError(err_str)
Exemplo n.º 3
0
 def __init__(self, **kwargs):
     super(ICredentialRequirement, self).__init__()
     for key, value in kwargs.items():
         if key not in self._schema.allItemNames():
             raise GangaAttributeError(
                 '{class_name} does not have attribute called "{attr}"'.
                 format(class_name=self.__class__.__name__, attr=key))
         setattr(self, key, value)
Exemplo n.º 4
0
    def __setitem__(self, key, value):
        from Ganga.GPIDev.Lib.Job.Job import Job
        if key in Job._schema.datadict.keys():
            raise GangaAttributeError(
                '\'%s\' is a reserved key name and cannot be used in the metadata'
                % key)
        if not isinstance(key, str):
            raise GangaAttributeError(
                'Metadata key must be of type \'str\' not %s' % type(key))
        if isinstance(value, GangaObject):
            raise GangaAttributeError(
                'Metadata doesn\'t support nesting of GangaObjects at the moment'
            )
# if type(value) is not type(''):
##             raise GangaAttributeError('Metadata only supports string values at the moment')
# if type(value) is list or type(value) is tuple or type(value) is dict:
##             raise GangaAttributeError('Metadata doesn\'t support nesting data structures at the moment, values of type \'list\', \'tuple\' or \'dict\' are forbidden')

        self.data[key] = value
        self._setDirty()
Exemplo n.º 5
0
 def __getitem__(self, name):
     try:
         return self.datadict[name]
     except KeyError:
         if self._pluginclass is not None:
             err_str = "Ganga Cannot find: %s in Object: %s" % (name,
                                                                self.name)
         else:
             err_str = "Ganga Cannot find: %s attribute for None object" % (
                 name, )
         logger.error(err_str)
         raise GangaAttributeError(err_str)
Exemplo n.º 6
0
    def addQuery(self, bk):
        """Add a BK query to this transform"""
        # Check if the BKQuery input is correct and append/update
        if not isType(bk, BKQuery):
            raise GangaAttributeError(
                None,
                'LHCbTransform expects a BKQuery object passed to the addQuery method'
            )

        # check we don't already have inputdata
        if len(self.queries) == 0 and len(self.inputdata) > 0:
            logger.error(
                "Cannot add both input data and BK queries. Input Data already present."
            )
            return

        # add the query and update the input data
        self.queries.append(bk)
        self.updateQuery()
Exemplo n.º 7
0
    def addQuery(self, transform, bkQuery, associate=True):
        """Allows the user to add multiple transforms corresponding to the list of
        BKQuery type objects given in the second argument. The first argument
        is a transform object to use as the basis for the creation of further
        transforms."""
        if not isType(transform, LHCbAnalysisTransform):
            raise GangaException(
                None,
                'First argument must be an LHCbAnalysisTransform objects to use as the basis for establishing the new transforms'
            )

        # Check if the template transform is associated with the Task
        try:
            self.transforms.index(transform)
        except:
            if associate:
                logger.info(
                    'The transform is not associated with this Task, doing so now.'
                )
                self.appendTransform(transform)

        # Check if the BKQuery input is correct and append/update
        if type(bkQuery) is not list:
            bkQuery = [bkQuery]
        for bk in bkQuery:
            if not isType(bk, BKQuery):
                raise GangaAttributeError(
                    None,
                    'LHCbTransform expects a BKQuery object or list of BKQuery objects passed to the addQuery method'
                )
            if transform.query is None:  # If template has no query itself
                logger.info('Attaching query to transform')
                transform.query = stripProxy(bk)
                transform.update()
            else:  # Duplicate from template
                logger.info('Duplicating transform to add new query.')
                tr = deepcopy(transform)
                tr.query = stripProxy(bk)
                self.appendTransform(tr)