Example #1
0
 def __getitem__(self,x):
     """ Get a job by positional index. Examples:
     jobs[-1] : get last job,
     jobs[0] : get first job,
     jobs[1] : get second job.
     """
     return _wrap(self._impl.__getitem__(_unwrap(x)))
Example #2
0
 def _get_obj(self,obj_id):
     if type(obj_id) == str:
         return self[self._getIDByName(obj_id)]
     elif type(obj_id) == int:
         return self[obj_id]
     else:
         obj = _unwrap(obj_id)
         return self[self.find(obj)]
Example #3
0
    def proxy_add(self,obj,name):
        """
        Add an object to the box
         
        The object must also be given a descriptive text name, for example:

        box.add(Job(),'A job')

        or

        a=Executable()
        box.add(a, 'An executable application')
        """
        obj = _unwrap(obj)
        if isinstance(obj,list):
            obj = makeGangaList(obj)
        if not isinstance(obj,GangaObject):
            raise BoxTypeError("The Box can only contain Ganga Objects (i.e. Applications, Datasets or Backends). Check that the object is first in box.add(obj,'name')")

        if obj._category == 'jobs':
            if hasattr(obj.application, 'is_prepared'):
                if obj.application.is_prepared is not None and obj.application.is_prepared is not True:
                    logger.debug('Adding a prepared job to the box and increasing the shareref counter')
                    obj.application.incrementShareCounter(obj.application.is_prepared.name)
        if obj._category == 'applications':
            if hasattr(obj, 'is_prepared'):
                if obj.is_prepared is not None and obj.is_prepared is not True:
                    logger.debug('Adding a prepared application to the box and increasing the shareref counter')
                    obj.incrementShareCounter(obj.is_prepared.name)

        obj = obj.clone()
        nobj = BoxMetadataObject()
        nobj.name = name
        self._add(obj)
        self.metadata._add(nobj,self.find(obj))
        nobj._setDirty()
        obj._setDirty()
Example #4
0
def jobSlice(joblist):
    """create a 'JobSlice' from a list of jobs
    example: jobSlice([j for j in jobs if j.name.startswith("T1:")])"""
    slice = JobRegistrySlice("manual slice")
    slice.objects = oDict([(j.fqid, _unwrap(j)) for j in joblist])
    return _wrap(slice)