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

Fix propagation of an earlier exception in Transformer #40879

Merged
merged 2 commits into from
Mar 16, 2023
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: 11 additions & 0 deletions FWCore/Framework/src/ProductResolvers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,17 @@ namespace edm {
return Resolution(nullptr);
}

void TransformingProductResolver::putProduct(std::unique_ptr<WrapperBase> edp) const {
// Override putProduct() to not set the resolver status to
// ResolveFailed when the Event::commit_() checks which produced
// products were actually produced and which not, because the
// transforming products are never produced by time of commit_()
// by construction.
if (edp) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the putProduct call always get a null wrapper? Or does the later call also call putProduct?

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 putProduct() call from Event::commit_()

for (auto index : iShouldPut) {
auto resolver = p.getProductResolverByIndex(index);
if (not resolver->productResolved()) {
dynamic_cast<ProductPutterBase const*>(resolver)->putProduct(std::unique_ptr<WrapperBase>());
}
}

will always have a null wrapper. The Transformer itself calls putProduct() via EventPrincipal::put()
dynamic_cast<ProductPutterBase const*>(phb)->putProduct(std::move(edp));

void EventForTransformer::put(ProductResolverIndex index,
std::unique_ptr<WrapperBase> edp,
BasicHandle const& iGetHandle) {
eventPrincipal_.put(index, std::move(edp), iGetHandle.provenance()->productProvenance()->parentageID());
}

Written that, I see now an alternative to customizing putProduct() that would be to customize (in some way) productResolved() to return true for Transformer. The productResolved() seems to be called only in {Event,LuminosityBlock,Run,ProcessBlock}::commit_(), but on a first thought "lying" in productResolved() sounds conceptually worse than leaving the status unaltered in putProduct().

ProducedProductResolver::putProduct(std::move(edp));
}
}

void TransformingProductResolver::prefetchAsync_(WaitingTaskHolder waitTask,
Principal const& principal,
bool skipCurrentProcess,
Expand Down
3 changes: 2 additions & 1 deletion FWCore/Framework/src/ProductResolvers.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,12 @@ namespace edm {
class TransformingProductResolver : public ProducedProductResolver {
public:
explicit TransformingProductResolver(std::shared_ptr<BranchDescription const> bd)
: ProducedProductResolver(bd, ProductStatus::ResolveFailed), mcc_(nullptr) {}
: ProducedProductResolver(bd, ProductStatus::ResolveNotRun), mcc_(nullptr) {}

void setupUnscheduled(UnscheduledConfigurator const&) final;

private:
void putProduct(std::unique_ptr<WrapperBase> edp) const override;
Resolution resolveProduct_(Principal const& principal,
bool skipCurrentProcess,
SharedResourcesAcquirer* sra,
Expand Down
4 changes: 4 additions & 0 deletions FWCore/Integration/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
<test name="testFWCoreIntegrationTransform_stream_onPath_async" command="cmsRun ${LOCALTOP}/src/FWCore/Integration/test/transformTest_cfg.py -- --stream --onPath --async_"/>
<test name="testFWCoreIntegrationTransform_noPut" command="! cmsRun ${LOCALTOP}/src/FWCore/Integration/test/transformTest_cfg.py -- --noPut"/>
<test name="testFWCoreIntegrationTransform_noPut_async" command="! cmsRun ${LOCALTOP}/src/FWCore/Integration/test/transformTest_cfg.py -- --noPut --async_"/>
<test name="testFWCoreIntegrationTransform_exception" command="cmsRun ${LOCALTOP}/src/FWCore/Integration/test/transformTest_cfg.py -- --exception 2>&amp;1 | fgrep 'exception for testing purposes'"/>
<test name="testFWCoreIntegrationTransform_async_exception" command="cmsRun ${LOCALTOP}/src/FWCore/Integration/test/transformTest_cfg.py -- --async --exception 2>&amp;1 | fgrep 'exception for testing purposes'"/>
<test name="testFWCoreIntegrationTransform_onPath_exception" command="cmsRun ${LOCALTOP}/src/FWCore/Integration/test/transformTest_cfg.py -- --onPath --exception 2>&amp;1 | fgrep 'exception for testing purposes'"/>
<test name="testFWCoreIntegrationTransform_onPath_async_exception" command="cmsRun ${LOCALTOP}/src/FWCore/Integration/test/transformTest_cfg.py -- --onPath --async --exception 2>&amp;1 | fgrep 'exception for testing purposes'"/>

<test name="TestFWCoreIntegrationModuleThread" command="cmsRun ${LOCALTOP}/src/FWCore/Integration/test/moduleThread_test_cfg.py"/>

Expand Down
3 changes: 3 additions & 0 deletions FWCore/Integration/test/transformTest_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
parser.add_argument("--noPut", help="do not put data used by transform", action="store_true")
parser.add_argument("--addTracer", help="add Tracer service", action="store_true")
parser.add_argument("--async_", help="use asynchronous module", action="store_true")
parser.add_argument("--exception", help="Make module consumed by transformer to throw an exception", action="store_true")

argv = sys.argv[:]
if '--' in argv:
Expand All @@ -27,6 +28,8 @@
process.maxEvents.input = 4

process.start = cms.EDProducer("IntProducer", ivalue = cms.int32(1))
if args.exception:
process.start = cms.EDProducer("FailingProducer")
Copy link
Contributor

Choose a reason for hiding this comment

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

So the test failure is in what is consumed and not in the actual transform call its.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, basically from anywhere in the data dependence chain of the module registering the transformation call.

if args.stream:
if args.async_:
process.t = cms.EDProducer("TransformAsyncIntStreamProducer", get = cms.InputTag("start"), offset = cms.uint32(1), checkTransformNotCalled = cms.untracked.bool(False))
Expand Down