-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alternative python module configuration syntax
Generates a new python file from the C++ configuration description which describes the default. This can be imported to allow a more simplified module configuration syntax.
- Loading branch information
Showing
6 changed files
with
110 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
from FWCore.Modules.modules import EventContentAnalyzer, EmptySource | ||
|
||
process = cms.Process("EMPTY") | ||
|
||
process.test = cms.EDAnalyzer("EventContentAnalyzer", listPathStatus = cms.untracked.bool(True)) | ||
process.test = EventContentAnalyzer(listPathStatus = True) | ||
|
||
process.e = cms.EndPath(process.test) | ||
|
||
#process.out = cms.OutputModule("AsciiOutputModule") | ||
#process.e2 = cms.EndPath(process.out) | ||
|
||
process.source = cms.Source("EmptySource") | ||
process.source = EmptySource() | ||
|
||
process.maxEvents.input = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
from FWCore.Framework.modules import AddIntsProducer, IntProductFilter | ||
from FWCore.Modules.modules import AsciiOutputModule | ||
from FWCore.Integration.modules import DelayedReaderThrowingSource | ||
|
||
process = cms.Process("TEST") | ||
|
||
process.source = cms.Source("DelayedReaderThrowingSource", labels = cms.untracked.vstring("test", "test2", "test3")) | ||
process.source = DelayedReaderThrowingSource( labels = ["test", "test2", "test3"]) | ||
|
||
process.getter = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag(cms.InputTag("test","","INPUTTEST"))) | ||
process.onPath = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag(cms.InputTag("test2", "", "INPUTTEST"), cms.InputTag("getter", "other"))) | ||
process.f1 = cms.EDFilter("IntProductFilter", label = cms.InputTag("onPath"), shouldProduce = cms.bool(True)) | ||
process.f2 = cms.EDFilter("IntProductFilter", label = cms.InputTag("onPath"), shouldProduce = cms.bool(True)) | ||
process.inFront = cms.EDFilter("IntProductFilter", label = cms.InputTag("test3")) | ||
process.getter = AddIntsProducer(labels = [("test","","INPUTTEST")]) | ||
process.onPath = AddIntsProducer(labels = [("test2", "", "INPUTTEST"), ("getter", "other")]) | ||
process.f1 = IntProductFilter( label = "onPath", shouldProduce = True) | ||
process.f2 = IntProductFilter( label = "onPath", shouldProduce = True) | ||
process.inFront = IntProductFilter( label = "test3") | ||
|
||
process.p1 = cms.Path(process.inFront+process.onPath+process.f1+process.f2) | ||
process.p3 = cms.Path(process.onPath+process.f1, cms.Task(process.getter)) | ||
|
||
process.p2 = cms.Path(process.onPath+process.f2) | ||
|
||
|
||
#process.dump = cms.EDAnalyzer("EventContentAnalyzer") | ||
#from FWCore.Modules.modules import EventContentAnalyzer import * | ||
#process.dump = EventContentAnalyzer() | ||
#process.p = cms.Path(process.dump) | ||
|
||
process.out = cms.OutputModule("AsciiOutputModule") | ||
process.out = AsciiOutputModule() | ||
process.e = cms.EndPath(process.out, cms.Task(process.getter)) | ||
|
||
process.maxEvents.input = 1 | ||
|
||
#process.add_(cms.Service("Tracer")) | ||
#from FWCore.Services.modules import Tracer | ||
#process.add_(Tracer()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
from os.path import sep, join | ||
import importlib | ||
|
||
class _ModuleProxy (object): | ||
def __init__(self, package, name): | ||
self._package = package | ||
self._name = name | ||
self._caller = None | ||
def __call__(self,**kwargs): | ||
if not self._caller: | ||
self._caller = getattr(importlib.import_module(self._package+'.'+self._name),self._name) | ||
return self._caller(**kwargs) | ||
|
||
|
||
def _setupProxies(fullName): | ||
_cmssw_package_name='.'.join(fullName.split(sep)[-3:-1]) | ||
basename = fullName.split(sep)[-1] | ||
pathname = fullName[:-1*len(basename)] | ||
proxies = dict() | ||
for filename in ( x for x in os.listdir(pathname) if (len(x) > 3 and x[-3:] == '.py' and x != basename and ((len(x) < 6) or (x[-6:] != 'cfi.py')))): | ||
name = filename[:-3] | ||
proxies[name] = _ModuleProxy(_cmssw_package_name, name) | ||
return proxies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters