diff --git a/FWCore/ParameterSet/python/Config.py b/FWCore/ParameterSet/python/Config.py index 698f37b2155c2..7f24bb514ddd5 100644 --- a/FWCore/ParameterSet/python/Config.py +++ b/FWCore/ParameterSet/python/Config.py @@ -1285,10 +1285,9 @@ def _insertPaths(self, processPSet, nodeVisitor): iFinalPath.resolve(self.__dict__) finalpathValidator.setLabel(finalpathname) iFinalPath.visit(finalpathValidator) - if finalpathValidator.filtersOnFinalpaths or finalpathValidator.producersOnFinalpaths: - names = [p.label_ for p in finalpathValidator.filtersOnFinalpaths] - names.extend( [p.label_ for p in finalpathValidator.producersOnFinalpaths]) - raise RuntimeError("FinalPath %s has non OutputModules %s" % (finalpathname, ",".join(names))) + invalidModules = finalpathValidator.invalidModulesOnFinalpaths + if invalidModules: + raise RuntimeError("FinalPath %s has non OutputModules %s" % (finalpathname, ",".join(invalidModules))) modulesOnFinalPath.extend(iFinalPath.moduleNames()) for m in modulesOnFinalPath: mod = getattr(self, m) @@ -3326,7 +3325,7 @@ def testFinalPath(self): path = FinalPath(p.a*(p.b+p.c)) self.assertEqual(str(path),'a+b+c') p.es = ESProducer("AnESProducer") - self.assertRaises(TypeError,FinalPath,p.es) + self.assertRaises(TypeError,FinalPath, p.es) t = FinalPath() self.assertEqual(t.dumpPython(PrintOptions()), 'cms.FinalPath()\n') @@ -3348,7 +3347,27 @@ def testFinalPath(self): p.t = FinalPath(p.a) p.a = OutputModule("ReplacedOutputModule") self.assertEqual(p.t.dumpPython(PrintOptions()), 'cms.FinalPath(process.a)\n') - + + p.anal = EDAnalyzer("MyAnalyzer") + p.t = FinalPath(p.anal) + pset = TestMakePSet() + self.assertRaises(RuntimeError, p.fillProcessDesc, pset) + + p.prod = EDProducer("MyProducer") + p.t = FinalPath(p.prod) + pset = TestMakePSet() + self.assertRaises(RuntimeError, p.fillProcessDesc, pset) + + p.filt = EDFilter("MyFilter") + p.t = FinalPath(p.filt) + pset = TestMakePSet() + self.assertRaises(RuntimeError, p.fillProcessDesc, pset) + + p.outp = OutputModule("MyOutputModule") + p.t = FinalPath(p.outp) + pset = TestMakePSet() + p.fillProcessDesc(pset) + def testCloneSequence(self): p = Process("test") a = EDAnalyzer("MyAnalyzer") diff --git a/FWCore/ParameterSet/python/SequenceVisitors.py b/FWCore/ParameterSet/python/SequenceVisitors.py index 679d44614bcf7..3717f193cc16d 100644 --- a/FWCore/ParameterSet/python/SequenceVisitors.py +++ b/FWCore/ParameterSet/python/SequenceVisitors.py @@ -72,8 +72,7 @@ class FinalPathValidator(object): def __init__(self): self.__label = '' self._levelInTasks = 0 - self.filtersOnFinalpaths = [] - self.producersOnFinalpaths = [] + self.invalidModulesOnFinalpaths = [] def setLabel(self,label): self.__label = "'"+label+"' " def enter(self,visitee): @@ -88,10 +87,8 @@ def enter(self,visitee): self._levelInTasks += 1 if self._levelInTasks > 0: return - if isinstance(visitee,EDFilter): - self.filtersOnFinalpaths.append(visitee.type_()) - if isinstance(visitee,EDProducer): - self.producersOnFinalpaths.append(visitee.type_()) + if isinstance(visitee,(EDAnalyzer,EDProducer,EDFilter)): + self.invalidModulesOnFinalpaths.append(visitee.type_()) def leave(self,visitee): if self._levelInTasks > 0: if isinstance(visitee, Task):