Skip to content

Commit

Permalink
Fixed replace with FinalPath
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr15Jones committed Feb 11, 2022
1 parent 18d26b4 commit b1f49c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 7 additions & 2 deletions FWCore/ParameterSet/python/Config.py
Expand Up @@ -2719,17 +2719,22 @@ def testFinalPath(self):
self.assertRaises(TypeError,FinalPath,p.es)

t = FinalPath()
self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.FinalPath()\n')
self.assertEqual(t.dumpPython(PrintOptions()), 'cms.FinalPath()\n')

t = FinalPath(p.a)
self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.FinalPath(process.a)\n')
self.assertEqual(t.dumpPython(PrintOptions()), 'cms.FinalPath(process.a)\n')

self.assertRaises(TypeError, FinalPath, Task())
self.assertRaises(TypeError, FinalPath, p.a, Task())

p.prod = EDProducer("prodName")
p.t1 = Task(p.prod)
self.assertRaises(TypeError, FinalPath, p.a, p.t1, Task(), p.t1)

p.t = FinalPath(p.a)
p.a = OutputModule("ReplacedOutputModule")
self.assertEqual(p.t.dumpPython(PrintOptions()), 'cms.FinalPath(process.a)\n')

def testCloneSequence(self):
p = Process("test")
a = EDAnalyzer("MyAnalyzer")
Expand Down
12 changes: 10 additions & 2 deletions FWCore/ParameterSet/python/SequenceTypes.py
Expand Up @@ -450,8 +450,9 @@ def replace(self, original, replacement):
self.visit(v)
if v.didReplace():
self._seq = v.result(self)[0]
self._tasks.clear()
self.associate(*v.result(self)[1])
if v.result(self)[1]:
self._tasks.clear()
self.associate(*v.result(self)[1])
return v.didReplace()
def _replaceIfHeldDirectly(self,original,replacement):
"""Only replaces an 'original' with 'replacement' if 'original' is directly held.
Expand Down Expand Up @@ -2103,6 +2104,13 @@ def testReplace(self):
t3 = Task(m5)
t2.replace(m2,t3)
self.assertTrue(t2.dumpPython() == "cms.Task(process.m1, process.m3, process.m5)\n")

fp = FinalPath()
fp.replace(m1,m2)
self.assertEqual(fp.dumpPython(), "cms.FinalPath()\n")
fp = FinalPath(m1)
fp.replace(m1,m2)
self.assertEqual(fp.dumpPython(), "cms.FinalPath(process.m2)\n")

def testReplaceIfHeldDirectly(self):
m1 = DummyModule("m1")
Expand Down

0 comments on commit b1f49c8

Please sign in to comment.