193 def submit(config, allSamples):
197 if not config.skipShowerCheck:
198 for configFile
in config.settingsFile.split(
','):
201 for configFile
in config.settingsFile.split(
','):
204 tarfile =
'top-xaod.tar.gz'
207 if not config.reuseTarBall:
219 for configFile
in config.settingsFile.split(
','):
221 print(logger.WARNING +
" WARNING - Did not find config file %s in this dir "%(configFile) + logger.ENDC)
222 print(logger.WARNING +
" - Attempt to find this file in a sensible location using PathResolver... " + logger.ENDC)
223 settingsFilePath = ROOT.PathResolver.find_file(configFile,
"DATAPATH", ROOT.PathResolver.LocalSearch)
224 if settingsFilePath ==
"":
225 print(logger.FAIL +
"DANGER DANGER. HIGH VOLTAGE" + logger.ENDC)
226 print(
'%s does not exist in this directory and cannot be found using PathResolver, exiting!' % configFile)
229 print(logger.WARNING +
" - Found an appropriate file %s "%(settingsFilePath) + logger.ENDC)
232 for configFile
in config.settingsFile.split(
','):
233 settingsFilePath = ROOT.PathResolver.find_file(configFile,
"DATAPATH", ROOT.PathResolver.LocalSearch)
236 outputFilename =
'EMPTY'
237 for l
in open(settingsFilePath,
"r"):
241 if l.find(
'OutputFilename') > -1:
242 outputFilename = l.replace(
'OutputFilename',
'').strip()
243 if outputFilename ==
'EMPTY':
244 print(logger.FAIL +
'OutputFilename not found in ' + settingsFilePath + logger.ENDC)
247 outputFiles.append(outputFilename)
251 if len(outputFiles) == 0:
252 print(logger.FAIL +
'No OutputFileName found' + logger.ENDC)
254 elif len(outputFiles) ==1:
255 outF = outputFiles[0]
256 outputFilenames = outF.replace(
".root",
"_root") +
":" + outF
259 if len(outputFiles) != len(
set(outputFiles)):
260 print(logger.FAIL +
'Two of the output file names are identical. Check the config files (separated by commas).' + logger.ENDC)
262 if config.combine_outputFile ==
None:
264 for configFile
in outputFiles:
265 cFile = configFile.replace(
".root",
"_root") +
":" + configFile
266 outputFilenames += cFile
267 if iconfigFile != len(outputFiles)-1:
268 outputFilenames +=
','
272 prefixes = config.combine_prefixes.split(
',')
274 if len(prefixes) != len(
set(prefixes)):
275 print(logger.FAIL +
'Two of the prefixes (separated by commas) are identical. Check the combine_prefixes option.' + logger.ENDC)
278 if len(prefixes) != len(outputFiles):
279 print(logger.FAIL +
'When combining the outputs, there should be as many prefixes as there are output files (separated by commas). Check the combine_prefixes and settingsFile options.' + logger.ENDC)
282 outputFilenames = config.combine_outputFile.replace(
".root",
"_root") +
":" + config.combine_outputFile
285 for outFile
in outputFiles:
286 combineArgument += outFile
287 combineArgument +=
":"
288 combineArgument += prefixes[iconfigFile]
289 if iconfigFile != len(outputFiles)-1:
290 combineArgument +=
','
297 print(logger.OKBLUE +
'For these samples' + logger.ENDC)
299 for sample
in allSamples:
300 currentDatasets = sample.datasets
302 for ds
in currentDatasets:
314 print(logger.OKBLUE +
'Starting submission of %d sample%s' % (len(these), plural) + logger.ENDC)
318 for i, d_concatenated
in enumerate(these):
320 print(logger.OKBLUE +
'Submitting %d of %d' % (i+1, len(these)) + logger.ENDC)
324 if config.groupProduction:
325 output =
'group.' + config.gridUsername +
'.' + config.nameShortener(d) +
'.' + config.suffix
327 output =
'user.' + config.gridUsername +
'.' + config.nameShortener(d) +
'.' + config.suffix
331 if config.groupProduction:
332 cmd +=
'--official --voms atlas:/atlas/' + config.gridUsername +
'/Role=production \\\n'
333 cmd +=
'--inDS=' + d_concatenated +
' \\\n'
334 cmd +=
'--outDS=' + output +
' \\\n'
336 CMTCONFIG = os.getenv(
"CMTCONFIG")
337 cmd +=
'--useAthenaPackages --cmtConfig=%s \\\n'%(CMTCONFIG)
339 cmd +=
'--useRootCore \\\n'
340 cmd +=
'--writeInputToTxt=IN:in.txt \\\n'
341 cmd +=
'--outputs=%s \\\n' % outputFilenames
345 for configFile
in config.settingsFile.split(
','):
346 cmd +=
'%s %s in.txt' % (config.code, configFile)
347 if iconfigFile!=len(config.settingsFile.split(
','))-1:
350 elif combineArgument !=
'':
351 cmd +=
'; combineATOutputs ' + config.combine_outputFile +
" " + combineArgument
357 if len(config.excludedSites) > 0:
358 cmd +=
'--excludedSite=' + config.excludedSites +
' \\\n'
361 if len(config.forceSite) > 0:
362 cmd +=
'--site ' + config.forceSite +
' \\\n'
367 print(logger.OKBLUE +
'Reusing existing tarball %s' % (tarfile) + logger.ENDC)
368 cmd +=
'--inTarBall=%s \\\n' % tarfile
369 elif config.reuseTarBall:
370 print(logger.WARNING +
'Tarball %s not found - will re-create it' % (tarfile) + logger.ENDC)
371 cmd +=
'--outTarBall=%s \\\n' % tarfile
373 cmd +=
'--outTarBall=%s \\\n' % tarfile
376 cmd +=
'--inTarBall=%s \\\n' % tarfile
381 cmd +=
'--noSubmit \\\n'
384 if config.mergeType !=
"None":
385 cmd +=
'--mergeOutput \\\n'
388 if len(config.destSE) > 0:
389 cmd +=
'--destSE=\"%s\" \\\n' % config.destSE
394 if config.mergeType ==
"xAOD":
395 cmd +=
'--mergeScript="xAODMerge %OUT \`echo %IN | sed \'s/,/ /g\'\`" \\\n'
398 if len(config.memory) > 0:
399 cmd +=
'--memory=%s \\\n' % config.memory
402 if len(config.maxNFilesPerJob) > 0:
403 cmd +=
'--maxNFilesPerJob=%s \\\n' % config.maxNFilesPerJob
406 if len(config.otherOptions) > 0:
407 cmd +=
'%s \\\n' % config.otherOptions
416 for l
in os.popen(cmd).readlines():
417 print(
'>> ', l.strip())