Skip to content

Commit

Permalink
Explicitly test parameter set input configuration for PrivateMC.
Browse files Browse the repository at this point in the history
We receive a lot of emails with misconfigurations when generating MC.  This
will test the input source of the parameter set and try to point the user
to potential fixes before the task hits the crab server and fails.

Fixes dmwm#4610.
  • Loading branch information
matz-e committed Apr 13, 2016
1 parent afc3407 commit bb159bc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/crab3bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ def saveCfgInfo(destFile, cmsswCfg):
info = {}
edmfiles, tfiles = cmsswCfg.outputFiles()
lhe, nfiles = cmsswCfg.hasLHESource()
pool = cmsswCfg.hasPoolSource()
info['outfiles'] = [ edmfiles, tfiles]
info['lheinfo'] = [lhe, nfiles]
info['poolinfo'] = [pool]
with open(destFile, 'w') as fd:
json.dump(info, fd)
except IOError as ioe:
Expand Down
22 changes: 22 additions & 0 deletions src/python/CRABClient/JobType/CMSSWConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,28 @@ def writeFile(self, filename = 'CMSSW.py'):
return


def hasPoolSource(self):
"""
Returns if an PoolSource is present in the parameter set.
"""
if bootstrapDone():
self.logger.debug("Getting source info from bootstrap cachefile.")
info = self.getCfgInfo()
return info['poolinfo']

isPool = False

if getattr(self.fullConfig.process, 'source'):
source = self.fullConfig.process.source
try:
isPool = str(source.type_()) == 'PoolSource'
except AttributeError as ex:
msg = "Invalid CMSSW configuration: Failed to check if 'process.source' is of type 'PoolSource': %s" % (ex)
raise ConfigurationException(msg)

return isPool


def hasLHESource(self):
"""
Returns a tuple containing a bool to indicate usage of an
Expand Down
17 changes: 17 additions & 0 deletions src/python/CRABClient/JobType/PrivateMC.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from CRABClient.ClientUtilities import colors
from CRABClient.JobType.Analysis import Analysis
from CRABClient.ClientExceptions import ConfigurationException
from CRABClient.ClientMapping import getParamDefaultValue


Expand All @@ -22,6 +23,7 @@ def run(self, *args, **kwargs):
configArguments['jobtype'] = 'PrivateMC'

lhe, nfiles = self.cmsswCfg.hasLHESource()
pool = self.cmsswCfg.hasPoolSource()
if lhe:
self.logger.debug("LHESource found in the CMSSW configuration.")
configArguments['generator'] = getattr(self.config.JobType, 'generator', 'lhe')
Expand All @@ -38,6 +40,21 @@ def run(self, *args, **kwargs):
msg += "Consider merging the LHE input files to guarantee complete processing."
self.logger.warning(msg)

if getattr(self.config.JobType, 'generator', '') == 'lhe' and not lhe:
msg = "Generator set to 'lhe' but "
if pool:
msg += "'PoolSource' instead of 'LHESoure' present in parameter set. If you "
msg += "are processing files in EDMLHE format, please set 'JobType.pluginName' "
msg += "to 'Analysis'."
else:
msg += "no 'LHESource' found in parameter set. If you are processing a gridpack "
msg += "to produce EDMLHE files, please remove the parameter 'JobType.generator'."
raise ConfigurationException(msg)
elif pool:
msg = "Found a 'PoolSource' in the parameter set. Please switch to either 'EmptySource' "
msg += "or 'LHESource' for event generation, or set 'JobType.pluginName' to 'Analysis'."
raise ConfigurationException(msg)

configArguments['primarydataset'] = getattr(self.config.Data, 'outputPrimaryDataset', 'CRAB_PrivateMC')

return tarFilename, configArguments
Expand Down

0 comments on commit bb159bc

Please sign in to comment.