Skip to content

Commit

Permalink
Add temporary failure element to Framework Job Report
Browse files Browse the repository at this point in the history
Until the job report finishes, we add a FrameworkError element to denote that if the job suddenly ends the error will be present. When job completes successfully or with another error, that temporary element is not written.
The new error was added to edm::errors.
  • Loading branch information
Dr15Jones committed Aug 16, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent e5b06f9 commit dddfd09
Showing 19 changed files with 45 additions and 2 deletions.
1 change: 1 addition & 0 deletions FWCore/MessageLogger/interface/JobReport.h
Original file line number Diff line number Diff line change
@@ -430,6 +430,7 @@ namespace edm {
void temporarilyCloseXML();
edm::propagate_const<std::unique_ptr<JobReportImpl>> impl_;
std::mutex write_mutex;
bool errorLogged_ = false;
};

std::ostream& operator<<(std::ostream& os, JobReport::InputFile const& f);
28 changes: 26 additions & 2 deletions FWCore/MessageLogger/src/JobReport.cc
Original file line number Diff line number Diff line change
@@ -302,18 +302,41 @@ namespace edm {
}
}

static constexpr std::string_view kJobReportEndElement = "</FrameworkJobReport>\n";
static constexpr int kMinSizeOfComment = 8;

JobReport::~JobReport() {
impl_->flushFiles();
if (impl_->ost_) {
*(impl_->ost_) << "</FrameworkJobReport>\n" << std::flush;
//are we actually at the end of the file?
auto pos = impl_->ost_->tellp();
impl_->ost_->seekp(0, std::ios_base::end);
auto endpos = impl_->ost_->tellp();
impl_->ost_->seekp(pos);
if ((endpos - pos) > static_cast<long int>(kJobReportEndElement.size())) {
//need to add some padding so use a comment element
// comment is used since white spaces are converted to a special node
// while comments are usually ignored by xml parsers
auto padding = (endpos - pos) - (kJobReportEndElement.size() + kMinSizeOfComment);
*(impl_->ost_) << "<!--";
for (int i = padding; i > 0; --i) {
(*impl_->ost_) << ' ';
}
*(impl_->ost_) << "-->\n";
}
*(impl_->ost_) << kJobReportEndElement << std::flush;
}
}

void JobReport::temporarilyCloseXML() {
if (impl_->ost_) {
//remember where we were
auto pos = impl_->ost_->tellp();
*(impl_->ost_) << "</FrameworkJobReport>\n" << std::flush;
if (not errorLogged_) {
*(impl_->ost_) << "<FrameworkError ExitStatus=\"8901\" Type=\"UnexpectedJobTermination\"/>\n";
}
*(impl_->ost_) << kJobReportEndElement << std::flush;

//overwrite above during next write.
impl_->ost_->seekp(pos);
}
@@ -507,6 +530,7 @@ namespace edm {
if (impl_->ost_) {
{
std::lock_guard<std::mutex> lock(write_mutex);
errorLogged_ = true;
std::ostream& msg = *(impl_->ost_);
msg << "<FrameworkError ExitStatus=\"" << exitCode << "\" Type=\"" << shortDesc << "\" >\n";
msg << "<![CDATA[\n" << longDesc << "\n]]>\n";
Original file line number Diff line number Diff line change
@@ -8,4 +8,5 @@

<GeneratorInfo>
</GeneratorInfo>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
1 change: 1 addition & 0 deletions FWCore/MessageService/test/unit_test_outputs/u27FJR.xml
Original file line number Diff line number Diff line change
@@ -10,4 +10,5 @@
<LogSystem_LogAbsolute Value="0" />
<LogWarnng_LogPrint Value="0" />
</MessageSummary>
<!-- -->
</FrameworkJobReport>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<FrameworkJobReport>
<!-- -->
</FrameworkJobReport>
2 changes: 2 additions & 0 deletions FWCore/Utilities/interface/EDMException.h
Original file line number Diff line number Diff line change
@@ -72,6 +72,8 @@ namespace edm {

EventGenerationFailure = 8501,

UnexpectedJobTermination = 8901,

CaughtSignal = 9000
};

1 change: 1 addition & 0 deletions FWCore/Utilities/src/EDMException.cc
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ namespace edm {
FILLENTRY(UnavailableAccelerator),
FILLENTRY(ExternalFailure),
FILLENTRY(EventGenerationFailure),
FILLENTRY(UnexpectedJobTermination),
FILLENTRY(CaughtSignal)};
static const std::string kUnknownCode("unknownCode");
} // namespace errors
1 change: 1 addition & 0 deletions IOPool/Common/test/proper_RLfjr_output
Original file line number Diff line number Diff line change
@@ -81,4 +81,5 @@
<ReadBranches>
</ReadBranches>

<!-- -->
</FrameworkJobReport>
1 change: 1 addition & 0 deletions IOPool/Common/test/proper_Rfjr_output
Original file line number Diff line number Diff line change
@@ -77,4 +77,5 @@
<ReadBranches>
</ReadBranches>

<!-- -->
</FrameworkJobReport>
1 change: 1 addition & 0 deletions IOPool/Common/test/proper_fjr_output
Original file line number Diff line number Diff line change
@@ -83,4 +83,5 @@
<Branch Name="edmtestThings_Thing__TESTPROD." ReadCount="35"/>
</ReadBranches>

<!-- -->
</FrameworkJobReport>
1 change: 1 addition & 0 deletions IOPool/Common/test/proper_fjrx_output
Original file line number Diff line number Diff line change
@@ -92,4 +92,5 @@
<Branch Name="edmtestThings_Thing__TESTPROD." ReadCount="35"/>
</ReadBranches>

<!-- -->
</FrameworkJobReport>
1 change: 1 addition & 0 deletions IOPool/Common/test/proper_fjrx_second_output
Original file line number Diff line number Diff line change
@@ -80,4 +80,5 @@
</Input>
</Inputs>
</File>
<!-- -->
</FrameworkJobReport>

0 comments on commit dddfd09

Please sign in to comment.