Skip to content

Commit

Permalink
Merge pull request #40736 from makortel/processAcceleratorDeleteService
Browse files Browse the repository at this point in the history
Allow ProcessAccelerators to delete Services
  • Loading branch information
cmsbuild authored Feb 10, 2023
2 parents f459c01 + ab96cfe commit 2bbe5a1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions FWCore/ParameterSet/python/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,11 @@ def __setattr__(self, label, value):
if not isinstance(value, Service):
raise TypeError("ProcessAccelerator.apply() can only set Services. Tried to set {} with label {}".format(str(type(value)), label))
setattr(self.__process, label, value)
def __delattr__(self, label):
value = getattr(self.__process, label)
if not isinstance(value, Service):
raise TypeError("ProcessAccelerator.apply() can delete only Services. Tried to del {} with label {}".format(str(type(value)), label))
delattr(self.__process, label)
def add_(self, value):
if not isinstance(value, Service):
raise TypeError("ProcessAccelerator.apply() can only add Services. Tried to set {} with label {}".format(str(type(value)), label))
Expand Down Expand Up @@ -2229,6 +2234,8 @@ def moduleTypeResolver(self, accelerators):
return self._moduleTypeResolverMaker(accelerators)
def apply(self, process, accelerators):
process.AcceleratorTestService = Service("AcceleratorTestService")
if hasattr(process, "AcceleratorTestServiceRemove"):
del process.AcceleratorTestServiceRemove
specialImportRegistry.registerSpecialImportForType(ProcessAcceleratorTest, "from test import ProcessAcceleratorTest")

class ProcessAcceleratorTest2(ProcessAccelerator):
Expand Down Expand Up @@ -4672,6 +4679,15 @@ def testProcessAccelerator(self):
self.assertFalse(p.values["@module_type_resolver"][0])
self.assertEqual("", p.values["@module_type_resolver"][1])

proc = Process("TEST")
proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
proc.add_(Service("AcceleratorTestServiceRemove"))
p = TestMakePSet()
proc.fillProcessDesc(p)
services = [x.values["@service_type"][1] for x in p.values["services"][1]]
self.assertTrue("AcceleratorTestService" in services)
self.assertFalse("AcceleratorTestServiceRemove" in services)

proc = Process("TEST")
proc.ProcessAcceleratorTest = ProcessAcceleratorTest(enabled=["test1"])
p = TestMakePSet()
Expand Down

0 comments on commit 2bbe5a1

Please sign in to comment.