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 bug in convertToUnscheduled with decorators #9988

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 28 additions & 10 deletions FWCore/ParameterSet/python/Utilities.py
Expand Up @@ -144,6 +144,22 @@ def convertToUnscheduled(proc):
dependentProducers = set()
firstPass = True


def getUnqualifiedName(name):
if name[0] in set(['!','-']):
return name[1:]
return name

def getQualifiedModule(name,proc):
unqual_name = getUnqualifiedName(name)
p=getattr(proc,unqual_name)
if unqual_name != name:
if name[0] == '!':
p = ~p
elif name[0] == '-':
p = cms.ignore(p)
return p

while True :

dependentsFoundThisPass = False
Expand Down Expand Up @@ -177,23 +193,23 @@ def convertToUnscheduled(proc):
# On each path we drop EDProducers except we
# keep the EDProducers that depend on EDFilters
for pName,p in l.iteritems():
nodes = []
v = cms.ModuleNodeVisitor(nodes)
qualified_names = []
v = cms.DecoratedNodeNameVisitor(qualified_names)
p.visit(v)
names = [node.label_() for node in nodes]
remaining =[]

for n in names:
if not isinstance(getattr(proc,n), cms.EDProducer):
for n in qualified_names:
unqual_name = getUnqualifiedName(n)
if not isinstance(getattr(proc,unqual_name), cms.EDProducer):
remaining.append(n)
else :
if n in dependentProducers :
if unqual_name in dependentProducers :
remaining.append(n)

if remaining:
p=getattr(proc,remaining[0])
p = getQualifiedModule(remaining[0],proc)
for m in remaining[1:]:
p+=getattr(proc,m)
p+=getQualifiedModule(m,proc)
setattr(proc,pName,cms.Path(p))
# drop empty paths
else:
Expand Down Expand Up @@ -277,8 +293,9 @@ def testNoSchedule(self):
process.f1 = cms.EDFilter("Filter")
process.f2 = cms.EDFilter("Filter2")
process.f3 = cms.EDFilter("Filter3")
process.f4 = cms.EDFilter("FIlter4")
process.p1 = cms.Path(process.a+process.b+process.f1+process.d+process.e+process.f+process.g+process.h+process.k)
process.p4 = cms.Path(process.a+process.f2+process.b+process.f1)
process.p4 = cms.Path(process.a+process.f2+process.b+~process.f1+cms.ignore(process.f4))
process.p2 = cms.Path(process.a+process.b)
process.p3 = cms.Path(process.f1)
convertToUnscheduled(process)
Expand All @@ -294,10 +311,11 @@ def testNoSchedule(self):
self.assert_(hasattr(process,'f1'))
self.assert_(hasattr(process,'f2'))
self.assert_(not hasattr(process,'f3'))
self.assert_(hasattr(process,'f4'))
self.assertEqual(process.p1.dumpPython(None),'cms.Path(process.f1+process.d+process.e+process.f+process.g+process.h+process.k)\n')
self.assertEqual(process.p2.dumpPython(None),'cms.Path()\n')
self.assertEqual(process.p3.dumpPython(None),'cms.Path(process.f1)\n')
self.assertEqual(process.p4.dumpPython(None),'cms.Path(process.f2+process.f1)\n')
self.assertEqual(process.p4.dumpPython(None),'cms.Path(process.f2+~process.f1+cms.ignore(process.f4))\n')
def testWithSchedule(self):
import FWCore.ParameterSet.Config as cms
process = cms.Process("TEST")
Expand Down