From bb159bc26114624921f5b77b5641ee9f33e3d382 Mon Sep 17 00:00:00 2001 From: Matthias Wolf Date: Wed, 13 Apr 2016 15:20:01 +0200 Subject: [PATCH] Explicitly test parameter set input configuration for PrivateMC. 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 #4610. --- bin/crab3bootstrap | 2 ++ src/python/CRABClient/JobType/CMSSWConfig.py | 22 ++++++++++++++++++++ src/python/CRABClient/JobType/PrivateMC.py | 17 +++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/bin/crab3bootstrap b/bin/crab3bootstrap index fb3c57f9a..83e5ccb41 100755 --- a/bin/crab3bootstrap +++ b/bin/crab3bootstrap @@ -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: diff --git a/src/python/CRABClient/JobType/CMSSWConfig.py b/src/python/CRABClient/JobType/CMSSWConfig.py index df7e6bfd1..e8ff78850 100644 --- a/src/python/CRABClient/JobType/CMSSWConfig.py +++ b/src/python/CRABClient/JobType/CMSSWConfig.py @@ -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 diff --git a/src/python/CRABClient/JobType/PrivateMC.py b/src/python/CRABClient/JobType/PrivateMC.py index 6e65a5479..4de87f6af 100644 --- a/src/python/CRABClient/JobType/PrivateMC.py +++ b/src/python/CRABClient/JobType/PrivateMC.py @@ -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 @@ -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') @@ -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