Skip to content

Commit 6cbbf95

Browse files
committed
Better process order handling
1 parent 0d84072 commit 6cbbf95

File tree

7 files changed

+40
-4
lines changed

7 files changed

+40
-4
lines changed

DataFormats/Provenance/interface/ProductRegistry.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ namespace edm {
182182
iter->second.merge(prod.second);
183183
}
184184
}
185+
mergeProcessOrderFromAddInput(iReg.processOrder());
185186
}
186187

187188
private:
@@ -206,6 +207,7 @@ namespace edm {
206207

207208
void checkForDuplicateProcessName(ProductDescription const& desc, std::string const* processName) const;
208209
void updateProcessOrder(std::vector<std::string> const& processOrder);
210+
void mergeProcessOrderFromAddInput(std::vector<std::string> const& processOrder);
209211

210212
void throwIfNotFrozen() const;
211213
void throwIfFrozen() const;

DataFormats/Provenance/src/ProductRegistry.cc

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,17 @@ namespace edm {
218218
processingOrderMerge(processOrder, transient_.processOrder_);
219219
}
220220

221+
void ProductRegistry::mergeProcessOrderFromAddInput(std::vector<std::string> const& processOrder) {
222+
if (processOrder.empty())
223+
return;
224+
//see if the input already has the current process
225+
if (not transient_.processOrder_.empty() and (transient_.processOrder_[0] != processOrder[0])) {
226+
transient_.processOrder_.insert(transient_.processOrder_.end(), processOrder.begin(), processOrder.end());
227+
} else {
228+
updateProcessOrder(processOrder);
229+
}
230+
}
231+
221232
void ProductRegistry::setUnscheduledProducts(std::set<std::string> const& unscheduledLabels) {
222233
throwIfFrozen();
223234

@@ -250,9 +261,20 @@ namespace edm {
250261
std::string ProductRegistry::merge(ProductRegistry const& other,
251262
std::string const& fileName,
252263
ProductDescription::MatchMode branchesMustMatch) {
253-
if (branchesMustMatch == ProductDescription::FromInputToCurrent and transient_.processOrder_.size() == 1) {
254-
transient_.processOrder_.insert(
255-
transient_.processOrder_.end(), other.transient_.processOrder_.begin(), other.transient_.processOrder_.end());
264+
if (branchesMustMatch == ProductDescription::FromInputToCurrent) {
265+
if (processOrder().size() == 1 and not other.processOrder().empty() and
266+
processOrder()[0] != other.processOrder()[0]) {
267+
assert(transient_.processOrder_.size() == 1);
268+
transient_.processOrder_.insert(transient_.processOrder_.end(),
269+
other.transient_.processOrder_.begin(),
270+
other.transient_.processOrder_.end());
271+
} else {
272+
//the current process must not change
273+
assert(not processOrder().empty());
274+
auto current = processOrder()[0];
275+
processingOrderMerge(other.processOrder(), transient_.processOrder_);
276+
assert(current == processOrder()[0]);
277+
}
256278
} else {
257279
processingOrderMerge(other.processOrder(), transient_.processOrder_);
258280
}
@@ -310,6 +332,7 @@ namespace edm {
310332
std::vector<std::string> producedTypes;
311333

312334
transient_.branchIDToIndex_.clear();
335+
assert(productList_.empty() or processOrder().size() > 0);
313336

314337
std::array<std::shared_ptr<ProductResolverIndexHelper>, NumBranchTypes> new_productLookups{
315338
{std::make_shared<ProductResolverIndexHelper>(),
@@ -452,7 +475,7 @@ namespace edm {
452475

453476
std::string_view processNameSV(processName ? std::string_view(*processName) : std::string_view());
454477
for (auto& iterProductLookup : new_productLookups) {
455-
iterProductLookup->setFrozen(processNameSV);
478+
iterProductLookup->setFrozen(processOrder());
456479
}
457480
for (size_t i = 0; i < new_productLookups.size(); ++i) {
458481
transient_.productLookups_[i] = std::move(new_productLookups[i]);

FWCore/Framework/interface/SignallingProductRegistryFiller.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ namespace edm {
8080
registry_.setProcessOrder(std::vector<std::string>(1, processOrder));
8181
}
8282

83+
void setProcessOrder(std::vector<std::string> const& processOrder) { registry_.setProcessOrder(processOrder); }
84+
8385
template <class T>
8486
void watchProductAdditions(const T& iFunc) {
8587
serviceregistry::connect_but_block_self(productAddedSignal_, iFunc);

FWCore/Framework/test/productregistry.cppunit.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ void testProductRegistry::testAddAlias() {
238238
simpleVecBranch_->unwrappedTypeID(),
239239
simpleDerivedVecBranch_->unwrappedTypeID()};
240240
std::set<edm::TypeID> elementTypesConsumed{intBranch_->unwrappedTypeID(), edm::TypeID(typeid(edmtest::Simple))};
241+
reg.setProcessOrder({"PROD"});
241242
reg.setFrozen(productTypesConsumed, elementTypesConsumed, "TEST");
242243
{
243244
auto notFound =

FWCore/Integration/plugins/PutOrMergeTestSource.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ void PutOrMergeTestSource::registerProducts() {
7878
productRegistryUpdate().copyProduct(thingDesc_);
7979
productRegistryUpdate().copyProduct(thingWithMergeDesc_);
8080
productRegistryUpdate().copyProduct(thingWithEqualDesc_);
81+
productRegistryUpdate().setProcessOrder({"PROD"});
8182
}
8283

8384
InputSource::ItemTypeInfo PutOrMergeTestSource::getNextItemType() {

FWCore/Sources/src/PuttableSourceBase.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ PuttableSourceBase::PuttableSourceBase(ParameterSet const& iPSet, InputSourceDes
4141

4242
void PuttableSourceBase::registerProducts() {
4343
SignallingProductRegistryFiller reg;
44+
reg.setProcessOrder({moduleDescription().processName()});
4445
//this handled case were Source's construct injects items into the ProductRegistry
4546
reg.addFromInput(productRegistryUpdate());
4647
registerProducts(this, &reg, moduleDescription());

FWCore/TestProcessor/src/TestProcessor.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "FWCore/ParameterSet/interface/ProcessDesc.h"
4646
#include "FWCore/ParameterSet/interface/validateTopLevelParameterSets.h"
4747

48+
#include "DataFormats/Provenance/interface/processingOrderMerge.h"
4849
#include "FWCore/Utilities/interface/ExceptionCollector.h"
4950

5051
#include "oneTimeInitialization.h"
@@ -121,6 +122,11 @@ namespace edm {
121122
processHistory_.emplace_back(p, psetid, xstr(PROJECT_VERSION), HardwareResourcesDescription());
122123
processHistoryRegistry_.registerProcessHistory(processHistory_);
123124
}
125+
std::vector<std::string> orderedProcesses;
126+
processingOrderMerge(processHistoryRegistry_, orderedProcesses);
127+
orderedProcesses.insert(orderedProcesses.begin(), processConfiguration_->processName());
128+
129+
tempReg->setProcessOrder(orderedProcesses);
124130

125131
//setup the products we will be adding to the event
126132
for (auto const& produce : iConfig.produceEntries()) {

0 commit comments

Comments
 (0)