Skip to content

Commit

Permalink
Merge pull request #42936 from fwyzard/fix_FinalPath_check
Browse files Browse the repository at this point in the history
Fix logic error in `FinalPath` checks
  • Loading branch information
cmsbuild authored Nov 28, 2023
2 parents 0036321 + 0f1e9ae commit cf995f9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
31 changes: 25 additions & 6 deletions FWCore/ParameterSet/python/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand All @@ -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")
Expand Down
9 changes: 3 additions & 6 deletions FWCore/ParameterSet/python/SequenceVisitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit cf995f9

Please sign in to comment.