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

Add support for Alpaka modules in HLT configs of CMSSW_14_0_0_pre1 or higher #85

Merged
merged 2 commits into from
Feb 28, 2024
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
283 changes: 252 additions & 31 deletions python/FWCore/ParameterSet/Config.py

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions python/FWCore/ParameterSet/MassReplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,12 @@ def testMassSearchReplaceAnyInputTag(self):
),
)
p.op = cms.EDProducer("op", src = cms.optional.InputTag, unset = cms.optional.InputTag, vsrc = cms.optional.VInputTag, vunset = cms.optional.VInputTag)
p.op2 = cms.EDProducer("op2", src = cms.optional.InputTag, unset = cms.optional.InputTag, vsrc = cms.optional.VInputTag, vunset = cms.optional.VInputTag)
p.op.src="b"
p.op.vsrc=cms.VInputTag("b")
p.s = cms.Sequence(p.a*p.b*p.c*p.sp*p.op)
p.op.vsrc = ["b"]
p.op2.src=cms.InputTag("b")
p.op2.vsrc = cms.VInputTag("b")
p.s = cms.Sequence(p.a*p.b*p.c*p.sp*p.op*p.op2)
massSearchReplaceAnyInputTag(p.s, cms.InputTag("b"), cms.InputTag("new"))
self.assertNotEqual(cms.InputTag("new"), p.b.src)
self.assertEqual(cms.InputTag("new"), p.c.src)
Expand Down Expand Up @@ -210,6 +213,8 @@ def testMassSearchReplaceAnyInputTag(self):
self.assertEqual(cms.untracked.InputTag("new"), p.sp.test2.nested.usrc)
self.assertEqual(cms.InputTag("new"), p.op.src)
self.assertEqual(cms.InputTag("new"), p.op.vsrc[0])
self.assertEqual(cms.InputTag("new"), p.op2.src)
self.assertEqual(cms.InputTag("new"), p.op2.vsrc[0])

def testMassReplaceInputTag(self):
process1 = cms.Process("test")
Expand Down
2 changes: 1 addition & 1 deletion python/FWCore/ParameterSet/MessageLogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
default = _default_pset.clone(),
cerr = _destination_base.clone(
enable = untracked.bool(True),
enableStatistics = untracked.bool(True),
enableStatistics = untracked.bool(False),
resetStatistics = untracked.bool(False),
statisticsThreshold = untracked.string('WARNING'),
INFO = untracked.PSet(
Expand Down
31 changes: 26 additions & 5 deletions python/FWCore/ParameterSet/Mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ def setIsFrozen(self):
self._isFrozen = True
def isCompatibleCMSType(self,aType):
return isinstance(self,aType)
def _checkAndReturnValueWithType(self, valueWithType):
if isinstance(valueWithType, type(self)):
return valueWithType
raise TypeError("Attempted to assign type {from_} to type {to}".format(from_ = str(type(valueWithType)), to = str(type(self))) )


class _SimpleParameterTypeBase(_ParameterTypeBase):
"""base class for parameter classes which only hold a single value"""
Expand Down Expand Up @@ -277,7 +282,7 @@ def __setattr__(self,name,value):
else:
# handle the case where users just replace with a value, a = 12, rather than a = cms.int32(12)
if isinstance(value,_ParameterTypeBase):
self.__dict__[name] = value
self.__dict__[name] = self.__dict__[name]._checkAndReturnValueWithType(value)
else:
self.__dict__[name].setValue(value)
self._isModified = True
Expand Down Expand Up @@ -579,7 +584,7 @@ def __init__(self,*arg,**args):
super(_ValidatingListBase,self).__init__(arg)
if 0 != len(args):
raise SyntaxError("named arguments ("+','.join([x for x in args])+") passsed to "+str(type(self)))
if not self._isValid(iter(self)):
if not type(self)._isValid(iter(self)):
raise TypeError("wrong types ("+','.join([str(type(value)) for value in iter(self)])+
") added to "+str(type(self)))
def __setitem__(self,key,value):
Expand All @@ -590,12 +595,13 @@ def __setitem__(self,key,value):
if not self._itemIsValid(value):
raise TypeError("can not insert the type "+str(type(value))+" in container "+self._labelIfAny())
super(_ValidatingListBase,self).__setitem__(key,value)
def _isValid(self,seq):
@classmethod
def _isValid(cls,seq):
# see if strings get reinterpreted as lists
if isinstance(seq, str):
return False
for item in seq:
if not self._itemIsValid(item):
if not cls._itemIsValid(item):
return False
return True
def _itemFromArgument(self, x):
Expand Down Expand Up @@ -753,7 +759,8 @@ def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth=""):

import unittest
class TestList(_ValidatingParameterListBase):
def _itemIsValid(self,item):
@classmethod
def _itemIsValid(cls,item):
return True
class testMixins(unittest.TestCase):
def testListConstruction(self):
Expand Down Expand Up @@ -938,5 +945,19 @@ def testSpecialImportRegistry(self):
self.assertEqual(reg.getSpecialImports(), ["import foo"])
reg.registerUse("a")
self.assertEqual(reg.getSpecialImports(), ["import bar", "import foo"])
def testInvalidTypeChange(self):
class __Test(_TypedParameterizable):
pass
class __TestTypeA(_SimpleParameterTypeBase):
def _isValid(self,value):
return True
class __TestTypeB(_SimpleParameterTypeBase):
def _isValid(self,value):
return True
pass
a = __Test("MyType",
t=__TestTypeA(1))
self.assertRaises(TypeError, lambda : setattr(a,'t',__TestTypeB(2)))


unittest.main()
5 changes: 1 addition & 4 deletions python/FWCore/ParameterSet/OrderedSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
# Copied from URL http://code.activestate.com/recipes/576694-orderedset/
# on 15 November 2016

try:
import collections.abc as collections_abc
except ImportError:
import collections as collections_abc
import collections as collections_abc

class OrderedSet(collections_abc.MutableSet):

Expand Down
Loading