LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
print_config_summary.cc
Go to the documentation of this file.
4 #include "cetlib/HorizontalRule.h"
6 #include "range/v3/view.hpp"
7 
8 #include <iomanip>
9 #include <iostream>
10 
11 namespace {
12  constexpr cet::HorizontalRule header_rule{50};
13 }
14 
15 //---------------------------------------------------------------
16 void
18  std::string const& header)
19 {
20  auto const names = pset.get_names();
21  std::cout << header << ": " << size(names) << '\n';
22 }
23 
24 void
26 {
27  std::cout << "Trigger paths: " << size(enabled_modules.trigger_path_specs())
28  << '\n'
29  << (enabled_modules.trigger_paths_override() ?
30  " -> 'trigger_paths' specified\n" :
31  "")
32  << "End paths: " << size(enabled_modules.end_paths()) << '\n'
33  << (enabled_modules.end_paths_override() ?
34  " -> 'end_paths' specified\n" :
35  "");
36 }
37 
38 void
40 {
41  {
42  auto const& trigger_paths = enabled_modules.trigger_path_specs();
43  std::cout << '\n'
44  << header_rule('=') << '\n'
45  << "Trigger paths: " << size(trigger_paths) << '\n'
46  << (enabled_modules.trigger_paths_override() ?
47  " -> 'trigger_paths' specified\n\n" :
48  "\n");
49  if (empty(trigger_paths)) {
50  return;
51  }
52 
53  std::string column_0{"Path ID"};
54  std::string column_1{"Path name"};
55  std::string column_2{"Path size"};
56 
57  auto column_0_width = size(column_0);
58  auto column_1_width = size(column_1);
59  for (auto const& spec : trigger_paths | ::ranges::views::keys) {
60  column_1_width = std::max(column_1_width, size(spec.name));
61  }
62 
63  std::cout << column_0 << " " << std::left << std::setw(column_1_width)
64  << column_1 << " " << column_2 << '\n'
65  << std::string(column_0_width, '-') << " "
66  << std::string(column_1_width, '-') << " "
67  << std::string(size(column_2), '-') << '\n';
68  for (auto const& [path_spec, entries] :
69  enabled_modules.trigger_path_specs()) {
70  std::cout << std::right << std::setw(column_0_width)
71  << to_string(path_spec.path_id) << " " << std::left
72  << std::setw(column_1_width) << path_spec.name << " "
73  << size(entries) << '\n';
74  }
75  }
76 
77  {
78  auto const& end_paths = enabled_modules.end_paths();
79 
80  std::cout << '\n'
81  << header_rule('=') << '\n'
82  << "End paths: " << size(end_paths) << '\n'
83  << (enabled_modules.end_paths_override() ?
84  " -> 'end_paths' specified\n\n" :
85  "\n");
86 
87  if (empty(end_paths)) {
88  return;
89  }
90 
91  std::string column_1{"Path name"};
92  std::string column_2{"Path size"};
93  auto column_1_width = size(column_1);
94  for (auto const& spec : end_paths | ::ranges::views::keys) {
95  column_1_width = std::max(column_1_width, size(spec.name));
96  }
97 
98  std::cout << std::left << std::setw(column_1_width) << column_1 << " "
99  << column_2 << '\n'
100  << std::string(column_1_width, '-') << " "
101  << std::string(size(column_2), '-') << '\n';
102  for (auto const& [path_spec, entries] : end_paths) {
103  std::cout << std::left << std::setw(column_1_width) << path_spec.name
104  << " " << size(entries) << '\n';
105  }
106  }
107 }
108 
109 void
111 {
112  std::cout << '\n' << header_rule('=') << '\n';
113  print_table_numbers(pset, "Services");
114  std::cout << '\n';
115 
116  auto const names = pset.get_names();
117 
118  std::string column_1{"Service name"};
119  auto column_1_width = size(column_1);
120  auto column_2_width = std::string::size_type{};
121  for (auto const& name : names) {
122  auto const service_provider =
123  pset.get<std::string>(fhicl_key(name, "service_provider"), {});
124  column_1_width = std::max(column_1_width, size(name));
125  column_2_width = std::max(column_2_width, size(service_provider));
126  }
127 
128  cet::HorizontalRule const rule_1{column_1_width};
129  if (column_2_width == 0ull) {
130  std::cout << column_1 << '\n' << rule_1('-') << '\n';
131  for (auto const& name : names) {
132  std::cout << std::left << std::setw(column_1_width) << name << '\n';
133  }
134  } else {
135  std::string const column_2{"service_provider"};
136  cet::HorizontalRule const rule_2{std::max(column_2_width, size(column_2))};
137  std::cout << std::left << std::setw(column_1_width) << column_1 << " "
138  << column_2 << '\n'
139  << rule_1('-') << " " << rule_2('-') << '\n';
140  for (auto const& name : names) {
141  auto const service_provider =
142  pset.get<std::string>(fhicl_key(name, "service_provider"), "-");
143  std::cout << std::left << std::setw(column_1_width) << name << " "
144  << service_provider << '\n';
145  }
146  }
147 }
148 
149 void
151  std::string const& header)
152 {
153  std::cout << '\n' << header_rule('=') << '\n';
154  print_table_numbers(pset, header);
155 
156  auto const names = pset.get_names();
157  if (empty(names)) {
158  return;
159  }
160 
161  std::cout << '\n';
162  std::string column_1{"Module label"};
163  std::string column_2{"module_type"};
164  auto column_1_width = size(column_1);
165  auto column_2_width = size(column_2);
166  for (auto const& name : names) {
167  auto const module_type =
168  pset.get<std::string>(fhicl_key(name, "module_type"));
169  column_1_width = std::max(column_1_width, size(name));
170  column_2_width = std::max(column_2_width, size(module_type));
171  }
172 
173  cet::HorizontalRule const rule_1{column_1_width};
174  cet::HorizontalRule const rule_2{column_2_width};
175  std::cout << std::left << std::setw(column_1_width) << column_1 << " "
176  << column_2 << '\n'
177  << rule_1('-') << " " << rule_2('-') << '\n';
178  for (auto const& name : names) {
179  auto const module_type =
180  pset.get<std::string>(fhicl_key(name, "module_type"));
181  std::cout << std::left << std::setw(column_1_width) << name << " "
182  << module_type << '\n';
183  }
184 }
185 
186 void
188  std::string const& verbosity,
189  EnabledModules const& enabled_modules)
190 {
191  auto const process_name = pset.get<std::string>("process_name");
192  auto const source = pset.get<std::string>("source.module_type");
193  auto const services = pset.get<fhicl::ParameterSet>("services");
194  auto const physics = pset.get<fhicl::ParameterSet>("physics", {});
195  auto const analyzers = physics.get<fhicl::ParameterSet>("analyzers", {});
196  auto const filters = physics.get<fhicl::ParameterSet>("filters", {});
197  auto const producers = physics.get<fhicl::ParameterSet>("producers", {});
198  auto const outputs = pset.get<fhicl::ParameterSet>("outputs", {});
199 
200  std::cout << "Process name: " << process_name << '\n'
201  << "Source module: " << source << '\n';
202  if (verbosity == "brief") {
203  print_table_numbers(services, "Services");
204  print_table_numbers(producers, "Producers");
205  print_table_numbers(filters, "Filters");
206  print_table_numbers(analyzers, "Analyzers");
207  print_table_numbers(outputs, "Output modules");
208  print_path_numbers(enabled_modules);
209  return;
210  } else if (verbosity == "detailed") {
211  print_service_types(services);
212  std::cout << '\n' << header_rule('=') << '\n' << "Physics modules\n\n";
213  print_table_numbers(producers, "Producers");
214  print_table_numbers(filters, "Filters");
215  print_table_numbers(analyzers, "Analyzers");
216  print_module_types(outputs, "Output modules");
217  print_path_names(enabled_modules);
218  return;
219  } else if (verbosity == "full") {
220  print_service_types(services);
221  print_module_types(producers, "Producers");
222  print_module_types(filters, "Filters");
223  print_module_types(analyzers, "Analyzers");
224  print_module_types(outputs, "Output modules");
225  print_path_names(enabled_modules);
226  return;
227  }
229  << "Unrecognized configuration-summary verbosity level: '" << verbosity
230  << "'\n";
231 }
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:102
void print_config_summary(fhicl::ParameterSet const &pset, std::string const &verbosity, EnabledModules const &enabled_modules)
void print_service_types(fhicl::ParameterSet const &pset)
void print_module_types(fhicl::ParameterSet const &pset, std::string const &header)
PathID path_id
Definition: PathSpec.h:49
ModuleType module_type(std::string const &full_key)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
void print_table_numbers(fhicl::ParameterSet const &pset, std::string const &header)
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
module_entries_for_ordered_path_t end_paths() const noexcept
T get(std::string const &key) const
Definition: ParameterSet.h:314
std::enable_if_t< std::is_convertible_v< T, std::string >, std::string > fhicl_key(T const &name)
Definition: fhicl_key.h:12
module_entries_for_ordered_path_t const & trigger_path_specs() const noexcept
std::string name
Definition: PathSpec.h:48
bool end_paths_override() const noexcept
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
bool trigger_paths_override() const noexcept
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:94
std::vector< std::string > get_names() const
void print_path_numbers(EnabledModules const &enabled_modules)
PathSpec path_spec(std::string const &path_spec)
Definition: PathSpec.cc:22
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109
void print_path_names(EnabledModules const &enabled_modules)