Home | Trees | Indices | Help |
---|
|
1 ################################################################################ 2 # Ganga Project. http://cern.ch/ganga 3 # 4 # $Id: Executable.py,v 1.1 2008-07-17 16:40:57 moscicki Exp $ 5 ################################################################################ 6 7 from Ganga.GPIDev.Adapters.IApplication import IApplication 8 from Ganga.GPIDev.Adapters.IRuntimeHandler import IRuntimeHandler 9 from Ganga.GPIDev.Schema import * 10 11 from Ganga.Utility.Config import getConfig 12 13 from Ganga.GPIDev.Lib.File import File 1416 """ 17 Executable application -- running arbitrary programs. 18 19 When you want to run on a worker node an exact copy of your script you should specify it as a File object. Ganga will 20 then ship it in a sandbox: 21 app.exe = File('/path/to/my/script') 22 23 When you want to execute a command on the worker node you should specify it as a string. Ganga will call the command 24 with its full path on the worker node: 25 app.exe = '/bin/date' 26 27 A command string may be either an absolute path ('/bin/date') or a command name ('echo'). 28 Relative paths ('a/b') or directory paths ('/a/b/') are not allowed because they have no meaning 29 on the worker node where the job executes. 30 31 The arguments may be specified in the following way: 32 app.args = ['-v',File('/some/input.dat')] 33 34 This will yield the following shell command: executable -v input.dat 35 The input.dat will be automatically added to the input sandbox. 36 37 If only one argument is specified the the following abbreviation may be used: 38 apps.args = '-v' 39 40 """ 41 _schema = Schema(Version(2,0), { 42 'exe' : SimpleItem(defvalue='echo',typelist=['str','Ganga.GPIDev.Lib.File.File.File'],doc='A path (string) or a File object specifying an executable.'), 43 'args' : SimpleItem(defvalue=["Hello World"],typelist=['str','Ganga.GPIDev.Lib.File.File.File','int'],sequence=1,strict_sequence=0,doc="List of arguments for the executable. Arguments may be strings, numerics or File objects."), 44 'env' : SimpleItem(defvalue={},typelist=['str'],doc='Environment') 45 } ) 46 _category = 'applications' 47 _name = 'Executable' 48 _GUIPrefs = [ { 'attribute' : 'exe', 'widget' : 'File' }, 49 { 'attribute' : 'args', 'widget' : 'String_List' }, 50 { 'attribute' : 'env', 'widget' : 'DictOfString' } ] 51 52 _GUIAdvancedPrefs = [ { 'attribute' : 'exe', 'widget' : 'File' }, 53 { 'attribute' : 'args', 'widget' : 'String_List' }, 54 { 'attribute' : 'env', 'widget' : 'DictOfString' } ] 55 5897 98 # disable type checking for 'exe' property (a workaround to assign File() objects) 99 # FIXME: a cleaner solution, which is integrated with type information in schemas should be used automatically 100 config = getConfig('defaults_Executable') #_Properties 101 #config.setDefaultOption('exe',Executable._schema.getItem('exe')['defvalue'], type(None),override=True) 102 config.options['exe'].type = type(None) 103 104 # not needed anymore: 105 # the backend is also required in the option name 106 # so we need a kind of dynamic options (5.0) 107 #mc = getConfig('MonitoringServices') 108 #mc['Executable'] = None 10960 from Ganga.Core import ApplicationConfigurationError 61 import os.path 62 63 # do the validation of input attributes, with additional checks for exe property 64 65 def validate_argument(x,exe=None): 66 if type(x) is type(''): 67 if exe: 68 if not x: 69 raise ApplicationConfigurationError(None,'exe not specified') 70 71 if len(x.split())>1: 72 raise ApplicationConfigurationError(None,'exe "%s" contains white spaces'%x) 73 74 dirn,filen = os.path.split(x) 75 if not filen: 76 raise ApplicationConfigurationError(None,'exe "%s" is a directory'%x) 77 if dirn and not os.path.isabs(dirn): 78 raise ApplicationConfigurationError(None,'exe "%s" is a relative path'%x) 79 80 81 else: 82 try: 83 #int arguments are allowed -> later converted to strings 84 if isinstance(x,int): 85 return 86 if not x.exists(): 87 raise ApplicationConfigurationError(None,'%s: file not found'%x.name) 88 except AttributeError: 89 raise ApplicationConfigurationError(None,'%s (%s): unsupported type, must be a string or File'%(str(x),str(type(x))))90 91 validate_argument(self.exe,exe=1) 92 93 for a in self.args: 94 validate_argument(a) 95 96 return (None,None)111 112 result = [] 113 114 for arg in args: 115 if isinstance(arg,int): 116 result.append(str(arg)) 117 else: 118 result.append(arg) 119 120 return result121131 132124 from Ganga.GPIDev.Adapters.StandardJobConfig import StandardJobConfig 125 126 c = StandardJobConfig(app.exe,app._getParent().inputsandbox,convertIntToStringArgs(app.args),app._getParent().outputsandbox,app.env) 127 128 #c.monitoring_svc = mc['Executable'] 129 130 return c147135 from Ganga.GPIDev.Lib.File import File 136 rth=RTHandler() 137 prep=rth.prepare(app,appconfig) 138 ## Modify result in order to run on Dirac 139 140 result={} 141 result['vers']='' 142 result['opts']='' 143 result['app']=prep['jobscript'] 144 result['inputbox']=prep['inputbox'] 145 result['dlls']='' 146 return result153150 from Ganga.Lib.LCG import LCGJobConfig 151 152 return LCGJobConfig(app.exe,app._getParent().inputsandbox,convertIntToStringArgs(app.args),app._getParent().outputsandbox,app.env)159 from Ganga.GPIDev.Adapters.ApplicationRuntimeHandlers import allHandlers 160 161 allHandlers.add('Executable','LSF', RTHandler) 162 allHandlers.add('Executable','Local', RTHandler) 163 allHandlers.add('Executable','PBS', RTHandler) 164 allHandlers.add('Executable','SGE', RTHandler) 165 allHandlers.add('Executable','Condor', RTHandler) 166 allHandlers.add('Executable','LCG', LCGRTHandler) 167 allHandlers.add('Executable','gLite', gLiteRTHandler) 168 allHandlers.add('Executable','TestSubmitter', RTHandler) 169 allHandlers.add('Executable','Interactive', RTHandler) 170 allHandlers.add('Executable','Batch', RTHandler) 171 allHandlers.add('Executable','Cronus', RTHandler) 172 allHandlers.add('Executable','Remote', LCGRTHandler) 173 allHandlers.add('Executable','CREAM', LCGRTHandler) 174 175 # 176 # 177 # $Log: not supported by cvs2svn $ 178 # Revision 1.29.24.6 2008/06/24 15:10:57 moscicki 179 # added Remote 180 # 181 # Revision 1.29.24.5 2007/12/18 16:40:03 moscicki 182 # removed unneccessary 'list' from the typelist 183 # 184 # Revision 1.29.24.4 2007/12/18 09:07:42 moscicki 185 # integrated typesystem from Alvin 186 # 187 # Revision 1.29.24.3 2007/12/10 17:51:22 amuraru 188 # merged changes from Ganga 4.4.4 189 # 190 # Revision 1.29.24.2 2007/10/12 14:41:49 moscicki 191 # merged from disabled jobs[] syntax and test migration 192 # 193 # Revision 1.29.24.1 2007/10/12 13:56:25 moscicki 194 # merged with the new configuration subsystem 195 # 196 # Revision 1.29.26.1 2007/09/25 09:45:12 moscicki 197 # merged from old config branch 198 # 199 # Revision 1.29.6.1 2007/06/18 07:44:55 moscicki 200 # config prototype 201 # 202 # Revision 1.29.22.1 2007/09/26 08:42:44 amuraru 203 # *** empty log message *** 204 # 205 # Revision 1.31 2007/09/26 08:39:17 amuraru 206 # *** empty log message *** 207 # 208 # Revision 1.30 2007/09/25 15:16:45 amuraru 209 # removed MonitoringServices configuration 210 # 211 # Revision 1.32 2007/10/22 11:52:57 amuraru 212 # removed job[] syntax intended for 4.4.X series 213 # 214 # 215 # Revision 1.30 2007/09/25 15:16:45 amuraru 216 # removed MonitoringServices configuration 217 # 218 # Revision 1.29.22.1 2007/09/26 08:42:44 amuraru 219 # *** empty log message *** 220 # 221 # Revision 1.31 2007/09/26 08:39:17 amuraru 222 # *** empty log message *** 223 # 224 # Revision 1.30 2007/09/25 15:16:45 amuraru 225 # removed MonitoringServices configuration 226 # 227 # Revision 1.29 2007/03/12 15:45:47 moscicki 228 # cronus added 229 # 230 # Revision 1.28 2007/03/07 09:52:37 moscicki 231 # Executable: args non-strict, i.e. a.args = 'abcd' => a.args = ['abcd'] 232 # 233 # Revision 1.27 2007/02/15 10:20:04 moscicki 234 # added SGE backend (merged from branch) 235 # 236 # Revision 1.26.2.1 2007/02/15 10:14:31 moscicki 237 # added SGE to runtime handlers list 238 # 239 # Revision 1.26 2006/10/06 10:25:13 moscicki 240 # removed DIRAC-Executable binding 241 # 242 # Revision 1.25 2006/08/24 16:50:19 moscicki 243 # MonitoringServices added 244 # 245 # Revision 1.24 2006/08/03 10:28:16 moscicki 246 # added Interactive 247 # 248 # Revision 1.23 2006/07/27 20:23:26 moscicki 249 # moved default values to the schema 250 # removed the explicit configuration unit 251 # 252 # Revision 1.22 2006/06/21 11:44:31 moscicki 253 # moved ExeSplitter to Lib/Splitters 254 # 255 # Revision 1.21 2006/06/13 12:25:59 moscicki 256 # make a entire copy of a master job for each subjob (instead of just copying the backend) 257 # 258 # Revision 1.20 2006/03/21 16:50:02 moscicki 259 # added Condor 260 # 261 # Revision 1.19 2006/03/09 08:34:48 moscicki 262 # - ExeSplitter fix (job copy) 263 # 264 # Revision 1.18 2006/02/10 14:28:16 moscicki 265 # validation of arguments on configure (fixes: bug #13685 overview: cryptic message if executable badly specified in LCG handler) 266 # 267 # Revision 1.17 2006/01/09 16:40:09 moscicki 268 # Executable_default config: echo Hello World 269 # 270 # Revision 1.16 2005/12/02 15:36:43 moscicki 271 # adapter to new base classes, added a simple splitter 272 # 273 # Revision 1.15 2005/11/25 12:59:37 moscicki 274 # added runtime handler for TestSubmitter 275 # 276 # Revision 1.14 2005/11/23 13:39:19 moscicki 277 # added PBS, removed obsolteted getRuntimeHandler() method 278 # 279 # Revision 1.13 2005/11/14 10:35:20 moscicki 280 # GUI prefs 281 # 282 # Revision 1.12.2.3 2005/10/28 17:32:46 ctan 283 # *** empty log message *** 284 # 285 # Revision 1.12.2.2 2005/10/27 15:04:03 ctan 286 # *** empty log message *** 287 # 288 # Revision 1.12.2.1 2005/10/26 09:02:13 ctan 289 # *** empty log message *** 290 # 291 # Revision 1.12 2005/09/21 12:41:26 andrew 292 # Changes made to include a gLite handler. 293 # 294 # Revision 1.11 2005/09/02 12:49:13 liko 295 # Include LCG Handler, extend application with environment 296 # 297 # Revision 1.10 2005/08/30 08:03:05 andrew 298 # Added Dirac as a possible backend. Not that this would really work mind you 299 # 300 # Revision 1.9 2005/08/24 08:13:41 moscicki 301 # using StandardJobConfig 302 # 303 # 304 # 305156 from Ganga.Lib.gLite import gLiteJobConfig 157 158 return gLiteJobConfig(app.exe,app._getParent().inputsandbox,convertIntToStringArgs(app.args),app._getParent().outputsandbox,app.env)
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon Jun 25 10:35:34 2012 | http://epydoc.sourceforge.net |