-
Notifications
You must be signed in to change notification settings - Fork 510
Adding customizable hook to be executed on workflow termination #2196
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
Merged
ktf
merged 1 commit into
AliceO2Group:dev
from
matthiasrichter:dev-custom-workflow-termination-hook
Jul 15, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
Framework/Core/include/Framework/CustomWorkflowTerminationHook.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // Copyright CERN and copyright holders of ALICE O2. This software is | ||
| // distributed under the terms of the GNU General Public License v3 (GPL | ||
| // Version 3), copied verbatim in the file "COPYING". | ||
| // | ||
| // See http://alice-o2.web.cern.ch/license for full licensing information. | ||
| // | ||
| // In applying this license CERN does not waive the privileges and immunities | ||
| // granted to it by virtue of its status as an Intergovernmental Organization | ||
| // or submit itself to any jurisdiction. | ||
| #ifndef CUSTOMWORKFLOWTERMINATIONHOOK_H | ||
| #define CUSTOMWORKFLOWTERMINATIONHOOK_H | ||
|
|
||
| namespace o2 | ||
| { | ||
| namespace framework | ||
| { | ||
|
|
||
| /// A callback definition for a hook to be invoked when processes terminate | ||
| /// | ||
| /// The parameter is the nullptr if the process is the main driver, for all | ||
| /// child processes, the id string is passed. This allows to customize the | ||
| /// hook depending on the process. | ||
| /// Note that the callback hook is invoked for every process, i.e. main driver | ||
| /// and all childs. | ||
| /// | ||
| /// \par Usage: | ||
| /// The customize the hook, add a function with the following signature before | ||
| /// including heder file runDataProcessing.h: | ||
| /// | ||
| /// void customize(o2::framework::OnWorkflowTerminationHook& hook) | ||
| /// { | ||
| /// hook = [](const char* idstring){ | ||
| /// if (idstring == nullptr) { | ||
| /// std::cout << "hook" << std::endl; | ||
| /// } else { | ||
| /// std::cout << "child process " << idstring << " terminating" << std::endl; | ||
| /// } | ||
| /// }; | ||
| /// } | ||
| /// #include "Framework/runDataProcessing.h" | ||
| using OnWorkflowTerminationHook = std::function<void(const char*)>; | ||
|
|
||
| } // namespace framework | ||
| } // namespace o2 | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is
--ida new option needed for this hook? I think not?In that case, perhaps the id parameter is already available from somewhere else, and does not need to be parsed from the cmdline again?
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.
The
--idparameter is added by the main driver so that every child process knows it's role in the workflow. So it is there already. The parsing of all the options is done indoMainin the cxx file. The customization happens in the header file because of some template trick, so one would need to pass the function as another parameter to do main.Using this id parameter allows to customize the hook depending on the position of a process in the workflow.
I decided not to do this and implement some simple parsing. But well, that can be changed.