1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 """
35 pyflowConfig
36
37 This file defines a class instance 'siteConfig' containing pyflow components
38 which are the most likely to need site-specific configuration.
39 """
40
41 import os
42
43
44
45
46
47 siteConfig = None
53 import socket
54 return socket.getfqdn()
55
56 cachedHostName = None
64
65
66 -def getDomainName() :
67 hn = getHostName().split(".")
68 if len(hn) > 1 : hn = hn[1:]
69 return ".".join(hn)
70
74 """
75 Default configuration settings are designed to work with as
76 many sites as technically feasible
77 """
78
79
80
81 mailFrom = "pyflow-bot@" + getDomainName()
82
83
84
85 defaultTaskMemMb = 2048
86
87
88
89
90 defaultHostMemMbPerCore = 2048
91
92
93
94
95
96
97 maxSGEJobs = 128
98
99
100
101
102 getHostName = staticmethod(getHostName)
103 getDomainName = staticmethod(getDomainName)
104
105 @classmethod
107 """
108 When a task is launched using qsub in sge mode, it will call this
109 function to specify the requested number of threads and megabytes
110 of memory. The returned argument list will be appended to the qsub
111 arguments.
112
113 nCores -- number of threads requested
114 memMb -- memory requested (in megabytes)
115 """
116 nCores = int(nCores)
117 memMb = int(memMb)
118 return cls._qsubResourceArgConfig(nCores, memMb)
119
120 @classmethod
122 """
123 The default function is designed for maximum
124 portability -- it just provides more memory
125 via more threads.
126 """
127
128
129
130
131 class Constants(object) : megsPerCore = 4096
132
133 memCores = 1 + ((memMb - 1) / Constants.megsPerCore)
134
135 qsubCores = max(nCores, memCores)
136
137 if qsubCores <= 1 : return []
138 return ["-pe", "threaded", str(qsubCores)]
139
140
141 @classmethod
143 """
144 This prefix will be added to ' -C directory', and run from
145 a local process to handle sge make jobs.
146
147 Note that memMb hasn't been well defined for make jobs yet,
148 is it the per task memory limit? The first application to
149 accually make use of this will have to setup the convention,
150 it is ignored right now...
151 """
152 nCores = int(nCores)
153 memMb = int(memMb)
154
155 retval = ["qmake",
156 "-V",
157 "-now", "n",
158 "-cwd",
159 "-N", "pyflowMakeTask"]
160
161
162 retval.extend(schedulerArgList)
163
164
165
166
167
168 retval.extend(["--", "-j", str(nCores)])
169
170 return retval
171
175 if key in os.environ : return os.environ[key]
176 return None
177
181 """
182 This config assumes 'h_vmem' is defined on the SGE instance
183
184 """
185
186 @classmethod
188
189 retval = []
190
191
192 memGb = 1 + ((memMb - 1) / 1024)
193 reqArg = "h_vmem=%iG" % (memGb)
194 retval.extend(["-l", reqArg])
195
196 if nCores > 1 :
197 retval.extend(["-pe", "threaded", str(nCores)])
198
199 return retval
200
210
211
212 siteConfig = siteConfigFactory()
213