-
Notifications
You must be signed in to change notification settings - Fork 36
feat: if a factory fails init, take it out of remaining operation #2356
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces error handling for factory initialization failures in JOmniFactory. When the Init() method fails, the factory is marked with CreationStatus::NeverCreated and continues to exist but produces only empty collections instead of attempting to re-initialize or process events.
Changes:
- Added try-catch block in
Init()to handle initialization failures gracefully - Factories with failed initialization are marked as
NeverCreatedand log an error Process()method now checks forNeverCreatedstatus and returns early with empty collections
Comments suppressed due to low confidence (1)
src/extensions/jana/JOmniFactory.h:546
- The BeginRun method should check if the factory is in NeverCreated status before attempting to execute. If initialization failed, calling ChangeRun on resources or the algorithm could lead to undefined behavior since Configure was never successfully called.
void BeginRun(const std::shared_ptr<const JEvent>& event) override {
for (auto* resource : m_resources) {
resource->ChangeRun(*event);
}
static_cast<AlgoT*>(this)->ChangeRun(event->GetRunNumber());
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/extensions/jana/JOmniFactory.h:546
- The BeginRun method should also check if the factory is in NeverCreated status and return early, similar to the Process method. If initialization failed, BeginRun shouldn't attempt to execute ChangeRun operations on resources or the algorithm itself, as they may depend on successful initialization.
void BeginRun(const std::shared_ptr<const JEvent>& event) override {
for (auto* resource : m_resources) {
resource->ChangeRun(*event);
}
static_cast<AlgoT*>(this)->ChangeRun(event->GetRunNumber());
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Briefly, what does this PR introduce?
Needs:
This PR ensures that failing
init()calls in algorithms immediately lead to that algorithm being taken out of operation for the rest of the run. This prevents the failing algorithms to attempt to get re-initialized the whole time.What kind of change does this PR introduce?
Please check if this PR fulfills the following:
Does this PR introduce breaking changes? What changes might users need to make to their code?
No.
Does this PR change default behavior?
Yes.