Skip to content

Commit b7921f3

Browse files
authored
Merge pull request #48816 from makortel/removeSwitchProducer
Remove SwitchProducer and ConditionalTask from the framework
2 parents 57ccb0f + 18495d8 commit b7921f3

File tree

47 files changed

+60
-4312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+60
-4312
lines changed

DataFormats/Common/interface/ProductData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace edm {
4545

4646
//Not const thread-safe update
4747
void unsafe_setWrapper(std::unique_ptr<WrapperBase> iValue) const;
48-
void unsafe_setWrapper(std::shared_ptr<WrapperBase const> iValue) const; // for SwitchProducer
48+
void unsafe_setWrapper(std::shared_ptr<WrapperBase const> iValue) const; // for RepeatingCachedRootSource
4949

5050
void resetProductDescription(std::shared_ptr<ProductDescription const> bd);
5151

DataFormats/Provenance/interface/BranchDescription.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,6 @@ namespace edm {
9595
TypeID wrappedTypeID() const { return TypeID(transient_.wrappedType_.typeInfo()); }
9696
TypeID unwrappedTypeID() const { return TypeID(transient_.unwrappedType_.typeInfo()); }
9797

98-
bool isSwitchAlias() const { return not transient_.switchAliasModuleLabel_.empty(); }
99-
std::string const& switchAliasModuleLabel() const { return transient_.switchAliasModuleLabel_; }
100-
void setSwitchAliasModuleLabel(std::string label) { transient_.switchAliasModuleLabel_ = std::move(label); }
101-
BranchID const& switchAliasForBranchID() const { return transient_.switchAliasForBranchID_; }
102-
void setSwitchAliasForBranch(BranchDescription const& aliasForBranch);
103-
104-
bool isAnyAlias() const { return isAlias() or isSwitchAlias(); }
105-
10698
bool isProvenanceSetOnRead() const noexcept { return transient_.isProvenanceSetOnRead_; }
10799
void setIsProvenanceSetOnRead(bool value = true) noexcept { transient_.isProvenanceSetOnRead_ = value; }
108100

@@ -132,14 +124,6 @@ namespace edm {
132124
// The wrapped class name, which is currently derivable from the other attributes.
133125
std::string wrappedName_;
134126

135-
// For SwitchProducer alias, the label of the aliased-for label; otherwise empty
136-
std::string switchAliasModuleLabel_;
137-
138-
// Need a separate (transient) BranchID for switch, because
139-
// otherwise originalBranchID() gives wrong answer when reading
140-
// from a file (leading to wrong ProductProvenance to be retrieved)
141-
BranchID switchAliasForBranchID_;
142-
143127
// A TypeWithDict object for the wrapped object
144128
// This is set if and only if the dropped_ is false
145129
TypeWithDict wrappedType_;

DataFormats/Provenance/src/BranchDescription.cc

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -194,28 +194,6 @@ namespace edm {
194194
branchAliases_.insert(other.branchAliases().begin(), other.branchAliases().end());
195195
}
196196

197-
void BranchDescription::setSwitchAliasForBranch(BranchDescription const& aliasForBranch) {
198-
if (branchType_ != aliasForBranch.branchType()) {
199-
throw Exception(errors::LogicError) << "BranchDescription::setSwitchAliasForBranch: branchType (" << branchType_
200-
<< ") differs from aliasForBranch (" << aliasForBranch.branchType()
201-
<< ").\nPlease report this error to the FWCore developers";
202-
}
203-
if (produced() != aliasForBranch.produced()) {
204-
throw Exception(errors::LogicError) << "BranchDescription::setSwitchAliasForBranch: produced differs from "
205-
"aliasForBranch.\nPlease report this error to the FWCore developers";
206-
}
207-
if (unwrappedTypeID().typeInfo() != aliasForBranch.unwrappedType().typeInfo()) {
208-
throw Exception(errors::LogicError)
209-
<< "BranchDescription::setSwitchAliasForBranch: unwrapped type info (" << unwrappedTypeID().name()
210-
<< ") differs from aliasForBranch (" << aliasForBranch.unwrappedType().typeInfo().name()
211-
<< ").\nPlease report this error to the FWCore developers";
212-
}
213-
214-
branchAliases_ = aliasForBranch.branchAliases();
215-
transient_.switchAliasForBranchID_ = aliasForBranch.originalBranchID();
216-
transient_.availableOnlyAtEndTransition_ = aliasForBranch.availableOnlyAtEndTransition();
217-
}
218-
219197
void BranchDescription::write(std::ostream& os) const {
220198
os << "Branch Type = " << branchType() << std::endl;
221199
os << "Process Name = " << processName() << std::endl;

FWCore/Framework/interface/TypeMatch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace edm {
1818
class TypeMatch {
1919
public:
2020
bool operator()(edm::ProductDescription const& productDescription) const {
21-
return not productDescription.isAnyAlias();
21+
return not productDescription.isAlias();
2222
}
2323
};
2424
} // namespace edm

FWCore/Framework/src/ModuleMaker.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ namespace edm {
5959
MakeModuleParams const& p,
6060
signalslot::Signal<void(ModuleDescription const&)>& pre,
6161
signalslot::Signal<void(ModuleDescription const&)>& post) const {
62-
// Add process_name for SwitchProducer
63-
if (p.pset_->getParameter<std::string>("@module_type") == "SwitchProducer") {
64-
p.pset_->addUntrackedParameter("@process_name", p.processConfiguration_->processName());
65-
}
66-
6762
ConfigurationDescriptions descriptions(baseType(), p.pset_->getParameter<std::string>("@module_type"));
6863
fillDescriptions(descriptions);
6964
try {

FWCore/Framework/src/Principal.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ namespace edm {
612612
provenances.clear();
613613
for (auto const& productResolver : *this) {
614614
if (productResolver->singleProduct() && productResolver->provenanceAvailable() &&
615-
!productResolver->productDescription().isAnyAlias()) {
615+
!productResolver->productDescription().isAlias()) {
616616
// We do not attempt to get the event/lumi/run status from the provenance,
617617
// because the per event provenance may have been dropped.
618618
if (productResolver->provenance()->productDescription().present()) {
@@ -628,7 +628,7 @@ namespace edm {
628628
void Principal::getAllStableProvenance(std::vector<StableProvenance const*>& provenances) const {
629629
provenances.clear();
630630
for (auto const& productResolver : *this) {
631-
if (productResolver->singleProduct() && !productResolver->productDescription().isAnyAlias()) {
631+
if (productResolver->singleProduct() && !productResolver->productDescription().isAlias()) {
632632
if (productResolver->stableProvenance()->productDescription().present()) {
633633
provenances.push_back(productResolver->stableProvenance());
634634
}

FWCore/Framework/src/ProductRegistryHelper.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,6 @@ namespace edm {
8181
p->typeID_,
8282
true,
8383
isEndTransition(p->transition_));
84-
if (p->aliasType_ == TypeLabelItem::AliasType::kSwitchAlias) {
85-
if (p->branchAlias_.empty()) {
86-
throw edm::Exception(edm::errors::LogicError)
87-
<< "Branch alias type has been set to SwitchAlias, but the alias content is empty.\n"
88-
<< "Please report this error to the FWCore developers";
89-
}
90-
pdesc.setSwitchAliasModuleLabel(p->branchAlias_);
91-
}
9284
if (p->isTransform_) {
9385
pdesc.setOnDemand(true);
9486
pdesc.setIsTransform(true);

FWCore/Framework/src/ProductResolvers.cc

Lines changed: 0 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -679,169 +679,4 @@ namespace edm {
679679

680680
bool AliasProductResolver::singleProduct_() const { return true; }
681681

682-
SwitchBaseProductResolver::SwitchBaseProductResolver(std::shared_ptr<ProductDescription const> bd,
683-
DataManagingOrAliasProductResolver& realProduct)
684-
: realProduct_(realProduct), productData_(std::move(bd)), prefetchRequested_(false) {
685-
// Parentage of this branch is always the same by construction, so we can compute the ID just "once" here.
686-
Parentage p;
687-
p.setParents(std::vector<BranchID>{realProduct.productDescription().originalBranchID()});
688-
parentageID_ = p.id();
689-
ParentageRegistry::instance()->insertMapped(p);
690-
}
691-
692-
void SwitchBaseProductResolver::connectTo(ProductResolverBase const& iOther, Principal const* iParentPrincipal) {
693-
throw Exception(errors::LogicError)
694-
<< "SwitchBaseProductResolver::connectTo() not implemented and should never be called.\n"
695-
<< "Contact a Framework developer\n";
696-
}
697-
698-
void SwitchBaseProductResolver::setupUnscheduled(UnscheduledConfigurator const& iConfigure) {
699-
worker_ = iConfigure.findWorker(productDescription().moduleLabel());
700-
}
701-
702-
ProductResolverBase::Resolution SwitchBaseProductResolver::resolveProductImpl(Resolution res) const {
703-
if (res.data() == nullptr)
704-
return res;
705-
return Resolution(&productData_);
706-
}
707-
708-
bool SwitchBaseProductResolver::productResolved_() const {
709-
// SwitchProducer will never put anything in the event, and
710-
// "false" will make Event::commit_() to call putProduct() with
711-
// null unique_ptr<WrapperBase> to signal that the produce() was
712-
// run.
713-
return false;
714-
}
715-
716-
void SwitchBaseProductResolver::setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) {
717-
productData_.setProvenance(provRetriever);
718-
}
719-
720-
void SwitchBaseProductResolver::setProductID_(ProductID const& pid) {
721-
// insertIntoSet is const, so let's exploit that to fake the getting of the "input" product
722-
productData_.setProductID(pid);
723-
}
724-
725-
void SwitchBaseProductResolver::resetProductData_(bool deleteEarly) {
726-
productData_.resetProductData();
727-
realProduct_.resetProductData_(deleteEarly);
728-
if (not deleteEarly) {
729-
prefetchRequested_ = false;
730-
waitingTasks_.reset();
731-
}
732-
}
733-
734-
void SwitchBaseProductResolver::unsafe_setWrapperAndProvenance() const {
735-
// update provenance
736-
productData_.provenance().store()->insertIntoSet(ProductProvenance(productDescription().branchID(), parentageID_));
737-
// Use the Wrapper of the pointed-to resolver, but the provenance of this resolver
738-
productData_.unsafe_setWrapper(realProduct().getProductData().sharedConstWrapper());
739-
}
740-
741-
SwitchProducerProductResolver::SwitchProducerProductResolver(std::shared_ptr<ProductDescription const> bd,
742-
DataManagingOrAliasProductResolver& realProduct)
743-
: SwitchBaseProductResolver(std::move(bd), realProduct), status_(defaultStatus_) {}
744-
745-
ProductResolverBase::Resolution SwitchProducerProductResolver::resolveProduct_(
746-
Principal const& principal, SharedResourcesAcquirer* sra, ModuleCallingContext const* mcc) const {
747-
if (status_ == ProductStatus::ResolveFailed) {
748-
return resolveProductImpl(realProduct().resolveProduct(principal, sra, mcc));
749-
}
750-
return Resolution(nullptr);
751-
}
752-
753-
void SwitchProducerProductResolver::prefetchAsync_(WaitingTaskHolder waitTask,
754-
Principal const& principal,
755-
ServiceToken const& token,
756-
SharedResourcesAcquirer* sra,
757-
ModuleCallingContext const* mcc) const noexcept {
758-
if (productDescription().availableOnlyAtEndTransition() and mcc and not mcc->parent().isAtEndTransition()) {
759-
return;
760-
}
761-
762-
//need to try changing prefetchRequested before adding to waitingTasks
763-
bool expected = false;
764-
bool doPrefetchRequested = prefetchRequested().compare_exchange_strong(expected, true);
765-
waitingTasks().add(waitTask);
766-
767-
if (doPrefetchRequested) {
768-
//using a waiting task to do a callback guarantees that
769-
// the waitingTasks() list will be released from waiting even
770-
// if the module does not put this data product or the
771-
// module has an exception while running
772-
auto waiting = make_waiting_task([this](std::exception_ptr const* iException) {
773-
if (nullptr != iException) {
774-
waitingTasks().doneWaiting(*iException);
775-
} else {
776-
unsafe_setWrapperAndProvenance();
777-
waitingTasks().doneWaiting(std::exception_ptr());
778-
}
779-
});
780-
worker()->callWhenDoneAsync(WaitingTaskHolder(*waitTask.group(), waiting));
781-
}
782-
}
783-
784-
void SwitchProducerProductResolver::putProduct(std::unique_ptr<WrapperBase> edp) const {
785-
if (status_ != defaultStatus_) {
786-
throw Exception(errors::InsertFailure)
787-
<< "Attempt to insert more than one product for a branch " << productDescription().branchName()
788-
<< "This makes no sense for SwitchProducerProductResolver.\nContact a Framework developer";
789-
}
790-
// Let's use ResolveFailed to signal that produce() was called, as
791-
// there is no real product in this resolver
792-
status_ = ProductStatus::ResolveFailed;
793-
bool expected = false;
794-
if (prefetchRequested().compare_exchange_strong(expected, true)) {
795-
unsafe_setWrapperAndProvenance();
796-
waitingTasks().doneWaiting(std::exception_ptr());
797-
}
798-
}
799-
800-
bool SwitchProducerProductResolver::productUnavailable_() const {
801-
// if produce() was run (ResolveFailed), ask from the real resolver
802-
if (status_ == ProductStatus::ResolveFailed) {
803-
return realProduct().productUnavailable();
804-
}
805-
return true;
806-
}
807-
808-
void SwitchProducerProductResolver::resetProductData_(bool deleteEarly) {
809-
SwitchBaseProductResolver::resetProductData_(deleteEarly);
810-
if (not deleteEarly) {
811-
status_ = defaultStatus_;
812-
}
813-
}
814-
815-
ProductResolverBase::Resolution SwitchAliasProductResolver::resolveProduct_(Principal const& principal,
816-
SharedResourcesAcquirer* sra,
817-
ModuleCallingContext const* mcc) const {
818-
return resolveProductImpl(realProduct().resolveProduct(principal, sra, mcc));
819-
}
820-
821-
void SwitchAliasProductResolver::prefetchAsync_(WaitingTaskHolder waitTask,
822-
Principal const& principal,
823-
ServiceToken const& token,
824-
SharedResourcesAcquirer* sra,
825-
ModuleCallingContext const* mcc) const noexcept {
826-
//need to try changing prefetchRequested_ before adding to waitingTasks_
827-
bool expected = false;
828-
bool doPrefetchRequested = prefetchRequested().compare_exchange_strong(expected, true);
829-
waitingTasks().add(waitTask);
830-
831-
if (doPrefetchRequested) {
832-
//using a waiting task to do a callback guarantees that
833-
// the waitingTasks() list will be released from waiting even
834-
// if the module does not put this data product or the
835-
// module has an exception while running
836-
auto waiting = make_waiting_task([this](std::exception_ptr const* iException) {
837-
if (nullptr != iException) {
838-
waitingTasks().doneWaiting(*iException);
839-
} else {
840-
unsafe_setWrapperAndProvenance();
841-
waitingTasks().doneWaiting(std::exception_ptr());
842-
}
843-
});
844-
realProduct().prefetchAsync(WaitingTaskHolder(*waitTask.group(), waiting), principal, token, sra, mcc);
845-
}
846-
}
847682
} // namespace edm

0 commit comments

Comments
 (0)