Skip to content

Commit

Permalink
Merge pull request #18650 from Dr15Jones/fixExceptionAtGlobalBeginTra…
Browse files Browse the repository at this point in the history
…nsition

Fix exception at global begin transition
  • Loading branch information
cmsbuild authored May 10, 2017
2 parents 9556e93 + cec0139 commit 5fb33dd
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 14 deletions.
3 changes: 0 additions & 3 deletions FWCore/Framework/interface/EventPrincipal.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ namespace edm {
class ThinnedAssociationsHelper;
class ProcessHistoryRegistry;
class RunPrincipal;
class UnscheduledConfigurator;

class EventPrincipal : public Principal {
public:
Expand Down Expand Up @@ -139,8 +138,6 @@ namespace edm {

ProductProvenanceRetriever const* productProvenanceRetrieverPtr() const {return provRetrieverPtr_.get();}

void setupUnscheduled(UnscheduledConfigurator const&);

EventSelectionIDVector const& eventSelectionIDs() const;

BranchListIndexes const& branchListIndexes() const;
Expand Down
5 changes: 4 additions & 1 deletion FWCore/Framework/interface/Principal.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace edm {
class SharedResourcesAcquirer;
class InputProductResolver;
class WaitingTask;
class UnscheduledConfigurator;

struct FilledProductPtr {
bool operator()(propagate_const<std::shared_ptr<ProductResolverBase>> const& iObj) { return bool(iObj);}
Expand Down Expand Up @@ -82,7 +83,9 @@ namespace edm {
void fillPrincipal(ProcessHistoryID const& hist, ProcessHistoryRegistry const& phr, DelayedReader* reader);

void clearPrincipal();


void setupUnscheduled(UnscheduledConfigurator const&);

void setAtEndTransition(bool iAtEnd);
bool atEndTransition() const {return atEndTransition_;}

Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/interface/WorkerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace edm {
U const* context);


void setupOnDemandSystem(EventPrincipal& principal, EventSetup const& es);
void setupOnDemandSystem(Principal& principal, EventSetup const& es);

void beginJob(ProductRegistry const& iRegistry);
void endJob();
Expand Down
7 changes: 0 additions & 7 deletions FWCore/Framework/src/EventPrincipal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,6 @@ namespace edm {
return getProvenance(bid, mcc);
}

void
EventPrincipal::setupUnscheduled(UnscheduledConfigurator const& iConfigure) {
applyToResolvers([&iConfigure](ProductResolverBase* iResolver) {
iResolver->setupUnscheduled(iConfigure);
});
}

EventSelectionIDVector const&
EventPrincipal::eventSelectionIDs() const {
return eventSelectionIDs_;
Expand Down
5 changes: 4 additions & 1 deletion FWCore/Framework/src/GlobalSchedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ namespace edm {
workerManager_.resetAll();

ParentContext parentContext(globalContext.get());

//make sure the ProductResolvers know about their
// workers to allow proper data dependency handling
workerManager_.setupOnDemandSystem(ep,es);

//make sure the task doesn't get run until all workers have beens started
WaitingTaskHolder holdForLoop(doneTask);
for(auto& worker: boost::adaptors::reverse((allWorkers()))) {
Expand Down
8 changes: 8 additions & 0 deletions FWCore/Framework/src/Principal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,14 @@ namespace edm {
phb->unsafe_deleteProduct();
}

void
Principal::setupUnscheduled(UnscheduledConfigurator const& iConfigure) {
applyToResolvers([&iConfigure](ProductResolverBase* iResolver) {
iResolver->setupUnscheduled(iConfigure);
});
}


// Set the principal for the Event, Lumi, or Run.
void
Principal::fillPrincipal(ProcessHistoryID const& hist,
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/src/WorkerManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ namespace edm {
}

void
WorkerManager::setupOnDemandSystem(EventPrincipal& ep, EventSetup const& es) {
WorkerManager::setupOnDemandSystem(Principal& ep, EventSetup const& es) {
this->resetAll();
unscheduled_.setEventSetup(es);
if(&ep != lastSetupEventPrincipal_) {
Expand Down
21 changes: 21 additions & 0 deletions FWCore/Framework/test/stubs/ToyAnalyzers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@ namespace edmtest {
}


};
//--------------------------------------------------------------------
//
class IntFromRunConsumingAnalyzer : public edm::global::EDAnalyzer<> {
public:
IntFromRunConsumingAnalyzer(edm::ParameterSet const& iPSet)
{
consumes<IntProduct, edm::InRun>(iPSet.getUntrackedParameter<edm::InputTag>("getFromModule"));
}

void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override {}

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.addUntracked<edm::InputTag>("getFromModule");
descriptions.add("consumeInt", desc);

}


};
//--------------------------------------------------------------------
//
Expand Down Expand Up @@ -253,6 +273,7 @@ using edmtest::DSVAnalyzer;
DEFINE_FWK_MODULE(NonAnalyzer);
DEFINE_FWK_MODULE(IntTestAnalyzer);
DEFINE_FWK_MODULE(IntConsumingAnalyzer);
DEFINE_FWK_MODULE(edmtest::IntFromRunConsumingAnalyzer);
DEFINE_FWK_MODULE(ConsumingStreamAnalyzer);
DEFINE_FWK_MODULE(ConsumingOneSharedResourceAnalyzer);
DEFINE_FWK_MODULE(SCSimpleAnalyzer);
Expand Down
27 changes: 27 additions & 0 deletions FWCore/Framework/test/stubs/ToyIntProducers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,32 @@ namespace edmtest {
throw edm::Exception(edm::errors::NotFound) << "Intentional 'NotFound' exception for testing purposes\n";
}

//--------------------------------------------------------------------
//
// throws an exception.
// Announces an IntProduct but does not produce one;
// every call to FailingProducer::produce throws a cms exception
//
class FailingInRunProducer : public edm::global::EDProducer<edm::BeginRunProducer> {
public:
explicit FailingInRunProducer(edm::ParameterSet const& /*p*/) {
produces<IntProduct,edm::Transition::BeginRun>();
}
virtual void produce(edm::StreamID, edm::Event& e, edm::EventSetup const& c) const override;

void globalBeginRunProduce( edm::Run&, edm::EventSetup const&) const override;

};

void
FailingInRunProducer::produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const {
}
void
FailingInRunProducer::globalBeginRunProduce( edm::Run&, edm::EventSetup const&) const {
// We throw an edm exception with a configurable action.
throw edm::Exception(edm::errors::NotFound) << "Intentional 'NotFound' exception for testing purposes\n";
}

//--------------------------------------------------------------------
//
// Announces an IntProduct but does not produce one;
Expand Down Expand Up @@ -371,6 +397,7 @@ using edmtest::IntProducerFromTransient;
using edmtest::Int16_tProducer;
using edmtest::AddIntsProducer;
DEFINE_FWK_MODULE(FailingProducer);
DEFINE_FWK_MODULE(edmtest::FailingInRunProducer);
DEFINE_FWK_MODULE(NonProducer);
DEFINE_FWK_MODULE(IntProducer);
DEFINE_FWK_MODULE(IntLegacyProducer);
Expand Down
14 changes: 14 additions & 0 deletions FWCore/Framework/test/test_dependentRunDataAndException_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("TEST")

process.source = cms.Source("EmptySource")

process.intMaker = cms.EDProducer("edmtest::FailingInRunProducer")

process.consumer = cms.EDAnalyzer("edmtest::IntFromRunConsumingAnalyzer",
getFromModule = cms.untracked.InputTag("intMaker"))

process.p = cms.Path(process.consumer,cms.Task(process.intMaker))

process.options = cms.untracked.PSet(numberOfThreads = cms.untracked.uint32(2))
3 changes: 3 additions & 0 deletions FWCore/Framework/test/test_earlyTerminationSignal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ echo "running cmsRun testEarlyTerminationSignal_cfg.py"

echo "runnig cmsRun test_dependentPathsAndExceptions_cfg.py"
(cmsRun ${LOCAL_TEST_DIR}/test_dependentPathsAndExceptions_cfg.py 2>&1 | grep -q "Intentional 'NotFound' exception for testing purposes") || die "dependent Paths and Exceptions failed" $?

echo "runnig cmsRun test_dependentRunDataAndException_cfg.py"
(cmsRun ${LOCAL_TEST_DIR}/test_dependentRunDataAndException_cfg.py 2>&1 | grep -q "Intentional 'NotFound' exception for testing purposes") || die "dependent Run data and Exceptions failed" $?

0 comments on commit 5fb33dd

Please sign in to comment.