Package Ganga :: Package Lib :: Package Splitters :: Module ArgSplitter'
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Lib.Splitters.ArgSplitter'

 1  ############################################################################### 
 2  # Ganga Project. http://cern.ch/ganga 
 3  # 
 4  # $Id: ArgSplitter.py,v 1.1 2008-07-17 16:40:59 moscicki Exp $ 
 5  ############################################################################### 
 6   
 7  from Ganga.GPIDev.Adapters.ISplitter import ISplitter 
 8  from Ganga.GPIDev.Schema import * 
 9   
10 -class ArgSplitter(ISplitter):
11 12 """ 13 Split job by changing the args attribute of the application. 14 15 This splitter only applies to the applications which have args attribute (e.g. Executable, Root). 16 It is a special case of the GenericSplitter. 17 18 This splitter allows the creation of a series of subjobs where 19 the only difference between different jobs are their 20 arguments. Below is an example that executes a ROOT script ~/analysis.C 21 22 void analysis(const char* type, int events) { 23 std::cout << type << " " << events << std::endl; 24 } 25 26 with 3 different sets of arguments. 27 28 s = ArgSplitter(args=[['AAA',1],['BBB',2],['CCC',3]]) 29 r = Root(version='5.10.00',script='~/analysis.C') 30 j.Job(application=r, splitter=s) 31 32 Notice how each job takes a list of arguments (in this case a list 33 with a string and an integer). The splitter thus takes a list of 34 lists, in this case with 3 elements so there will be 3 subjobs. 35 36 Running the subjobs will produce the output: 37 subjob 1 : AAA 1 38 subjob 2 : BBB 2 39 subjob 3 : CCC 3 40 """ 41 _name = "ArgSplitter" 42 _schema = Schema(Version(1,0), { 43 'args' : SimpleItem(defvalue=[],typelist=['list','Ganga.GPIDev.Lib.GangaList.GangaList.GangaList'],sequence=1,checkset='_checksetNestedLists',doc='A list of lists of arguments to pass to script') 44 } ) 45
46 - def split(self,job):
47 48 subjobs = [] 49 50 for arg in self.args: 51 j = self.createSubjob(job) 52 # Add new arguments to subjob 53 j.application.args=arg 54 logger.debug('Arguments for split job is: '+str(arg)) 55 subjobs.append(j) 56 return subjobs
57 58 59 # 60 # 61 # $Log: not supported by cvs2svn $ 62 # Revision 1.7.4.3 2008/07/03 08:36:16 wreece 63 # Typesystem fix for Splitters 64 # 65 # Revision 1.7.4.2 2008/03/12 12:42:38 wreece 66 # Updates the splitters to check for File objects in the list 67 # 68 # Revision 1.7.4.1 2008/02/08 15:09:52 amuraru 69 # fixed the TypeMismatchError 70 # 71 # Revision 1.7 2007/07/10 13:08:32 moscicki 72 # docstring updates (ganga devdays) 73 # 74 # Revision 1.6 2006/09/29 08:31:56 moscicki 75 # typo fix 76 # 77 # Revision 1.5 2006/09/15 14:24:24 moscicki 78 # fixed a typo 79 # 80 # Revision 1.4 2006/08/24 16:52:10 moscicki 81 # splitter.createJob() 82 # 83 # Revision 1.3 2006/08/03 08:14:30 moscicki 84 # SimpleItem fix 85 # 86 # Revision 1.2 2006/08/01 10:25:50 moscicki 87 # small schema fixes 88 # 89 # Revision 1.1 2006/06/21 11:27:29 moscicki 90 # splitters moved to the new location 91 # 92 # 93 # 94