9 #include "boost/graph/graph_utility.hpp" 25 using namespace fhicl;
30 names_t const all_tables{
"physics.producers",
34 names_t const tables_with_modifiers{all_tables[0], all_tables[1]};
35 names_t const tables_with_observers{all_tables[2], all_tables[3]};
38 module_type_for_table(
string const& table)
40 if (table ==
"physics.producers")
42 if (table ==
"physics.filters")
44 if (table ==
"physics.analyzers")
46 if (table ==
"outputs")
54 std::map<std::string, ModuleConfigInfo>
result;
55 for (
auto const&
name : all_tables) {
65 for (
auto const& module_name : modules_in_table) {
83 std::map<std::string, ModuleConfigInfo>
const& module_configs)
89 auto const tmp = physics.
get<std::vector<string>>(
name);
92 tmp, back_inserter(configs), [&module_configs](
auto const&
label) {
93 auto const&
info = module_configs.at(
label);
104 module_found_in_table(
string const& module_name,
106 string const& table_name)
108 if (!pset.
has_key(table_name)) {
112 return table.
has_key(module_name);
116 module_found_with_type(
string const& module_name,
ParameterSet const& pset)
118 if (module_found_in_table(module_name, pset,
"physics.producers"))
120 if (module_found_in_table(module_name, pset,
"physics.filters"))
122 if (module_found_in_table(module_name, pset,
"physics.analyzers"))
124 if (module_found_in_table(module_name, pset,
"outputs"))
133 return "physics.producers";
135 return "physics.filters";
137 return "physics.analyzers";
144 module_found_in_tables(
string const& module_name,
148 for (
auto const& table_name : table_names) {
149 if (module_found_in_table(module_name, pset, table_name)) {
162 std::vector<string> paths_to_erase;
163 for (
auto const& pr : paths_to_modules) {
164 auto const& path_name = pr.first.name;
165 auto const& modules = pr.second;
166 bool first_module{
true};
168 for (
auto const& module : modules) {
169 auto const& module_label =
170 module.moduleConfigInfo->modDescription.moduleLabel();
172 first_module =
false;
173 present = module_found_in_tables(module_label, pset, tables);
175 module_found_in_tables(module_label, pset, tables)) {
179 <<
"There is an inconsistency in path " << path_name <<
".\n" 180 <<
"Module " << module_label
181 <<
" is a modifier/observer whereas the other modules\n" 182 <<
"on the path are the opposite.";
186 result.emplace_back(pr);
187 paths_to_erase.push_back(path_name);
190 for (
auto const& path : paths_to_erase) {
192 std::find_if(paths_to_modules.cbegin(),
193 paths_to_modules.cend(),
194 [&path](
auto const& pr) {
return pr.first.name == path; });
195 assert(path_it != paths_to_modules.cend());
196 paths_to_modules.erase(path_it);
205 for (
auto const& pr : paths_to_modules) {
215 for (
auto const& pr : paths_to_modules) {
216 result.
insert(pr.first.name);
221 std::set<art::ProductInfo>
222 sorted_produced_products(
223 std::vector<art::test::TypeAndInstance>
const& productsToProduce,
224 string const& module_name,
225 string const& current_process_name)
227 std::set<art::ProductInfo>
result;
228 for (
auto const& prod : productsToProduce) {
231 prod.friendlyClassName,
233 prod.productInstanceName,
239 template <
typename T>
241 consumables_for_module(
Table<T> const& module,
242 string const& current_process_name)
244 std::vector<art::ProductInfo> sorted_deps;
245 std::vector<art::test::TypeAndTag> deps;
246 if (module().consumes(deps)) {
247 for (
auto const& dep : deps) {
249 current_process_name};
251 dep.friendlyClassName,
252 dep.inputTag.label(),
253 dep.inputTag.instance(),
257 std::vector<std::string> many;
258 if (module().consumesMany(many)) {
259 for (
auto const& class_name : many) {
265 art::ConsumesInfo::consumables_t::mapped_type result{{}};
273 string const& process_name,
274 string const& path_name,
276 std::map<
std::string, std::set<art::ProductInfo>>& produced_products,
281 auto const& module_name =
282 it->moduleConfigInfo->modDescription.moduleLabel();
283 auto&
info = modules[module_name];
284 info.paths.insert(path_name);
285 info.module_type = module_found_with_type(module_name, pset);
286 auto const table_name = table_for_module_type(
info.module_type);
293 std::vector<art::test::TypeAndInstance> prods;
294 if (mod().produces(prods)) {
295 info.produced_products =
296 sorted_produced_products(prods, module_name, process_name);
297 produced_products[module_name] =
info.produced_products;
305 string const& process_name,
306 string const& path_name,
308 std::map<
std::string, std::set<art::ProductInfo>>
const& produced_products,
313 auto const& module_name =
314 it->moduleConfigInfo->modDescription.moduleLabel();
315 auto&
info = modules[module_name];
316 info.paths.insert(path_name);
317 info.module_type = module_found_with_type(module_name, pset);
318 auto const table_name = table_for_module_type(
info.module_type);
325 auto const consumables = consumables_for_module(mod, process_name);
327 process_name, consumables, produced_products, {},
begin, it);
334 string const& process_name,
335 string const& path_name,
337 std::map<
std::string, std::set<art::ProductInfo>>
const& produced_products,
342 auto const& module_name =
343 it->moduleConfigInfo->modDescription.moduleLabel();
344 auto&
info = modules[module_name];
345 info.paths.insert(path_name);
346 info.module_type = module_found_with_type(module_name, pset);
347 auto const table_name = table_for_module_type(
info.module_type);
354 auto const consumables = consumables_for_module(mod, process_name);
356 process_name, consumables, produced_products, {},
begin, it);
357 std::vector<string> sel;
358 if (mod().select_events(sel)) {
374 auto const& process_name = table().process_name();
375 auto const& test_properties = table().test_properties();
383 auto module_configs = get_module_configs(pset);
384 auto paths_to_modules = get_paths_to_modules(physics, module_configs);
385 auto const trigger_paths =
386 select_paths(pset, tables_with_modifiers, paths_to_modules);
387 auto end_paths = paths_to_modules;
389 auto const end_path = merge_end_paths(end_paths);
394 auto& source_info = modules[
"input_source"];
395 if (!trigger_paths.empty()) {
396 source_info.paths = path_names(trigger_paths);
397 }
else if (!end_path.empty()) {
398 source_info.paths = {
"end_path"};
402 std::map<std::string, std::set<art::ProductInfo>> produced_products{};
403 for (
auto const& path : trigger_paths) {
404 fillProducesInfo(pset,
422 bool graph_failure{
false};
424 for (
auto const& path : trigger_paths) {
425 fillModifierInfo(pset,
433 if (!trigger_paths.empty()) {
438 pset, process_name,
"end_path", end_path, produced_products, modules);
442 graph_failure =
true;
447 if (err_msg.empty()) {
449 auto const module_graph =
451 auto const&
err = module_graph.second;
454 graph_failure =
true;
460 std::ofstream ofs{basename +
".dot"};
466 bool const graph_failure_expected = test_properties.graph_failure_expected();
467 if (graph_failure && !graph_failure_expected) {
468 std::cerr <<
"Unexpected graph-construction failure.\n" 469 <<
"Error message:\n" 472 }
else if (!graph_failure && graph_failure_expected) {
473 std::cerr <<
"Unexpected graph-construction success.\n";
477 if (test_properties.error_message(expected_msg)) {
478 std::regex
const re{expected_msg};
479 if (!std::regex_search(err_msg, re)) {
480 std::cerr <<
" The error message does not match what was expected:\n" 481 <<
" Actual: [" << err_msg <<
"]\n" 482 <<
" Expected: [" << expected_msg <<
"]\n";
488 catch (detail::validationException
const& v) {
489 std::cerr << v.what();
493 std::cerr << e.what() <<
'\n';
497 std::cerr <<
"Job failed.\n";
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
static ParameterSet make(intermediate_table const &tbl)
std::map< module_name_t, ModuleGraphInfo > collection_map_t
ModuleType module_type(std::string const &full_key)
int main(int argc, char **argv)
void sort_all(RandCont &)
bool is_key_to_sequence(std::string const &key) const
std::vector< std::string > get_pset_names() const
bool is_key_to_table(std::string const &key) const
std::set< std::string > name_set_t
std::vector< WorkerInPath::ConfigInfo > configs_t
T get(std::string const &key) const
constexpr exempt_ptr< E > make_exempt_ptr(E *) noexcept
void print_module_graph(std::ostream &os, ModuleGraphInfoMap const &modInfos, ModuleGraph const &graph)
bool has_key(std::string const &key) const
std::vector< std::pair< PathSpec, configs_t >> paths_to_modules_t
QCString & insert(uint index, const char *s)
auto transform_all(Container &, OutputIt, UnaryOp)
void err(const char *fmt,...)
bool is_modifier(ModuleType const mt)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
constexpr static auto invalid() noexcept
std::optional< T > get_if_present(std::string const &key) const
std::vector< std::string > get_names() const
std::set< ProductInfo > consumed_products_for_module(std::string const ¤t_process, ConsumesInfo::consumables_t::mapped_type const &consumables, std::map< std::string, std::set< ProductInfo >> const &produced_products, std::map< std::string, std::set< std::string >> const &viewable_products, config_const_iterator const config_begin, config_const_iterator const config_it)
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
std::vector< std::string > names_t
bool is_observer(ModuleType const mt)
def maker(G, ac, typename)
constexpr ProductStatus present() noexcept
cet::coded_exception< error, detail::translate > exception
std::pair< ModuleGraph, std::string > make_module_graph(ModuleGraphInfoMap const &modInfos, paths_to_modules_t const &trigger_paths, configs_t const &end_path)