Skip to content

Commit

Permalink
Fix bug in convertToUnscheduled with decorators
Browse files Browse the repository at this point in the history
When rebuilding a path in convertToUnscheduled, any decorator applied to a module, e.g. '~', were previously stripped away.
  • Loading branch information
Dr15Jones committed Jul 1, 2015
1 parent 6979e4d commit 5d561a6
Showing 1 changed file with 28 additions and 10 deletions.
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

0 comments on commit 5d561a6

Please sign in to comment.