@@ -167,13 +167,12 @@ def _addCEConfigDefaults(self):
167
167
ComputingElement ._addCEConfigDefaults (self )
168
168
169
169
#############################################################################
170
- def _writeXRSL (self , executableFile , inputs = None , outputs = None , executables = None ):
170
+ def _writeXRSL (self , executableFile , inputs , outputs ):
171
171
"""Create the JDL for submission
172
172
173
173
:param str executableFile: executable to wrap in a XRSL file
174
- :param str/list inputs: path of the dependencies to include along with the executable
175
- :param str/list outputs: path of the outputs that we want to get at the end of the execution
176
- :param str/list executables: path to inputs that should have execution mode on the remote worker node
174
+ :param list inputs: path of the dependencies to include along with the executable
175
+ :param list outputs: path of the outputs that we want to get at the end of the execution
177
176
"""
178
177
diracStamp = makeGuid ()[:8 ]
179
178
# Evaluate the number of processors to allocate
@@ -191,34 +190,25 @@ def _writeXRSL(self, executableFile, inputs=None, outputs=None, executables=None
191
190
"xrslMPExtraString" : self .xrslMPExtraString ,
192
191
}
193
192
194
- # Files that would need execution rights on the remote worker node
195
- xrslExecutables = ""
196
- if executables :
197
- if not isinstance (executables , list ):
198
- executables = [executables ]
199
- xrslExecutables = "(executables=%s)" % " " .join (map (os .path .basename , executables ))
200
- # Add them to the inputFiles
201
- if not inputs :
202
- inputs = []
203
- if not isinstance (inputs , list ):
204
- inputs = [inputs ]
205
- inputs += executables
206
-
207
193
# Dependencies that have to be embedded along with the executable
208
194
xrslInputs = ""
209
- if inputs :
210
- if not isinstance (inputs , list ):
211
- inputs = [inputs ]
212
- for inputFile in inputs :
213
- xrslInputs += '(%s "%s")' % (os .path .basename (inputFile ), inputFile )
195
+ executables = []
196
+ for inputFile in inputs :
197
+ inputFileBaseName = os .path .basename (inputFile )
198
+ if os .access (inputFile , os .X_OK ):
199
+ # Files that would need execution rights on the remote worker node
200
+ executables .append (inputFileBaseName )
201
+ xrslInputs += '(%s "%s")' % (inputFileBaseName , inputFile )
202
+
203
+ # Executables are added to the XRSL
204
+ xrslExecutables = ""
205
+ if executables :
206
+ xrslExecutables = "(executables=%s)" % " " .join (executables )
214
207
215
208
# Output files to retrieve once the execution is complete
216
209
xrslOutputs = '("%s.out" "") ("%s.err" "")' % (diracStamp , diracStamp )
217
- if outputs :
218
- if not isinstance (outputs , list ):
219
- outputs = [outputs ]
220
- for outputFile in outputs :
221
- xrslOutputs += '(%s "")' % (outputFile )
210
+ for outputFile in outputs :
211
+ xrslOutputs += '(%s "")' % (outputFile )
222
212
223
213
xrsl = """
224
214
&(executable="%(executable)s")
@@ -247,6 +237,13 @@ def _writeXRSL(self, executableFile, inputs=None, outputs=None, executables=None
247
237
def _bundlePreamble (self , executableFile ):
248
238
"""Bundle the preamble with the executable file"""
249
239
wrapperContent = "%s\n ./%s" % (self .preamble , executableFile )
240
+
241
+ # We need to make sure the executable file can be executed by the wrapper
242
+ # By adding the execution mode to the file, the file will be processed as an "executable" in the XRSL
243
+ # This is done in _writeXRSL()
244
+ if not os .access (executableFile , os .X_OK ):
245
+ os .chmod (executableFile , stat .S_IRWXU | stat .S_IRGRP | stat .S_IXGRP | stat .S_IROTH + stat .S_IXOTH )
246
+
250
247
return writeScript (wrapperContent , os .getcwd ())
251
248
252
249
#############################################################################
@@ -299,13 +296,14 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1, inputs=None, outputs=
299
296
return result
300
297
self .usercfg .ProxyPath (os .environ ["X509_USER_PROXY" ])
301
298
302
- self .log .verbose ("Executable file path: %s" % executableFile )
303
- if not os .access (executableFile , 5 ):
304
- os .chmod (executableFile , stat .S_IRWXU | stat .S_IRGRP | stat .S_IXGRP | stat .S_IROTH + stat .S_IXOTH )
299
+ if not inputs :
300
+ inputs = []
301
+ if not outputs :
302
+ outputs = []
305
303
306
- executables = None
304
+ self . log . verbose ( "Executable file path: %s" % executableFile )
307
305
if self .preamble :
308
- executables = [ executableFile ]
306
+ inputs . append ( executableFile )
309
307
executableFile = self ._bundlePreamble (executableFile )
310
308
311
309
batchIDList = []
@@ -325,7 +323,7 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1, inputs=None, outputs=
325
323
# The basic job description
326
324
jobdescs = arc .JobDescriptionList ()
327
325
# Get the job into the ARC way
328
- xrslString , diracStamp = self ._writeXRSL (executableFile , inputs , outputs , executables )
326
+ xrslString , diracStamp = self ._writeXRSL (executableFile , inputs , outputs )
329
327
self .log .debug ("XRSL string submitted : %s" % xrslString )
330
328
self .log .debug ("DIRAC stamp for job : %s" % diracStamp )
331
329
# The arc bindings don't accept unicode objects in Python 2 so xrslString must be explicitly cast
0 commit comments