-
Notifications
You must be signed in to change notification settings - Fork 31
Storage of job execution environment in output files [2/4] #497
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: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
add_subdirectory(gen) | ||
add_subdirectory(g4) | ||
add_subdirectory(caf) | ||
add_subdirectory(util) | ||
install_fhicl() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
install_fhicl() |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# File: dump_sbnjobmetadata.fcl | ||
# Purpose: Prints on screen all the job SBN metadata stored in an input file. | ||
# Author: Gianluca Petrillo (petrillo@slac.stanford.edu) | ||
# Date: January 20, 2025 | ||
# | ||
# Reads and prints on screen the SBN job environment information from the input | ||
# file. | ||
# | ||
# Changes | ||
# -------- | ||
# | ||
# [20250120] (petrillo@slac.stanford.edu) | ||
# original version | ||
# | ||
|
||
#include "messages_icarus.fcl" | ||
|
||
process_name: JobMeta | ||
|
||
# use `icarus_message_services_interactive` to see dump on screen | ||
services.message: @local::icarus_message_services_prod | ||
|
||
services.message.destinations.MetadataLog: { | ||
type: file | ||
filename: "JobEnvironment.log" | ||
append: false | ||
threshold: INFO | ||
categories: { | ||
DumpJobEnvironment: { limit: -1 } | ||
default: { limit: 0 } | ||
} | ||
} | ||
|
||
outputs.metadataDumper: { | ||
module_type: "DumpJobEnvironment" | ||
} | ||
|
||
physics: { | ||
streams: [ metadataDumper ] | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
/** | ||
* @file sbncode/Metadata/DumpJobEnvironment_module.cc | ||
* @brief Producer module writing job environment information into output. | ||
* @author Gianluca Petrillo (petrillo@slac.stanford.edu) | ||
* @date January 16, 2025 | ||
*/ | ||
|
||
// local libraries | ||
#include "sbnobj/Common/Metadata/JobEnvironmentInfo.h" | ||
|
||
// framework libraries | ||
#include "art/Framework/Core/ModuleMacros.h" | ||
#include "art/Framework/Core/OutputModule.h" | ||
#include "art/Framework/Principal/ResultsPrincipal.h" | ||
#include "art/Framework/Principal/Results.h" | ||
#include "art/Framework/Principal/Provenance.h" | ||
#include "art/Framework/Principal/Handle.h" | ||
#include "art/Persistency/Provenance/ModuleContext.h" | ||
#include "messagefacility/MessageLogger/MessageLogger.h" | ||
#include "fhiclcpp/types/ConfigurationTable.h" // fhicl::WrappedTable | ||
#include "fhiclcpp/types/TableFragment.h" | ||
#include "fhiclcpp/types/Atom.h" | ||
|
||
// C++ standard libraries | ||
#include <string> | ||
#include <vector> | ||
|
||
|
||
// ----------------------------------------------------------------------------- | ||
namespace sbn { class DumpJobEnvironment; } | ||
/** | ||
* @brief Output module dumping input versions to screen. | ||
* | ||
* The output module can be added to any of the end paths of an _art_ job to | ||
* get a complete dump of the SBN job environment metadata stored into the input | ||
* file. | ||
* | ||
* For example: | ||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
* process_name: JobMeta | ||
* | ||
* services.message.destinations.MetadataLog: { | ||
* type: file | ||
* filename: "JobEnvironment.log" | ||
* append: false | ||
* threshold: INFO | ||
* categories: { | ||
* DumpJobEnvironment: { limit: -1 } | ||
* default: { limit: 0 } | ||
* } | ||
* } | ||
* | ||
* outputs.metadataDumper: { module_type: "DumpJobEnvironment" } | ||
* | ||
* physics.streams: [ metadataDumper ] | ||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
* will dump the metadata into a text file named `JobEnvironment.log`. | ||
* | ||
*/ | ||
class sbn::DumpJobEnvironment: public art::OutputModule { | ||
public: | ||
|
||
/// Module configuration. | ||
struct Config { | ||
|
||
using Name = fhicl::Name; | ||
using Comment = fhicl::Comment; | ||
|
||
fhicl::TableFragment<art::OutputModule::Config> OutputModuleConfig; | ||
|
||
fhicl::Atom<std::string> LogCategory { | ||
Name{ "LogCategory" }, | ||
Comment{ "name of the messagefacility output category to be used" }, | ||
"DumpJobEnvironment" | ||
}; | ||
|
||
}; // Config | ||
|
||
using Parameters | ||
= fhicl::WrappedTable<Config, art::OutputModule::Config::KeysToIgnore>; | ||
|
||
explicit DumpJobEnvironment(Parameters const& params); | ||
|
||
private: | ||
|
||
// --- BEGIN --- Configuration ----------------------------------------------- | ||
|
||
std::string const fLogCategory; ///< Messagefacility category for the output. | ||
|
||
// --- END ----- Configuration ----------------------------------------------- | ||
|
||
|
||
/// Dumps the information from an handle into the output stream. | ||
template <typename Stream> | ||
void dumpInformation( | ||
Stream& out, | ||
art::Handle<std::vector<sbn::JobEnvironmentInfo>> const& infoHandle | ||
) const; | ||
|
||
|
||
|
||
void write(art::EventPrincipal&) override {} | ||
void writeRun(art::RunPrincipal&) override {} | ||
void writeSubRun(art::SubRunPrincipal&) override {} | ||
|
||
/// Reads and prints all the metadata data products. | ||
void readResults(art::ResultsPrincipal const& results) override; | ||
|
||
}; // sbn::DumpJobEnvironment | ||
|
||
|
||
// ----------------------------------------------------------------------------- | ||
// --- Implementation | ||
// ----------------------------------------------------------------------------- | ||
sbn::DumpJobEnvironment::DumpJobEnvironment(Parameters const& params) | ||
: OutputModule{ params().OutputModuleConfig } | ||
, fLogCategory{ params().LogCategory() } | ||
{} | ||
|
||
|
||
// ----------------------------------------------------------------------------- | ||
void sbn::DumpJobEnvironment::readResults | ||
(art::ResultsPrincipal const& principal) | ||
{ | ||
if (!principal.size()) return; | ||
|
||
art::ModuleContext const moduleContext{ moduleDescription() }; | ||
art::Results const& results = principal.makeResults(moduleContext); | ||
|
||
std::vector<art::Handle<std::vector<sbn::JobEnvironmentInfo>>> infoHandles | ||
= results.getMany<std::vector<sbn::JobEnvironmentInfo>>(); | ||
|
||
mf::LogInfo out{ fLogCategory }; | ||
out << "Found " << infoHandles.size() << " job information entries in input."; | ||
|
||
for (art::Handle<std::vector<sbn::JobEnvironmentInfo>> const& infoHandle | ||
: infoHandles | ||
) { | ||
out << '\n' << std::string(80, '*') << '\n'; | ||
dumpInformation(out, infoHandle); | ||
} | ||
|
||
} // sbn::DumpJobEnvironment::readResults() | ||
|
||
|
||
// ----------------------------------------------------------------------------- | ||
template <typename Stream> | ||
void sbn::DumpJobEnvironment::dumpInformation( | ||
Stream& out, | ||
art::Handle<std::vector<sbn::JobEnvironmentInfo>> const& infoHandle | ||
) const { | ||
|
||
art::Provenance const* provenance = infoHandle.provenance(); | ||
if (provenance) { | ||
out << "Information from '" << provenance->inputTag().encode() << "'"; | ||
} | ||
else { | ||
out << "Information with unknown provenance"; | ||
} | ||
|
||
if (infoHandle.isValid()) { | ||
out << " from " << infoHandle->size() << " sources\n"; | ||
for (sbn::JobEnvironmentInfo const& info: *infoHandle) { | ||
out << std::string(80, '=') << '\n' << info; | ||
} | ||
} | ||
else out << "\n[information not available]\n"; | ||
|
||
} // sbn::DumpJobEnvironment::dumpInformation() | ||
|
||
|
||
// ----------------------------------------------------------------------------- | ||
DEFINE_ART_MODULE(sbn::DumpJobEnvironment) | ||
|
||
|
||
// ----------------------------------------------------------------------------- |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @file ${gitRepoVersionSourceStem}.cxx | ||
* @brief GIT version for repository `${gitRepoName}`. | ||
* @author automatically generated; | ||
* template: Gianluca Petrillo (petrillo@slac.stanford.edu) | ||
* @date January 18, 2025 | ||
* @see ${gitRepoVersionSourceStem}.h | ||
*/ | ||
|
||
#include "${gitRepoVersionSourceStem}.h" | ||
|
||
// ----------------------------------------------------------------------------- | ||
const char RepositoryVersion_${gitRepoName}[] = "${gitRepoVersion}"; | ||
|
||
|
||
// ----------------------------------------------------------------------------- |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @file ${gitRepoVersionSourceStem}.h | ||
* @brief GIT version for repository `${gitRepoName}`. | ||
* @author automatically generated; | ||
* template: Gianluca Petrillo (petrillo@slac.stanford.edu) | ||
* @date January 18, 2025 | ||
* @see ${gitRepoVersionSourceStem}.cxx | ||
*/ | ||
|
||
#ifndef ${gitRepoName}_${gitRepoVersionSourceStem}_H | ||
#define ${gitRepoName}_${gitRepoVersionSourceStem}_H | ||
|
||
|
||
/// Repository version for ${gitRepoName}. | ||
extern const char RepositoryVersion_${gitRepoName}[]; | ||
|
||
|
||
#endif // ${gitRepoName}_${gitRepoVersionSourceStem}_H |
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.
sbnobj