Warning, /FWCore/MessageService/doc/cfg_validation.txt is written in an unsupported language. File is not indexed.
0001 Design of validation for the cfg PSet for the MessageService
0002 ---------------------------------------------------------
0003
0004 The following errors in configuring the message service
0005 should be detected and reported rather than proceeding
0006 with a job, because the mysterious behavior they cause
0007 is too tough to track down by hand:
0008
0009 At the main level, only the following PSets are allowed:
0010 A destination, as listed in the vstring destinations
0011 A category, as listed in the vstring categories or messageIDs
0012 One of the following keywords, which are valid as PSets at the main level
0013 default
0014 Note: The meaning of default as a PSet at the main level is that
0015 of a DESTINATION PSet, not a category PSet. However, for the
0016 default desitnation,
0017
0018 At the main level, only the following vstrings are allowed:
0019 categories vstring
0020 messageIDs vstring
0021 fwkJobReports vstring
0022 destinations vstring
0023 statistics vstring
0024
0025 The following are errors:
0026 In the destinations vstring, duplicate names.
0027 In the statistics vstring, duplicate names.
0028 In the fwkJobReports vstring, duplicate names.
0029 In the categories vstring, duplicate names or names matching one of the
0030 destinations or statistics or fwkJobReports or a keyword.
0031 Any destination or category is used as anything other than a PSet
0032
0033 debugModules vstring
0034 suppressInfo vstring
0035 suppressFwkInfo vstring
0036 suppressDebug vstring
0037 suppressWarning vstring
0038
0039 The following are errors:
0040 Use of wildcards with suppressInfo or suppressWarning or suppressDebug.
0041 suppressDebug unless debugModules = "*"
0042 More than one debugModules if one is "*"
0043
0044
0045 At the main level, only the following non-PSets non-vstrings are allowed:
0046 messageSummaryToJobReport bool
0047 generate_preconfiguration_message string
0048 threshold string only certain values
0049
0050 Within a destination PSet, only the following PSets are allowed:
0051 A category, as listed in the vstring categories or messageIDs
0052 One of the following keywords, which are valid as PSets at this level
0053 default
0054 ERROR
0055 WARNING
0056 INFO
0057 DEBUG
0058
0059 Within a destination PSet, only the following non-PSets are allowed:
0060 placeholder bool forbids others (because it will just return)!
0061 threshold string only certain values
0062 noLineBreaks bool
0063 lineLength int
0064 noTimeStamps bool
0065 output string
0066 filename string
0067 extension string
0068
0069 Within a default PSet at the main level (which behaves much like a destination
0070 PSet), only the following PSets are allowed:
0071 A category, as listed in the vstring categories or messageIDs
0072 One of the following keywords, which are valid as PSets at this level
0073 ERROR
0074 WARNING
0075 INFO
0076 DEBUG
0077 (Note that default is NOT present here)
0078
0079 Within a default PSet at the main level, only the following non-PSets are
0080 allowed:
0081 placeholder bool forbids others (because it will just return)!
0082 threshold string only certain values
0083 noLineBreaks bool
0084 lineLength int
0085 noTimeStamps bool
0086 And the following, which stem from being able to establish defaults
0087 for categories:
0088 limit int
0089 reportEvery int
0090 timespan int
0091
0092 Within a statistics PSet, only the following (all non-PSets) are allowed:
0093 placeholder bool
0094 output string
0095 filename string
0096 extension string
0097 reset bool
0098
0099 Within the fwkJobReport PSet only the following non-PSets are allowed:
0100 placeholder bool
0101 output string
0102 filename string
0103 extension string
0104
0105
0106 Within a severity PSet, whether or not it is in the main or nested in a
0107 destination PSet,only the following are allowed:
0108 limit int
0109 reportEvery int
0110 timespan int
0111 threshold int
0112
0113 Within a category PSet, whether or not this is the default category PSet,
0114 and whether or not it is in the main or nested in a destination PSet,
0115 only the following are allowed:
0116 limit int
0117 reportEvery int
0118 timespan int
0119
0120
0121 Not allowed:
0122
0123 Use of filename or extension of cerr or cout. (But output can be cerr or cout.)
0124
0125 In the destinations vstring, duplicate names.
0126
0127 In the statistics vstring, duplicate names, or cerr when destinations has
0128 cout or vice-versa.
0129
0130 In the fwkJobReports vstring, duplicate names.
0131
0132 In the categories vstring, duplicate names or names matching one of the
0133 destinations or statistics or a keyword.
0134
0135 Any destination or category is used as anything other than a PSet
0136
0137 Use of wildcards with suppressInfo or suppressWarning or suppressDebug not
0138 allowed.
0139
0140 Anything tracked is not allowed.
0141
0142 The following is strongly discouraged unless the intent is to redirect
0143 cout and cerr into different files:
0144 In the destinations vstring, presence of both cerr and cout.
0145 However, this is NOT flagged as a flaw because it can be legit.
0146
0147
0148
0149
0150
0151 ==========================================================================
0152
0153 Where does this validation get done?
0154
0155 Don't want all the modules to have been created (significant work into the job)
0156 but do want the services, particularly Message service and Job Report, to have
0157 started.
0158
0159 Partial Answer: The validation should be done before or during
0160 preModuleConstruction and preSourceConstruction, which should
0161 (possibly issue a message and) throw if there is a problem.
0162
0163 However, the PSet supplied to the ctor is no longer trivially available at
0164 that point. Although it could be saved, there would be potential snags:
0165 * Saving by reference suffers a tiny risk of the PSet goign away.
0166 * Saving by copying begs the question of what can and can't be asked of a copy.
0167 * Saving the PSet ID should be airtight, but it may be a bit convoluted
0168 (according to jbk) to re-obtain the PSet from the ID.
0169
0170 The solution is to do the validation -- and store the results -- in the
0171 MessageService::MessageLogger ctor. But we don't throw in that ctor, because
0172 that would squelch operation of the logger, which assumedly is "good enough"
0173 despite the unintended behavior due to errors in the configuration.
0174 Instead, we **check** the result in preModuleConstruction or
0175 preSourceConstruction, whichever happens first.
0176
0177 ============================================================================
0178
0179 Working with a PSet:
0180
0181 The following (in addition to getParameter and getUntrackedParameter<T>) are
0182 potentially useful for validation:
0183
0184 template <typename T>
0185 std::vector<std::string> getParameterNamesForType(bool trackiness =
0186 true) const ;
0187 ParameterSet trackedPart() const;
0188 bool empty() const;
0189
0190 (the above two in tandem give us a way to check that everything is
0191 untracked)
0192
0193
0194 // Return the names of all parameters of type ParameterSet,
0195 // pushing the names into the argument 'output'. Return the number
0196 // of names pushed into the vector. If 'trackiness' is true, we
0197 // return tracked parameters; if 'trackiness' is false, w return
0198 // untracked parameters.
0199 size_t getParameterSetNames(std::vector<std::string>& output,
0200 bool trackiness = true) const;
0201
0202
0203
0204 /// checks if a parameter exists
0205 bool exists(std::string const& parameterName) const;
0206
0207 /// checks if a parameter exists as a given type
0208 template <typename T>
0209 bool existsAs(std::string const& parameterName, bool trackiness=true) const {
0210 std::vector<std::string> names = getParameterNamesForType<T>(trackiness);
0211 return std::find(names.begin(), names.end(), parameterName) != names.end();
0212 }
0213
0214
0215
0216
0217 ============================================================================
0218
0219 Code plan:
0220
0221 Each type of PSet and collection can be validated separately. So for
0222 example, we have validateDestinationPSet(). And the various overall lists
0223 can be validated in context of the other lists.
0224
0225 We ask whether a parameter exists as the expected type before looking at
0226 its value; that way, we can see if it is there but with the wrong type.
0227