Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion GeneratorInterface/Core/plugins/ExternalGeneratorFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class ExternalGeneratorFilter : public edm::global::EDFilter<edm::StreamCache<ex
std::string const config_;
bool const verbose_;
unsigned int waitTime_;
std::string const extraConfig_;

//This is set at beginStream and used for globalBeginRun
//The framework guarantees that non of those can happen concurrently
Expand All @@ -226,7 +227,8 @@ ExternalGeneratorFilter::ExternalGeneratorFilter(edm::ParameterSet const& iPSet)
lumiInfoToken_{produces<GenLumiInfoProduct, edm::Transition::EndLuminosityBlock>()},
config_{iPSet.getUntrackedParameter<std::string>("@python_config")},
verbose_{iPSet.getUntrackedParameter<bool>("_external_process_verbose_")},
waitTime_{iPSet.getUntrackedParameter<unsigned int>("_external_process_waitTime_")} {}
waitTime_{iPSet.getUntrackedParameter<unsigned int>("_external_process_waitTime_")},
extraConfig_{iPSet.getUntrackedParameter<std::string>("_external_process_extraConfig_")} {}

std::unique_ptr<externalgen::StreamCache> ExternalGeneratorFilter::beginStream(edm::StreamID iID) const {
auto const label = moduleDescription().moduleLabel();
Expand All @@ -241,6 +243,10 @@ process = TestProcess()
config += R"_(
process.add_(cms.Service("InitRootHandlers", UnloadRootSigHandler=cms.untracked.bool(True)))
)_";
if (not extraConfig_.empty()) {
config += "\n";
config += extraConfig_;
}

auto cache = std::make_unique<externalgen::StreamCache>(config, iID.value(), verbose_, waitTime_);
if (iID.value() == 0) {
Expand Down
14 changes: 12 additions & 2 deletions GeneratorInterface/Core/python/ExternalGeneratorFilter.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import FWCore.ParameterSet.Config as cms

class ExternalGeneratorFilter(cms.EDFilter):
def __init__(self, prod, _external_process_waitTime_ = cms.untracked.uint32(60), _external_process_verbose_ = cms.untracked.bool(False)):
def __init__(self, prod, _external_process_waitTime_ = cms.untracked.uint32(60), _external_process_verbose_ = cms.untracked.bool(False),
_external_process_esModules_ = cms.vstring()):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: although I called this _external_process_esModules_, technically the module names of any type of plugin could be passed and it would work. It only really makes sense for ES modules (and maybe Services for testing). If you'd rather, this could be changed to _external_process_components_ or something else to capture what is technically possible rather than what I think is most reasonable.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the proposal components as it might avoid confusion.

self.__dict__['_external_process_verbose_']=_external_process_verbose_
self.__dict__['_external_process_waitTime_']=_external_process_waitTime_
self.__dict__['_external_process_esModules_'] = _external_process_esModules_
self.__dict__['_prod'] = prod
super(cms.EDFilter,self).__init__('ExternalGeneratorFilter')
def __setattr__(self, name, value):
Expand Down Expand Up @@ -31,6 +33,13 @@ def insertInto(self, parameterSet, myname):
newpset.addString(False,"@python_config", self._prod.dumpPython())
newpset.addBool(False,"_external_process_verbose_", self._external_process_verbose_.value())
newpset.addUInt32(False,"_external_process_waitTime_", self._external_process_waitTime_.value())
newpset.addVString(True, "_external_process_esModules_", self._external_process_esModules_.value())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new parameter is tracked since the ES modules loaded affect the physics.


extraConfig =''
for x in self._external_process_esModules_.value():
extraConfig += "process."+x+"="+parameterSet.getTopPSet_(x).dumpPython()
extraConfig += '\n'
newpset.addString(False, "_external_process_extraConfig_", extraConfig)
self._prod.insertContentsInto(newpset)
parameterSet.addPSet(True, self.nameInProcessDesc_(myname), newpset)
def dumpPython(self, options=cms.PrintOptions()):
Expand All @@ -40,7 +49,8 @@ def dumpPython(self, options=cms.PrintOptions()):
result += "\n"+options.indentation() + self._prod.dumpPython(options)
result +=options.indentation()+",\n"
result += options.indentation() + "_external_process_waitTime_ = " + self._external_process_waitTime_.dumpPython(options) + ',\n'
result += options.indentation() + "_external_process_verbose_ = " + self._external_process_verbose_.dumpPython(options) + ','
result += options.indentation() + "_external_process_verbose_ = " + self._external_process_verbose_.dumpPython(options) + ',\n'
result += options.indentation() + "_external_process_esModules_ =" + self._external_process_esModules_.dumpPython(options) + ','
options.unindent()
result += "\n)\n"
return result
Expand Down