Skip to content

Commit

Permalink
Pass PSet or dict to Module proxy
Browse files Browse the repository at this point in the history
When using new syntax to create a module, can now pass a PSet or
dict in the same way as one could using the old syntax.
  • Loading branch information
Dr15Jones committed Sep 19, 2024
1 parent 8de9874 commit e49d999
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions FWCore/ParameterSet/python/ModulesProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ def __init__(self, package, name):
self._package = package
self._name = name
self._caller = None
def __call__(self,**kwargs):
def __call__(self,*arg, **kwargs):
if not self._caller:
self._caller = getattr(importlib.import_module(self._package+'.'+self._name),self._name)
return self._caller(**kwargs)
return self._caller(*arg, **kwargs)


def _setupProxies(fullName:str):
Expand Down
7 changes: 4 additions & 3 deletions FWCore/ParameterSet/src/ConfigurationDescriptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ namespace edm {
}
outFile << "import FWCore.ParameterSet.Config as cms\n\n";
outFile << "def " << pluginName
<< "(**kwargs):\n"
<< "(*args, **kwargs):\n"
" mod = cms."
<< baseType_ << "('" << pluginName_ << "'";

Expand All @@ -201,8 +201,9 @@ namespace edm {
iDesc.writeCfi(outFile, startWithComma, indentation, ops);

outFile << ")\n"
" for k,v in kwargs.items():\n"
" setattr(mod, k, v)\n"
" for a in args:\n"
" mod.update_(a)\n"
" mod.update_(kwargs)\n"
" return mod\n";

outFile.close();
Expand Down

0 comments on commit e49d999

Please sign in to comment.