1
2
3
4
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
13
14
16 """
17 """
18 _schema = Schema(Version(0,0), {})
19 _category = 'splitters'
20 _hidden = 1
21
22
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
40
41
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
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
69 subjobs = self.split(job)
70
71
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