Skip to content

Commit

Permalink
Move MessageLogger default configuration to be part of Process
Browse files Browse the repository at this point in the history
  • Loading branch information
makortel committed Sep 17, 2021
1 parent 0db308a commit fc16ab2
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 147 deletions.
4 changes: 1 addition & 3 deletions FWCore/MessageLogger/python/MessageLogger_cfi.py
@@ -1,4 +1,2 @@
import FWCore.ParameterSet.Config as cms

from FWCore.MessageService.MessageLogger_cfi import *
from FWCore.ParameterSet.MessageLogger import *

92 changes: 1 addition & 91 deletions FWCore/MessageService/python/MessageLogger_cfi.py
@@ -1,91 +1 @@
import FWCore.ParameterSet.Config as cms

_category = cms.optional.untracked.PSetTemplate(
reportEvery = cms.untracked.int32(1),
limit = cms.optional.untracked.int32,
timespan = cms.optional.untracked.int32
)

_destination_base = cms.untracked.PSet(
noLineBreaks = cms.optional.untracked.bool,
noTimeStamps = cms.optional.untracked.bool,
lineLength = cms.optional.untracked.int32,
threshold = cms.optional.untracked.string,
statisticsThreshold = cms.optional.untracked.string,
allowAnyLabel_ = _category
)
_destination_no_stat = _destination_base.clone(
enableStatistics = cms.untracked.bool(False),
resetStatistics = cms.untracked.bool(False)
)

_file_destination = cms.optional.untracked.PSetTemplate(
noLineBreaks = cms.optional.untracked.bool,
noTimeStamps = cms.optional.untracked.bool,
lineLength = cms.optional.untracked.int32,
threshold = cms.optional.untracked.string,
statisticsThreshold = cms.optional.untracked.string,
enableStatistics = cms.untracked.bool(False),
resetStatistics = cms.untracked.bool(False),
filename = cms.optional.untracked.string,
extension = cms.optional.untracked.string,
output = cms.optional.untracked.string,
allowAnyLabel_ = _category
)

_default_pset = cms.untracked.PSet(
reportEvery = cms.untracked.int32(1),
limit = cms.optional.untracked.int32,
timespan = cms.optional.untracked.int32,

noLineBreaks = cms.untracked.bool(False),
noTimeStamps = cms.untracked.bool(False),
lineLength = cms.untracked.int32(80),
threshold = cms.untracked.string("INFO"),
statisticsThreshold = cms.untracked.string("INFO"),
allowAnyLabel_ = _category
)


MessageLogger = cms.Service("MessageLogger",
suppressWarning = cms.untracked.vstring(),
suppressFwkInfo = cms.untracked.vstring(),
suppressInfo = cms.untracked.vstring(),
suppressDebug = cms.untracked.vstring(),
debugModules = cms.untracked.vstring(),
cout = _destination_no_stat.clone(
enable = cms.untracked.bool(False)
),
default = _default_pset.clone(),
cerr = _destination_base.clone(
enable = cms.untracked.bool(True),
enableStatistics = cms.untracked.bool(True),
resetStatistics = cms.untracked.bool(False),
statisticsThreshold = cms.untracked.string('WARNING'),
INFO = cms.untracked.PSet(
limit = cms.untracked.int32(0)
),
noTimeStamps = cms.untracked.bool(False),
FwkReport = cms.untracked.PSet(
reportEvery = cms.untracked.int32(1),
limit = cms.untracked.int32(10000000)
),
default = cms.untracked.PSet(
limit = cms.untracked.int32(10000000)
),
Root_NoDictionary = cms.untracked.PSet(
limit = cms.untracked.int32(0)
),
FwkSummary = cms.untracked.PSet(
reportEvery = cms.untracked.int32(1),
limit = cms.untracked.int32(10000000)
),
threshold = cms.untracked.string('INFO')
),
files = cms.untracked.PSet(
allowAnyLabel_ = _file_destination
),
allowAnyLabel_ = _category
)


from FWCore.ParameterSet.MessageLogger import MessageLogger
123 changes: 119 additions & 4 deletions FWCore/ParameterSet/python/Config.py
Expand Up @@ -18,6 +18,7 @@
from .SequenceTypes import *
from .SequenceTypes import _ModuleSequenceType, _Sequenceable #extend needs it
from .SequenceVisitors import PathValidator, EndPathValidator, ScheduleTaskValidator, NodeVisitor, CompositeVisitor, ModuleNamesFromGlobalsVisitor
from .MessageLogger import MessageLogger
from . import DictTypes

from .ExceptionHandling import *
Expand Down Expand Up @@ -137,6 +138,11 @@ def __init__(self,name,*Mods):
self.options = Process.defaultOptions_()
self.maxEvents = Process.defaultMaxEvents_()
self.maxLuminosityBlocks = Process.defaultMaxLuminosityBlocks_()
# intentionally not cloned to ensure that everyone taking
# MessageLogger still via
# FWCore.Message(Logger|Service).MessageLogger_cfi
# use the very same MessageLogger object.
self.MessageLogger = MessageLogger
for m in self.__modifiers:
m._setChosen()

Expand Down Expand Up @@ -1479,6 +1485,8 @@ def __init__(self,process, SelectEvents = untracked.PSet(), outputCommands = unt
self.__process = process
self.__SelectEvents = SelectEvents
self.__outputCommands = outputCommands
# Need to remove MessageLogger from the subprocess now that MessageLogger is always present
del self.__process.MessageLogger
def dumpPython(self, options=PrintOptions()):
out = "parentProcess"+str(hash(self))+" = process\n"
out += self.__process.dumpPython()
Expand Down Expand Up @@ -1885,9 +1893,9 @@ def testProcessInsertion(self):
p.a = EDAnalyzer("MyAnalyzer")
self.assertTrue( 'a' in p.analyzers_() )
self.assertTrue( 'a' in p.analyzers)
p.add_(Service("MessageLogger"))
self.assertTrue('MessageLogger' in p.services_())
self.assertEqual(p.MessageLogger.type_(), "MessageLogger")
p.add_(Service("SomeService"))
self.assertTrue('SomeService' in p.services_())
self.assertEqual(p.SomeService.type_(), "SomeService")
p.Tracer = Service("Tracer")
self.assertTrue('Tracer' in p.services_())
self.assertRaises(TypeError, setattr, *(p,'b',"this should fail"))
Expand Down Expand Up @@ -2036,6 +2044,101 @@ def testProcessDumpPython(self):
wantSummary = cms.untracked.bool(False)
)
process.MessageLogger = cms.Service("MessageLogger",
cerr = cms.untracked.PSet(
FwkReport = cms.untracked.PSet(
limit = cms.untracked.int32(10000000),
reportEvery = cms.untracked.int32(1)
),
FwkSummary = cms.untracked.PSet(
limit = cms.untracked.int32(10000000),
reportEvery = cms.untracked.int32(1)
),
INFO = cms.untracked.PSet(
limit = cms.untracked.int32(0)
),
Root_NoDictionary = cms.untracked.PSet(
limit = cms.untracked.int32(0)
),
default = cms.untracked.PSet(
limit = cms.untracked.int32(10000000)
),
enable = cms.untracked.bool(True),
enableStatistics = cms.untracked.bool(True),
lineLength = cms.optional.untracked.int32,
noLineBreaks = cms.optional.untracked.bool,
noTimeStamps = cms.untracked.bool(False),
resetStatistics = cms.untracked.bool(False),
statisticsThreshold = cms.untracked.string('WARNING'),
threshold = cms.untracked.string('INFO'),
allowAnyLabel_=cms.optional.untracked.PSetTemplate(
limit = cms.optional.untracked.int32,
reportEvery = cms.untracked.int32(1),
timespan = cms.optional.untracked.int32
)
),
cout = cms.untracked.PSet(
enable = cms.untracked.bool(False),
enableStatistics = cms.untracked.bool(False),
lineLength = cms.optional.untracked.int32,
noLineBreaks = cms.optional.untracked.bool,
noTimeStamps = cms.optional.untracked.bool,
resetStatistics = cms.untracked.bool(False),
statisticsThreshold = cms.optional.untracked.string,
threshold = cms.optional.untracked.string,
allowAnyLabel_=cms.optional.untracked.PSetTemplate(
limit = cms.optional.untracked.int32,
reportEvery = cms.untracked.int32(1),
timespan = cms.optional.untracked.int32
)
),
debugModules = cms.untracked.vstring(),
default = cms.untracked.PSet(
limit = cms.optional.untracked.int32,
lineLength = cms.untracked.int32(80),
noLineBreaks = cms.untracked.bool(False),
noTimeStamps = cms.untracked.bool(False),
reportEvery = cms.untracked.int32(1),
statisticsThreshold = cms.untracked.string('INFO'),
threshold = cms.untracked.string('INFO'),
timespan = cms.optional.untracked.int32,
allowAnyLabel_=cms.optional.untracked.PSetTemplate(
limit = cms.optional.untracked.int32,
reportEvery = cms.untracked.int32(1),
timespan = cms.optional.untracked.int32
)
),
files = cms.untracked.PSet(
allowAnyLabel_=cms.optional.untracked.PSetTemplate(
enableStatistics = cms.untracked.bool(False),
extension = cms.optional.untracked.string,
filename = cms.optional.untracked.string,
lineLength = cms.optional.untracked.int32,
noLineBreaks = cms.optional.untracked.bool,
noTimeStamps = cms.optional.untracked.bool,
output = cms.optional.untracked.string,
resetStatistics = cms.untracked.bool(False),
statisticsThreshold = cms.optional.untracked.string,
threshold = cms.optional.untracked.string,
allowAnyLabel_=cms.optional.untracked.PSetTemplate(
limit = cms.optional.untracked.int32,
reportEvery = cms.untracked.int32(1),
timespan = cms.optional.untracked.int32
)
)
),
suppressDebug = cms.untracked.vstring(),
suppressFwkInfo = cms.untracked.vstring(),
suppressInfo = cms.untracked.vstring(),
suppressWarning = cms.untracked.vstring(),
allowAnyLabel_=cms.optional.untracked.PSetTemplate(
limit = cms.optional.untracked.int32,
reportEvery = cms.untracked.int32(1),
timespan = cms.optional.untracked.int32
)
)
""")
p = Process("test")
p.a = EDAnalyzer("MyAnalyzer")
Expand Down Expand Up @@ -2842,7 +2945,19 @@ def testSubProcess(self):
process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet(
), outputCommands = cms.untracked.vstring()))"""
equalD = equalD.replace("parentProcess","parentProcess"+str(hash(process.subProcesses_()[0])))
self.assertEqual(_lineDiff(d,Process('Parent').dumpPython()+Process('Child').dumpPython()),equalD)
# SubProcesses are dumped before Services, so in order to
# craft the dump of the Parent and Child manually the dump
# of the Parent needs to be split at the MessageLogger
# boundary (now when it is part of Process by default),
# and insert the dump of the Child between the top part of
# the Parent (before MessageLogger) and the bottom part of
# the Parent (after and including MessageLogger)
messageLoggerSplit = 'process.MessageLogger = cms.Service'
parentDumpSplit = Process('Parent').dumpPython().split(messageLoggerSplit)
childProcess = Process('Child')
del childProcess.MessageLogger
combinedDump = parentDumpSplit[0] + childProcess.dumpPython() + messageLoggerSplit + parentDumpSplit[1]
self.assertEqual(_lineDiff(d, combinedDump), equalD)
p = TestMakePSet()
process.fillProcessDesc(p)
self.assertEqual((True,['a']),p.values["subProcesses"][1][0].values["process"][1].values['@all_modules'])
Expand Down
93 changes: 93 additions & 0 deletions FWCore/ParameterSet/python/MessageLogger.py
@@ -0,0 +1,93 @@
#import FWCore.ParameterSet.Config as cms
from .Types import *
from .Modules import Service

_category = optional.untracked.PSetTemplate(
reportEvery = untracked.int32(1),
limit = optional.untracked.int32,
timespan = optional.untracked.int32
)

_destination_base = untracked.PSet(
noLineBreaks = optional.untracked.bool,
noTimeStamps = optional.untracked.bool,
lineLength = optional.untracked.int32,
threshold = optional.untracked.string,
statisticsThreshold = optional.untracked.string,
allowAnyLabel_ = _category
)
_destination_no_stat = _destination_base.clone(
enableStatistics = untracked.bool(False),
resetStatistics = untracked.bool(False)
)

_file_destination = optional.untracked.PSetTemplate(
noLineBreaks = optional.untracked.bool,
noTimeStamps = optional.untracked.bool,
lineLength = optional.untracked.int32,
threshold = optional.untracked.string,
statisticsThreshold = optional.untracked.string,
enableStatistics = untracked.bool(False),
resetStatistics = untracked.bool(False),
filename = optional.untracked.string,
extension = optional.untracked.string,
output = optional.untracked.string,
allowAnyLabel_ = _category
)

_default_pset = untracked.PSet(
reportEvery = untracked.int32(1),
limit = optional.untracked.int32,
timespan = optional.untracked.int32,

noLineBreaks = untracked.bool(False),
noTimeStamps = untracked.bool(False),
lineLength = untracked.int32(80),
threshold = untracked.string("INFO"),
statisticsThreshold = untracked.string("INFO"),
allowAnyLabel_ = _category
)


MessageLogger = Service("MessageLogger",
suppressWarning = untracked.vstring(),
suppressFwkInfo = untracked.vstring(),
suppressInfo = untracked.vstring(),
suppressDebug = untracked.vstring(),
debugModules = untracked.vstring(),
cout = _destination_no_stat.clone(
enable = untracked.bool(False)
),
default = _default_pset.clone(),
cerr = _destination_base.clone(
enable = untracked.bool(True),
enableStatistics = untracked.bool(True),
resetStatistics = untracked.bool(False),
statisticsThreshold = untracked.string('WARNING'),
INFO = untracked.PSet(
limit = untracked.int32(0)
),
noTimeStamps = untracked.bool(False),
FwkReport = untracked.PSet(
reportEvery = untracked.int32(1),
limit = untracked.int32(10000000)
),
default = untracked.PSet(
limit = untracked.int32(10000000)
),
Root_NoDictionary = untracked.PSet(
limit = untracked.int32(0)
),
FwkSummary = untracked.PSet(
reportEvery = untracked.int32(1),
limit = untracked.int32(10000000)
),
threshold = untracked.string('INFO')
),
files = untracked.PSet(
allowAnyLabel_ = _file_destination
),
allowAnyLabel_ = _category
)


0 comments on commit fc16ab2

Please sign in to comment.