Skip to content

Commit d78cbce

Browse files
committed
Add Process name, reduced configuration ID, and ParameterSet ID to the JobReport
Main motivation is to give CRAB a more stable way to retrieve the ParameterSetID than edmProvDump.
1 parent 8f4b703 commit d78cbce

25 files changed

+205
-11
lines changed

FWCore/Framework/src/EventProcessor.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,15 @@ namespace edm {
534534
processConfiguration_ = items.processConfiguration();
535535
processContext_.setProcessConfiguration(processConfiguration_.get());
536536

537+
{
538+
edm::Service<edm::JobReport> jr;
539+
if (jr.isAvailable()) {
540+
ProcessConfiguration reduced = *processConfiguration_;
541+
reduced.reduce();
542+
jr->reportProcess(reduced.processName(), reduced.id(), reduced.parameterSetID());
543+
}
544+
}
545+
537546
FDEBUG(2) << parameterSet << std::endl;
538547

539548
principalCache_.setNumberOfConcurrentPrincipals(preallocations_);

FWCore/MessageLogger/interface/JobReport.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ Changes Log 1: 2009/01/14 10:29:00, Natalia Garcia Nebot
8282
*/
8383

8484
#include "DataFormats/Provenance/interface/RunLumiEventNumber.h"
85+
#include "DataFormats/Provenance/interface/ParameterSetID.h"
86+
#include "DataFormats/Provenance/interface/ProcessConfigurationID.h"
8587
#include "FWCore/Utilities/interface/InputType.h"
8688
#include "FWCore/Utilities/interface/get_underlying_safe.h"
8789

@@ -177,8 +179,10 @@ namespace edm {
177179
};
178180

179181
struct JobReportImpl {
180-
JobReportImpl& operator=(JobReportImpl const&) = delete;
181182
JobReportImpl(JobReportImpl const&) = delete;
183+
JobReportImpl& operator=(JobReportImpl const&) = delete;
184+
JobReportImpl(JobReportImpl&&) = delete;
185+
JobReportImpl& operator=(JobReportImpl&&) = delete;
182186

183187
InputFile& getInputFileForToken(InputType inputType, Token t);
184188
OutputFile& getOutputFileForToken(Token t);
@@ -269,6 +273,11 @@ namespace edm {
269273

270274
~JobReport();
271275

276+
// Insert information about the process
277+
void reportProcess(std::string_view processName,
278+
ProcessConfigurationID const& reducedProcessID,
279+
ParameterSetID const& psetID);
280+
272281
/// Report that an input file has been opened.
273282
/// The returned Token should be used for later identification
274283
/// of this file.

FWCore/MessageLogger/src/JobReport.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,19 @@ namespace edm {
351351
temporarilyCloseXML();
352352
}
353353

354+
void JobReport::reportProcess(std::string_view processName,
355+
ProcessConfigurationID const& reducedProcessID,
356+
ParameterSetID const& psetID) {
357+
if (impl_->ost_) {
358+
*(impl_->ost_) << "\n<Process>\n";
359+
*(impl_->ost_) << " <Name>" << processName << "</Name>\n";
360+
*(impl_->ost_) << " <ReducedConfigurationID>" << reducedProcessID << "</ReducedConfigurationID>\n";
361+
*(impl_->ost_) << " <ParameterSetID>" << psetID << "</ParameterSetID>\n";
362+
*(impl_->ost_) << "</Process>\n";
363+
}
364+
temporarilyCloseXML();
365+
}
366+
354367
JobReport::Token JobReport::inputFileOpened(std::string const& physicalFileName,
355368
std::string const& logicalFileName,
356369
std::string const& catalog,

FWCore/MessageService/test/BuildFile.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@
200200
<use name="FWCore/Framework"/>
201201
</library>
202202

203+
<library file="PrintProcessInformation.cc" name="MLPrintProcessInformation">
204+
<flags EDM_PLUGIN="1"/>
205+
<use name="DataFormats/Provenance"/>
206+
<use name="FWCore/Framework"/>
207+
<use name="FWCore/MessageLogger"/>
208+
<use name="FWCore/ServiceRegistry"/>
209+
</library>
203210
</environment>
204211
<bin file="standAloneTest.cpp" name="standAloneWithMessageLogger">
205212
<use name="FWCore/MessageLogger"/>
@@ -234,6 +241,7 @@
234241

235242
<test name="unitTestsGroup_6" command="${value}.sh" foreach="u23,u27,u30,u31,u33"/>
236243

244+
<test name="TestFWCoreMessageServiceJobReport" command="testJobReport.sh"/>
237245
<bin name="makeJobReport" file="makeJobReport.cpp">
238246
<use name="boost_program_options"/>
239247
<use name="FWCore/Framework"/>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "DataFormats/Provenance/interface/ProcessConfiguration.h"
2+
#include "FWCore/Framework/interface/global/EDAnalyzer.h"
3+
#include "FWCore/Framework/interface/Event.h"
4+
#include "FWCore/Framework/interface/Frameworkfwd.h"
5+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
6+
#include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h"
7+
#include "FWCore/ServiceRegistry/interface/ProcessContext.h"
8+
#include "FWCore/ServiceRegistry/interface/StreamContext.h"
9+
10+
namespace edmtest {
11+
class PrintProcessInformation : public edm::global::EDAnalyzer<> {
12+
public:
13+
explicit PrintProcessInformation(edm::ParameterSet const&) {}
14+
15+
void analyze(edm::StreamID, edm::Event const& e, edm::EventSetup const&) const final {
16+
auto const* processConfiguration =
17+
e.moduleCallingContext()->getStreamContext()->processContext()->processConfiguration();
18+
assert(processConfiguration);
19+
auto reduced = *processConfiguration;
20+
reduced.reduce();
21+
edm::LogSystem("PrintProcessInformation")
22+
<< "Name:" << processConfiguration->processName() << "\nReducedConfigurationID:" << reduced.id()
23+
<< "\nParameterSetID:" << processConfiguration->parameterSetID();
24+
}
25+
};
26+
} // namespace edmtest
27+
28+
#include "FWCore/Framework/interface/MakerMacros.h"
29+
DEFINE_FWK_MODULE(edmtest::PrintProcessInformation);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
3+
import xml.etree.ElementTree as ET
4+
5+
quantities = ["Name", "ReducedConfigurationID", "ParameterSetID"]
6+
7+
def parsexml(fname):
8+
root = ET.parse(fname)
9+
process = root.find("Process")
10+
return {q: process.find(q).text for q in quantities}
11+
12+
def parselog(fname):
13+
ret = {}
14+
with open(fname) as f:
15+
for line in f:
16+
s = line.rstrip().split(":")
17+
if len(s) == 2:
18+
ret[s[0]] = s[1]
19+
return ret
20+
21+
def main(jobreport, log):
22+
xmldata = parsexml(jobreport)
23+
logdata = parselog(log)
24+
25+
ret = 0
26+
for q in quantities:
27+
if xmldata[q] != logdata[q]:
28+
print(f"Quantity {q}: job report '{xmldata[q]}' != log '{logdata[q]}'")
29+
ret = 1
30+
return ret
31+
32+
if __name__ == "__main__":
33+
import sys
34+
sys.exit(main(sys.argv[1], sys.argv[2]))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
s/ [0-9]?[0-9]-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-2[0-9][0-9][0-9] [0-9]?[0-9]:[0-9][0-9]:[0-9][0-9](\.[0-9][0-9][0-9])? [A-Z]?[A-Z][A-Z][A-Z]( |\t|-|$)/ {Timestamp} /
2+
s|<ReducedConfigurationID>.*?</ReducedConfigurationID>|<ReducedConfigurationID>{Value}</ReducedConfigurationID>|
3+
s|<ParameterSetID>.*?</ParameterSetID>|<ParameterSetID>{Value}</ParameterSetID>|
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import FWCore.ParameterSet.Config as cms
2+
3+
process = cms.Process("TEST")
4+
process.maxEvents.input = 1
5+
process.source = cms.Source("EmptySource")
6+
process.a = cms.EDAnalyzer("edmtest::PrintProcessInformation")
7+
process.p = cms.Path(process.a)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
function die { echo $1: status $2 ; exit $2; }
4+
5+
cmsRun -j fwjr.xml ${SCRAM_TEST_PATH}/jobreport_cfg.py > log.txt 2>&1 || die "cmsRun jobreport_cfg.py failed" $?
6+
${SCRAM_TEST_PATH}/compareJobReportToOutput.py fwjr.xml log.txt || die "Job report comparison to log failed" $?
7+
8+

FWCore/MessageService/test/u1.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ status=0
88
rm -f u1_errors.log u1_warnings.log u1_infos.log u1_debugs.log u1_default.log u1_job_report.mxml
99

1010
cmsRun -j u1_job_report.mxml ${SCRAM_TEST_PATH}/u1_cfg.py || exit $?
11+
edmFjrDump u1_job_report.mxml
1112

1213
for file in u1_errors.log u1_warnings.log u1_infos.log u1_debugs.log u1_default.log u1_job_report.mxml
1314
do

0 commit comments

Comments
 (0)