Package Ganga :: Package GPIDev :: Package Lib :: Package Tasks :: Module ArgTransform
[hide private]
[frames] | no frames]

Source Code for Module Ganga.GPIDev.Lib.Tasks.ArgTransform

 1  from common import * 
 2  from Transform import Transform 
 3  from Ganga.Utility.util import containsGangaObjects,isNestedList 
 4  from TaskApplication import ArgSplitterTask 
 5   
6 -class ArgTransform(Transform):
7 _schema = Schema(Version(1,0), dict(Transform._schema.datadict.items() + { 8 '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'), 9 }.items())) 10 _category = 'transforms' 11 _name = 'ArgTransform' 12 _exportmethods = Transform._exportmethods 13 14 # Copied from ISplitter
15 - def _checksetNestedLists(self,value):
16 """The rule is that if there are nested lists then they 17 must not contain GangaObjects, as this corrupts the repository""" 18 if isNestedList(value) and containsGangaObjects(value): 19 raise TypeMismatchError('Assigning nested lists which contain Ganga GPI Objects is not supported.')
20
21 - def check(self):
22 nargs = len(self.args) 23 self.setPartitionsStatus(range(1,nargs+1), "ready") 24 if "_partition_status" in self._data: 25 self.setPartitionsLimit(nargs+1)
26
27 - def getJobsForPartitions(self, partitions):
28 """Create Ganga Jobs for the next N partitions that are ready and submit them.""" 29 j = self.createNewJob(partitions[0]) 30 if len(partitions) > 1: 31 j.splitter = ArgSplitterTask() 32 j.splitter.args = [self.args[p-1] for p in partitions] 33 j.splitter.task_partitions = partitions 34 else: 35 p = partitions[0] 36 if (p < 1 or p > len(self.args)): 37 raise ApplicationConfigurationError("Partition %i did not find a corresponding argment!", p) 38 j.application.args = self.args[p-1] 39 return [j]
40