15 #include "boost/program_options.hpp" 20 #include "cetlib_except/exception.h" 38 using namespace string_literals;
47 assert(!filename.empty());
56 <<
"Unable to write post-processed configuration to specified file " 68 }
else if (mode ==
"annotate") {
70 }
else if (mode ==
"prefix-annotate") {
74 <<
"Unrecognized ParameterSet printing mode: " << mode <<
'\n';
84 to_terminal ?
"follows" :
std::string(
"to file '" + filename +
"'");
94 std::cerr << banner(output_file);
95 auto os = make_ostream_handle(output_file);
110 if (not scheduler_pset.
has_key(
"debug")) {
111 return debug_processing::none;
114 auto const processing_options = {
115 "config-summary",
"config-out",
"debug-config",
"validate-config"};
117 auto const option = scheduler_pset.
get<
std::string>(
"debug.option");
119 if (pos ==
cend(processing_options)) {
122 "An error was encountered while processing debugging options"}
123 <<
"The debugging option '" << option <<
"' is not supported.\n" 124 <<
"If you did not explicitly provide this value in your configuration " 125 "file, please contact artists@fnal.gov and report this error. " 127 <<
"choose from 'configSummary', 'configOut', 'debugConfig', or " 128 "'validateConfig'.\n";
137 namespace bpo = boost::program_options;
144 bpo::options_description& all_desc,
148 bpo::positional_options_description pd;
150 pd.add(
"source", -1);
152 bpo::variables_map vm;
154 bpo::store(bpo::command_line_parser(argc, argv)
156 .style(bpo::command_line_style::default_style &
157 ~bpo::command_line_style::allow_guessing)
164 cerr <<
"Exception from command line processing in " << argv[0] <<
": " 169 for (
auto&
handler : handlers) {
177 for (
auto&
handler : handlers) {
187 auto const scheduler_key =
fhicl_key(
"services",
"scheduler");
188 auto enabled_modules = detail::EnabledModules::none();
191 auto const pruneConfigKey =
fhicl_key(scheduler_key,
"pruneConfig");
192 auto const reportUnusedKey =
fhicl_key(scheduler_key,
"reportUnused");
195 bool const prune_config = raw_config.
get<
bool>(pruneConfigKey);
196 bool const report_unused = raw_config.
get<
bool>(reportUnusedKey);
198 prune_config, report_unused, raw_config);
202 return e.returnCode();
208 catch (std::bad_alloc
const& bda) {
230 cerr <<
"ERROR: Failed to create a parameter set from parsed " 231 "configuration with exception " 232 << e.what() <<
".\n";
233 cerr <<
" Intermediate configuration state follows:\n" 235 << rule(
'-') <<
'\n';
236 for (
auto const& [
key,
value] : raw_config) {
237 cerr <<
key <<
": " <<
value.to_string() <<
'\n';
239 cerr << rule(
'-') <<
'\n' << rule(
'-') <<
'\n';
247 cerr <<
"Uncaught exception while inserting main parameter set into " 260 auto enabled_modules = detail::EnabledModules::none();
268 bpo::variables_map vm;
276 cerr <<
"ERROR: Failed to create a parameter set from an input " 277 "configuration string with exception " 278 << e.what() <<
".\n";
279 cerr <<
" Input configuration string follows:\n" 280 << rule(
'-') << rule(
'-') <<
"\n";
281 cerr << config_string <<
"\n";
282 cerr << rule(
'-') << rule(
'-') <<
'\n';
290 cerr <<
"Uncaught exception while inserting main parameter set into " 307 mallopt(M_ARENA_MAX, 1);
310 auto const services_pset =
312 auto const scheduler_pset =
316 auto const debug_mode = debug_processing_mode(scheduler_pset);
317 if (debug_mode != debug_processing::none) {
320 auto const mode = debug_pset.get<
std::string>(
"printMode");
322 switch (debug_mode) {
323 case debug_processing::validate_config: {
326 case debug_processing::config_out: {
327 print_config(main_pset, filename, mode);
330 case debug_processing::debug_config: {
331 print_config(main_pset, filename, mode);
334 case debug_processing::config_summary: {
338 case debug_processing::none:
351 cerr << e.what() <<
'\n';
355 cerr << e.what() <<
'\n';
359 cerr <<
"Caught unknown exception while initializing the message " 363 mf::LogInfo(
"MF_INIT_OK") <<
"Messagelogger initialization complete.";
375 if (debug_mode == debug_processing::validate_config) {
378 if (scheduler_pset.
has_key(
"dataDependencyGraph")) {
381 auto ep_rc = ep.runToCompletion();
382 if (ep_rc == EventProcessor::epSignal) {
384 if (scheduler_pset.
get<
bool>(
"errorOnSIGINT")) {
404 catch (bad_alloc
const& bda) {
void SetIteration(string const &val)
static ParameterSetID const & put(ParameterSet const &ps)
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
bool exists_outside_prolog(fhicl::intermediate_table const &config, std::string const &key)
void msg(const char *fmt,...)
void print_config_summary(fhicl::ParameterSet const &pset, std::string const &verbosity, EnabledModules const &enabled_modules)
int run_art_common_(fhicl::ParameterSet const &main_pset, detail::EnabledModules const &enabled_modules)
static ParameterSet make(intermediate_table const &tbl)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
char const * what() const noexcept override
int run_art_string_config(string const &config_string)
void printStdException(std::exception const &e, char const *prog)
std::atomic< int > shutdown_flag
void printUnknownException(char const *prog)
EnabledModules prune_config_if_enabled(bool prune_config, bool report_enabled, fhicl::intermediate_table &config)
void StartMessageFacility(fhicl::ParameterSet const &pset, string const &applicationName)
T get(std::string const &key) const
std::enable_if_t< std::is_convertible_v< T, std::string >, std::string > fhicl_key(T const &name)
std::string to_indented_string() const
std::vector< std::unique_ptr< art::OptionsHandler >> OptionsHandlers
MaybeLogger_< ELseverityLevel::ELsev_severe, false > LogSystem
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
bool has_key(std::string const &key) const
int processOptions(bpo::variables_map const &vm, fhicl::intermediate_table &raw_config)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
bool output_to_stderr(std::string const &spec)
intermediate_table parse_document(std::string const &filename, cet::filepath_maker &maker)
int run_art(int argc, char **argv, bpo::options_description &all_desc, OptionsHandlers &&handlers)
void printArtException(cet::exception const &e, char const *prog)
auto find_in_all(FwdCont &, Datum const &)
constexpr int info_success()
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
static msg_handler handler
void printBadAllocException(char const *prog)
bool output_to_stdout(std::string const &spec)
cet::coded_exception< error, detail::translate > exception