Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logic error in FinalPath checks #42936

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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