Package Ganga :: Package GPIDev :: Package Adapters :: Module ISplitter
[hide private]
[frames] | no frames]

Source Code for Module Ganga.GPIDev.Adapters.ISplitter

 1  ################################################################################ 
 2  # Ganga Project. http://cern.ch/ganga 
 3  # 
 4  # $Id: ISplitter.py,v 1.1 2008-07-17 16:40:52 moscicki Exp $ 
 5  ################################################################################ 
 6   
 7  from Ganga.GPIDev.Base import GangaObject 
 8  from Ganga.GPIDev.Base.Proxy import TypeMismatchError 
 9  from Ganga.GPIDev.Schema import * 
10  from Ganga.Utility.util import containsGangaObjects,isNestedList 
11   
12  #class SplittingError(Exception): 
13  #    def __init__(self,x): Exception.__init__(self,x) 
14   
15 -class ISplitter(GangaObject):
16 """ 17 """ 18 _schema = Schema(Version(0,0), {}) 19 _category = 'splitters' 20 _hidden = 1 21 22
23 - def _checksetNestedLists(self,value):
24 """The rule is that if there are nested lists then they 25 must not contain GangaObjects, as this corrupts the repository""" 26 if isNestedList(value) and containsGangaObjects(value): 27 raise TypeMismatchError('Assigning nested lists which contain Ganga GPI Objects is not supported.')
28
29 - def createSubjob(self,job):
30 """ Create a new subjob by copying the master job and setting all fields correctly. 31 """ 32 from Ganga.GPIDev.Lib.Job import Job 33 34 j = Job() 35 j.copyFrom(job) 36 j.splitter=None 37 #FIXME: 38 j.inputsandbox = [] 39 return j
40 41
42 - def split(self,job):
43 """ Return a list of subjobs generated from a master job. The 44 original master job should not be modified. This method 45 should be implemented in the derived classes. 46 47 Splitter changes certain parts of the subjobs i.e. mutates 48 certain properties (otherwise all subjobs would be the same). 49 Only these properties may be mutated which are declared 50 'splitable' in the schema. This restriction applies to 51 application objects to avoid inconsistencies if application 52 handler is not able to deal with modified arguments. 53 54 In the current implementation the type of the backend cannot 55 be changed either. 56 57 """ 58 59 raise NotImplementedError
60
61 - def validatedSplit(self,job):
62 """ Perform splitting using the split() method and validate the mutability 63 invariants. If the invariants are broken (or exception occurs in the 64 split() method) then SplittingError exception is raised. This method is 65 called directly by the framework and should not be modified in the derived 66 classes. """ 67 68 #try: 69 subjobs = self.split(job) 70 #except Exception,x: 71 # raise SplittingError(x) 72 73 if not len(subjobs): 74 raise SplittingError('splitter did not create any subjobs') 75 76 cnt = 0 77 for s in subjobs: 78 if s.backend._name != job.backend._name: 79 raise SplittingError('masterjob backend %s is not the same as the subjob (probable subjob id=%d) backend %s'%(job.backend._name,cnt,s.backend._name)) 80 cnt += 1 81 82 return subjobs
83