Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new test for reduced ProcessHistory #47032

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions FWCore/Framework/src/ScheduleItems.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,15 @@ namespace edm {

act_table_ = std::make_unique<ExceptionToActionTable>(parameterSet);
std::string processName = parameterSet.getParameter<std::string>("@process_name");
processConfiguration_ = std::make_shared<ProcessConfiguration>(
processName, getReleaseVersion(), getPassID()); // propagate_const<T> has no reset() function
std::string releaseVersion;
if (parameterSet.existsAs<std::string>("@special_override_release_version_only_for_testing", false)) {
releaseVersion =
parameterSet.getUntrackedParameter<std::string>("@special_override_release_version_only_for_testing");
} else {
releaseVersion = getReleaseVersion();
}
// propagate_const<T> has no reset() function
processConfiguration_ = std::make_shared<ProcessConfiguration>(processName, releaseVersion, getPassID());
auto common = std::make_shared<CommonParams>(
parameterSet.getUntrackedParameterSet("maxEvents").getUntrackedParameter<int>("input"),
parameterSet.getUntrackedParameterSet("maxLuminosityBlocks").getUntrackedParameter<int>("input"),
Expand Down
70 changes: 53 additions & 17 deletions FWCore/Framework/test/stubs/RunLumiEventAnalyzer.cc
Original file line number Diff line number Diff line change
@@ -1,51 +1,87 @@

#include "FWCore/Framework/test/stubs/RunLumiEventAnalyzer.h"

#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Common/interface/TriggerResults.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Utilities/interface/propagate_const.h"

#include <cassert>
#include <iostream>
#include <vector>

namespace edmtest {
class RunLumiEventAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
public:
explicit RunLumiEventAnalyzer(edm::ParameterSet const& pset);

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

void analyze(edm::Event const& event, edm::EventSetup const& es) final;
void beginRun(edm::Run const& run, edm::EventSetup const& es) final;
void endRun(edm::Run const& run, edm::EventSetup const& es) final;
void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& es) final;
void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& es) final;
void endJob();

private:
std::vector<unsigned long long> expectedRunLumisEvents0_;
std::vector<unsigned long long> expectedRunLumisEvents1_;
edm::propagate_const<std::vector<unsigned long long>*> const expectedRunLumisEvents_;
bool const verbose_;
bool const dumpTriggerResults_;
int const expectedEndingIndex0_;
int const expectedEndingIndex1_;
int const expectedEndingIndex_;
edm::EDGetTokenT<edm::TriggerResults> triggerResultsToken_;
makortel marked this conversation as resolved.
Show resolved Hide resolved
int index_ = 0;
};

RunLumiEventAnalyzer::RunLumiEventAnalyzer(edm::ParameterSet const& pset)
: expectedRunLumisEvents0_(),
expectedRunLumisEvents1_(),
expectedRunLumisEvents_(&expectedRunLumisEvents0_),
index_(0),
verbose_(pset.getUntrackedParameter<bool>("verbose", false)),
dumpTriggerResults_(pset.getUntrackedParameter<bool>("dumpTriggerResults", false)),
expectedEndingIndex0_(pset.getUntrackedParameter<int>("expectedEndingIndex", -1)),
expectedEndingIndex1_(pset.getUntrackedParameter<int>("expectedEndingIndex1", -1)),
verbose_(pset.getUntrackedParameter<bool>("verbose")),
dumpTriggerResults_(pset.getUntrackedParameter<bool>("dumpTriggerResults")),
expectedEndingIndex0_(pset.getUntrackedParameter<int>("expectedEndingIndex")),
expectedEndingIndex1_(pset.getUntrackedParameter<int>("expectedEndingIndex1")),
expectedEndingIndex_(expectedEndingIndex0_) {
if (pset.existsAs<std::vector<unsigned int> >("expectedRunLumiEvents", false)) {
std::vector<unsigned int> temp = pset.getUntrackedParameter<std::vector<unsigned int> >("expectedRunLumiEvents");
if (pset.existsAs<std::vector<unsigned int>>("expectedRunLumiEvents", false)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given you have a fillDescriptions, does the existsAs make sense anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing behavior was "interpret the parameter as vector<unsigned int> if it exists as such, otherwise interpret it as vector<unsigned long long>, so I believe I need to keep the existsAs() to preserve that behavior.

Written that, I could do a follow-up PR to make all instances of RunLumiEventAnalyzer to use the vector<unsigned long long> that would allow removing the existsAs call.

std::vector<unsigned int> temp = pset.getUntrackedParameter<std::vector<unsigned int>>("expectedRunLumiEvents");
expectedRunLumisEvents0_.assign(temp.begin(), temp.end());
} else {
expectedRunLumisEvents0_ = pset.getUntrackedParameter<std::vector<unsigned long long> >(
"expectedRunLumiEvents", std::vector<unsigned long long>());
expectedRunLumisEvents0_ = pset.getUntrackedParameter<std::vector<unsigned long long>>("expectedRunLumiEvents");
}

if (pset.existsAs<std::vector<unsigned int> >("expectedRunLumiEvents1", false)) {
std::vector<unsigned int> temp = pset.getUntrackedParameter<std::vector<unsigned int> >("expectedRunLumiEvents1");
if (pset.existsAs<std::vector<unsigned int>>("expectedRunLumiEvents1", false)) {
std::vector<unsigned int> temp = pset.getUntrackedParameter<std::vector<unsigned int>>("expectedRunLumiEvents1");
expectedRunLumisEvents1_.assign(temp.begin(), temp.end());
} else {
expectedRunLumisEvents1_ = pset.getUntrackedParameter<std::vector<unsigned long long> >(
"expectedRunLumiEvents1", std::vector<unsigned long long>());
expectedRunLumisEvents1_ = pset.getUntrackedParameter<std::vector<unsigned long long>>("expectedRunLumiEvents1");
}
if (dumpTriggerResults_) {
triggerResultsToken_ = consumes(edm::InputTag("TriggerResults"));
}
}

void RunLumiEventAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.addUntracked<bool>("verbose", false);
desc.addUntracked<bool>("dumpTriggerResults", false);
desc.addUntracked<int>("expectedEndingIndex", -1);
desc.addUntracked<int>("expectedEndingIndex1", -1);
desc.addNode(edm::ParameterDescription<std::vector<unsigned long long>>("expectedRunLumiEvents", {}, false) xor
edm::ParameterDescription<std::vector<unsigned int>>("expectedRunLumiEvents", {}, false));
desc.addNode(edm::ParameterDescription<std::vector<unsigned long long>>("expectedRunLumiEvents1", {}, false) xor
edm::ParameterDescription<std::vector<unsigned int>>("expectedRunLumiEvents1", {}, false));

descriptions.addDefault(desc);
}

void RunLumiEventAnalyzer::analyze(edm::Event const& event, edm::EventSetup const&) {
if (verbose_) {
edm::LogAbsolute("RunLumiEvent") << "RUN_LUMI_EVENT " << event.run() << ", " << event.luminosityBlock() << ", "
Expand Down
44 changes: 0 additions & 44 deletions FWCore/Framework/test/stubs/RunLumiEventAnalyzer.h

This file was deleted.

157 changes: 100 additions & 57 deletions FWCore/Framework/test/stubs/TestMergeResults.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ namespace edmtest {
public:
explicit TestMergeResults(edm::ParameterSet const&);

static void fillDescriptions(edm::ConfigurationDescriptions&);

void analyze(edm::Event const& e, edm::EventSetup const& c) override;
void beginRun(edm::Run const&, edm::EventSetup const&) override;
void endRun(edm::Run const&, edm::EventSetup const&) override;
Expand Down Expand Up @@ -74,84 +76,70 @@ namespace edmtest {
int actualValue,
bool unexpectedImproperlyMergedValue = false) const;

std::vector<int> default_;
std::vector<std::string> defaultvstring_;

std::vector<int> expectedBeginRunProd_;
std::vector<int> expectedEndRunProd_;
std::vector<int> expectedBeginLumiProd_;
std::vector<int> expectedEndLumiProd_;
std::vector<int> const expectedBeginRunProd_;
std::vector<int> const expectedEndRunProd_;
std::vector<int> const expectedBeginLumiProd_;
std::vector<int> const expectedEndLumiProd_;

std::vector<int> expectedBeginRunNew_;
std::vector<int> expectedEndRunNew_;
std::vector<int> expectedBeginLumiNew_;
std::vector<int> expectedEndLumiNew_;
std::vector<int> const expectedBeginRunNew_;
std::vector<int> const expectedEndRunNew_;
std::vector<int> const expectedBeginLumiNew_;
std::vector<int> const expectedEndLumiNew_;

std::vector<int> expectedEndRunProdImproperlyMerged_;
std::vector<int> expectedEndLumiProdImproperlyMerged_;
std::vector<int> const expectedEndRunProdImproperlyMerged_;
std::vector<int> const expectedEndLumiProdImproperlyMerged_;

std::vector<std::string> expectedParents_;
std::vector<std::string> const expectedParents_;

std::vector<std::string> expectedProcessHistoryInRuns_;
std::vector<std::string> const expectedProcessHistoryInRuns_;

std::vector<int> expectedDroppedEvent_;
std::vector<int> expectedDroppedEvent1_;
std::vector<int> expectedDroppedEvent1NEvents_;
std::vector<int> const expectedDroppedEvent_;
std::vector<int> const expectedDroppedEvent1_;
std::vector<int> const expectedDroppedEvent1NEvents_;

bool verbose_;
bool const verbose_;
bool const testAlias_;

unsigned int indexRun_;
unsigned int indexLumi_;
unsigned int parentIndex_;
unsigned int droppedIndex1_;
int droppedIndex1EventCount_;
unsigned int processHistoryIndex_;
unsigned int indexRun_ = 0;
unsigned int indexLumi_ = 0;
unsigned int parentIndex_ = 0;
unsigned int droppedIndex1_ = 0;
int droppedIndex1EventCount_ = 0;
unsigned int processHistoryIndex_ = 0;

edm::Handle<edmtest::Thing> h_thing;
edm::Handle<edmtest::ThingWithMerge> h_thingWithMerge;
edm::Handle<edmtest::ThingWithIsEqual> h_thingWithIsEqual;

bool testAlias_;
};

// -----------------------------------------------------------------

TestMergeResults::TestMergeResults(edm::ParameterSet const& ps)
: default_(),
defaultvstring_(),
expectedBeginRunProd_(ps.getUntrackedParameter<std::vector<int> >("expectedBeginRunProd", default_)),
expectedEndRunProd_(ps.getUntrackedParameter<std::vector<int> >("expectedEndRunProd", default_)),
expectedBeginLumiProd_(ps.getUntrackedParameter<std::vector<int> >("expectedBeginLumiProd", default_)),
expectedEndLumiProd_(ps.getUntrackedParameter<std::vector<int> >("expectedEndLumiProd", default_)),

expectedBeginRunNew_(ps.getUntrackedParameter<std::vector<int> >("expectedBeginRunNew", default_)),
expectedEndRunNew_(ps.getUntrackedParameter<std::vector<int> >("expectedEndRunNew", default_)),
expectedBeginLumiNew_(ps.getUntrackedParameter<std::vector<int> >("expectedBeginLumiNew", default_)),
expectedEndLumiNew_(ps.getUntrackedParameter<std::vector<int> >("expectedEndLumiNew", default_)),
: expectedBeginRunProd_(ps.getUntrackedParameter<std::vector<int>>("expectedBeginRunProd")),
expectedEndRunProd_(ps.getUntrackedParameter<std::vector<int>>("expectedEndRunProd")),
expectedBeginLumiProd_(ps.getUntrackedParameter<std::vector<int>>("expectedBeginLumiProd")),
expectedEndLumiProd_(ps.getUntrackedParameter<std::vector<int>>("expectedEndLumiProd")),

expectedBeginRunNew_(ps.getUntrackedParameter<std::vector<int>>("expectedBeginRunNew")),
expectedEndRunNew_(ps.getUntrackedParameter<std::vector<int>>("expectedEndRunNew")),
expectedBeginLumiNew_(ps.getUntrackedParameter<std::vector<int>>("expectedBeginLumiNew")),
expectedEndLumiNew_(ps.getUntrackedParameter<std::vector<int>>("expectedEndLumiNew")),

expectedEndRunProdImproperlyMerged_(
ps.getUntrackedParameter<std::vector<int> >("expectedEndRunProdImproperlyMerged", default_)),
ps.getUntrackedParameter<std::vector<int>>("expectedEndRunProdImproperlyMerged")),
expectedEndLumiProdImproperlyMerged_(
ps.getUntrackedParameter<std::vector<int> >("expectedEndLumiProdImproperlyMerged", default_)),
ps.getUntrackedParameter<std::vector<int>>("expectedEndLumiProdImproperlyMerged")),

expectedParents_(ps.getUntrackedParameter<std::vector<std::string> >("expectedParents", defaultvstring_)),
expectedParents_(ps.getUntrackedParameter<std::vector<std::string>>("expectedParents")),
expectedProcessHistoryInRuns_(
ps.getUntrackedParameter<std::vector<std::string> >("expectedProcessHistoryInRuns", defaultvstring_)),

expectedDroppedEvent_(ps.getUntrackedParameter<std::vector<int> >("expectedDroppedEvent", default_)),
expectedDroppedEvent1_(ps.getUntrackedParameter<std::vector<int> >("expectedDroppedEvent1", default_)),
expectedDroppedEvent1NEvents_(
ps.getUntrackedParameter<std::vector<int> >("expectedDroppedEvent1NEvents", default_)),

verbose_(ps.getUntrackedParameter<bool>("verbose", false)),

indexRun_(0),
indexLumi_(0),
parentIndex_(0),
droppedIndex1_(0),
droppedIndex1EventCount_(0),
processHistoryIndex_(0),
testAlias_(ps.getUntrackedParameter<bool>("testAlias", false)) {
ps.getUntrackedParameter<std::vector<std::string>>("expectedProcessHistoryInRuns")),

expectedDroppedEvent_(ps.getUntrackedParameter<std::vector<int>>("expectedDroppedEvent")),
expectedDroppedEvent1_(ps.getUntrackedParameter<std::vector<int>>("expectedDroppedEvent1")),
expectedDroppedEvent1NEvents_(ps.getUntrackedParameter<std::vector<int>>("expectedDroppedEvent1NEvents")),

verbose_(ps.getUntrackedParameter<bool>("verbose")),
testAlias_(ps.getUntrackedParameter<bool>("testAlias")) {
auto ap_thing = std::make_unique<edmtest::Thing>();
edm::Wrapper<edmtest::Thing> w_thing(std::move(ap_thing));
assert(!w_thing.isMergeable());
Expand Down Expand Up @@ -277,6 +265,61 @@ namespace edmtest {

// -----------------------------------------------------------------

void TestMergeResults::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.addUntracked<std::vector<int>>("expectedBeginRunProd", {})
->setComment(
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from process PROD at beginRun.");
desc.addUntracked<std::vector<int>>("expectedEndRunProd", {})
->setComment(
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from process PROD at nendRun.");
desc.addUntracked<std::vector<int>>("expectedBeginLumiProd", {})
->setComment(
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from process PROD at "
"beginLuminosityBlock.");
desc.addUntracked<std::vector<int>>("expectedEndLumiProd", {})
->setComment(
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from process PROD at "
"endLuminosityBlock.");

desc.addUntracked<std::vector<int>>("expectedBeginRunNew", {})
->setComment(
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from the latest process at "
"beginRun.");
desc.addUntracked<std::vector<int>>("expectedEndRunNew", {})
->setComment(
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from the latest process at endRun.");
desc.addUntracked<std::vector<int>>("expectedBeginLumiNew", {})
->setComment(
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from the latest process at "
"beginLuminosityBlock.");
desc.addUntracked<std::vector<int>>("expectedEndLumiNew", {})
->setComment(
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from the latest process at "
"endLuminosityBlock.");

desc.addUntracked<std::vector<int>>("expectedEndRunProdImproperlyMerged", {});
desc.addUntracked<std::vector<int>>("expectedEndLumiProdImproperlyMerged", {});
desc.addUntracked<std::vector<std::string>>("expectedParents", {});
desc.addUntracked<std::vector<std::string>>("expectedProcessHistoryInRuns", {});
desc.addUntracked<std::vector<int>>("expectedDroppedEvent", {});
desc.addUntracked<std::vector<int>>("expectedDroppedEvent1", {});
desc.addUntracked<std::vector<int>>("expectedDroppedEvent1NEvents", {});

desc.addUntracked<bool>("testAlias", false);
desc.addUntracked<bool>("verbose", false);

desc.setComment(
"The expected{Begin,End}(Run,Lumi}{Prod,New} parameters follow the same pattern. The expected values come in "
"sets of three: value expected in Thing, ThingWithMerge, and ThingWithIsEqual. Each set of 3 is tested at the "
"specific transition, and then the next set of 3 is tested at the next transition, and so on. When the "
"sequence of parameter values is exhausted, the checking is stopped. The values if 0 are just placedholders, "
"i.e. if the value is a 0, the check is not made.");

descriptions.addDefault(desc);
}

// -----------------------------------------------------------------
void TestMergeResults::analyze(edm::Event const& e, edm::EventSetup const&) {
assert(e.processHistory().id() == e.processHistoryID());

Expand Down
Loading