From 07e069462de1a247a5c8a4b8a296f8d487235f62 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Mon, 15 Sep 2025 16:22:31 -0700 Subject: [PATCH 1/5] Incomplete work on a CL processor check --- Cpp/Executables/Main/Nymph.cc | 6 ++++++ Cpp/Library/Implementation/RunNymph.cc | 11 +++++++++++ Cpp/Library/Implementation/RunNymph.hh | 5 ++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Cpp/Executables/Main/Nymph.cc b/Cpp/Executables/Main/Nymph.cc index ac2b460..8c48b7f 100644 --- a/Cpp/Executables/Main/Nymph.cc +++ b/Cpp/Executables/Main/Nymph.cc @@ -66,10 +66,12 @@ int main( int argc, char** argv ) // Create the application scarab::main_app the_main; + the_main.require_subcommand(0, 1); the_main.set_global_verbosity(scarab::logger::ELevel::eDebug); // add the typical CL options Nymph::AddRunNymphOptions( the_main ); + Nymph::AddProcessorCheckOptions( the_main ); //Runs RunNymph() and sets the_return based on its return value int the_return = -1; @@ -79,6 +81,10 @@ int main( int argc, char** argv ) the_main.callback( t_callback ); + // Checks for the existence of a processor type using Nymph::ProcessorCheck() + CLI::App* t_proc_check = the_main.add_config_subcommand( "proc-check", "Check if a processor type is known" ); + t_proc_check->callback( [&](){ Nymph::ProcessorCheck(the_main.primary_config()); } ); + // Parse CL options and run the application CLI11_PARSE( the_main, argc, argv ); diff --git a/Cpp/Library/Implementation/RunNymph.cc b/Cpp/Library/Implementation/RunNymph.cc index 3521d24..6f9e356 100644 --- a/Cpp/Library/Implementation/RunNymph.cc +++ b/Cpp/Library/Implementation/RunNymph.cc @@ -69,4 +69,15 @@ namespace Nymph // options an_app.add_config_flag< bool >( "--dry-run", "dry-run", "Load the config, setup processors, but do not execute the run" ); } + + int ProcessorCheck( scarab::param_node& config ) + { + + } + + void AddProcessorCheckOptions( scarab::config_decorator* a_subcommand ) + { + // options + a_subcommand->add_config_option< std::string >( "proc-type", "proc-type", "Processor type to check for" ); + } } diff --git a/Cpp/Library/Implementation/RunNymph.hh b/Cpp/Library/Implementation/RunNymph.hh index aba61f4..9a6ad01 100644 --- a/Cpp/Library/Implementation/RunNymph.hh +++ b/Cpp/Library/Implementation/RunNymph.hh @@ -10,6 +10,7 @@ namespace scarab { + class config_decorator; class main_app; class param_node; } @@ -17,8 +18,10 @@ namespace scarab namespace Nymph { int RunNymph( scarab::param_node& config ); - void AddRunNymphOptions( scarab::main_app& an_app ); + + int ProcessorCheck( scarab::param_node& config ); + void AddProcessorCheckOptions( scarab::config_decorator* an_app ); } From c12d2cc1d99bc4f2c96eea35c47d3a23ab4f154f Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Wed, 17 Sep 2025 14:36:40 -0700 Subject: [PATCH 2/5] Updated scarab (on a feature branch) --- Scarab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scarab b/Scarab index b899601..b748b78 160000 --- a/Scarab +++ b/Scarab @@ -1 +1 @@ -Subproject commit b899601d9c5f6a81734b6bd78f3056a1bf52b708 +Subproject commit b748b785bf4b5e633ba7eed1cdd1984b3ff86cc0 From 172414ffabb6923613d6362b83653cecb1f760b3 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Wed, 17 Sep 2025 14:37:21 -0700 Subject: [PATCH 3/5] Add processor checking functions to RunNymph --- Cpp/Library/Implementation/RunNymph.cc | 38 +++++++++++++++++++++-- Cpp/Library/Processor/ProcessorToolbox.hh | 7 +++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Cpp/Library/Implementation/RunNymph.cc b/Cpp/Library/Implementation/RunNymph.cc index 6f9e356..21196b9 100644 --- a/Cpp/Library/Implementation/RunNymph.cc +++ b/Cpp/Library/Implementation/RunNymph.cc @@ -70,14 +70,48 @@ namespace Nymph an_app.add_config_flag< bool >( "--dry-run", "dry-run", "Load the config, setup processors, but do not execute the run" ); } - int ProcessorCheck( scarab::param_node& config ) + int ProcessorCheck( scarab::param_node& a_config ) { + ProcessorToolbox tb; + + LWARN( nlog, a_config ); + if( a_config.has( "list-procs" ) && a_config["list-procs"]().as_bool() ) + { + using factory_type = const scarab::factory< Processor, const std::string& >; + factory_type* t_factory = tb.ProcFactory(); + std::stringstream t_list_ss; + for( auto it = t_factory->begin(); it != t_factory->end(); ++it ) + { + t_list_ss << it->first << '\n'; + + } + LPROG( nlog, "Available processors:\n" << t_list_ss.str() ); + return RETURN_SUCCESS; + } + else + { + if( ! a_config.has( "proc-type" ) || a_config["proc-type"]().as_string().empty() ) + { + LERROR( nlog, "No processor type was provided to check" ); + return RETURN_ERROR; + } + std::string t_proc_type( a_config["proc-type"]().as_string() ); + bool t_proc_is_available = tb.CouldBuild( t_proc_type ); + if( ! t_proc_is_available ) + { + LWARN( nlog, "Processor <" << t_proc_type << "> is NOT registered with the processor toolbox" ); + return -1; + } + LPROG( nlog, "Processor <" << t_proc_type << "> is known to the processor toolbox" ); + return RETURN_SUCCESS; + } } void AddProcessorCheckOptions( scarab::config_decorator* a_subcommand ) { // options - a_subcommand->add_config_option< std::string >( "proc-type", "proc-type", "Processor type to check for" ); + a_subcommand->add_config_option< std::string >( "proc-type", "proc-type", "Query Nymph to see if this processor type has been registered; returns 0 if present; -1 if not present" ); + a_subcommand->add_config_flag< bool >( "-l,--list-procs", "list-procs", "List available processors" ); } } diff --git a/Cpp/Library/Processor/ProcessorToolbox.hh b/Cpp/Library/Processor/ProcessorToolbox.hh index c51283c..76ac86e 100644 --- a/Cpp/Library/Processor/ProcessorToolbox.hh +++ b/Cpp/Library/Processor/ProcessorToolbox.hh @@ -118,6 +118,8 @@ namespace Nymph /// Also clears the run queue void ClearProcessors(); + const scarab::factory< Processor, const std::string& >* ProcFactory() const; + protected: ProcessorMap fProcMap; @@ -177,5 +179,10 @@ namespace Nymph return MakeConnection(signalProcName, signalName, slotProcName, slotName, std::numeric_limits< int >::min()); } + inline const scarab::factory< Processor, const std::string& >* ProcessorToolbox::ProcFactory() const + { + return fProcFactory; + } + } /* namespace Nymph */ #endif /* NYMPH_PROCESSORTOOLBOX_HH_ */ From c2c6b231bdd89ebb7d4164bcc40b7a5905933a3d Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Wed, 17 Sep 2025 14:37:35 -0700 Subject: [PATCH 4/5] Use processor checking in the Nymph executable --- Cpp/Executables/Main/Nymph.cc | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Cpp/Executables/Main/Nymph.cc b/Cpp/Executables/Main/Nymph.cc index 8c48b7f..014fcf1 100644 --- a/Cpp/Executables/Main/Nymph.cc +++ b/Cpp/Executables/Main/Nymph.cc @@ -63,27 +63,28 @@ int main( int argc, char** argv ) // Start handling signals scarab::signal_handler t_sig_hand; + int the_return = -1; + // Create the application scarab::main_app the_main; + //Runs RunNymph() and sets the_return based on its return value + auto t_callback = [&](){ + // If any subcommands were called, we don't execute the main callback + if( the_main.get_subcommands().size() > 0 ) return; + the_return = Nymph::RunNymph( the_main.primary_config() ); + }; + the_main.callback( t_callback ); + + // Checks for the existence of a processor type and lists processors + scarab::config_decorator* t_proc_check = the_main.add_config_subcommand( "proc-check", "Check if a processor type is known" ); + t_proc_check->this_app()->callback( [&](){ the_return = Nymph::ProcessorCheck(the_main.primary_config()); } ); the_main.require_subcommand(0, 1); the_main.set_global_verbosity(scarab::logger::ELevel::eDebug); // add the typical CL options Nymph::AddRunNymphOptions( the_main ); - Nymph::AddProcessorCheckOptions( the_main ); - - //Runs RunNymph() and sets the_return based on its return value - int the_return = -1; - auto t_callback = [&](){ - the_return = Nymph::RunNymph( the_main.primary_config() ); - }; - - the_main.callback( t_callback ); - - // Checks for the existence of a processor type using Nymph::ProcessorCheck() - CLI::App* t_proc_check = the_main.add_config_subcommand( "proc-check", "Check if a processor type is known" ); - t_proc_check->callback( [&](){ Nymph::ProcessorCheck(the_main.primary_config()); } ); + Nymph::AddProcessorCheckOptions( t_proc_check ); // Parse CL options and run the application CLI11_PARSE( the_main, argc, argv ); From 20f49ad2f8219b70dc53831c903439f67cfbed1b Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Wed, 17 Sep 2025 16:36:06 -0700 Subject: [PATCH 5/5] Scarab updated to v3.13.2 (on develop) --- Scarab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scarab b/Scarab index b748b78..cb559e0 160000 --- a/Scarab +++ b/Scarab @@ -1 +1 @@ -Subproject commit b748b785bf4b5e633ba7eed1cdd1984b3ff86cc0 +Subproject commit cb559e090c950f56a6ddb12d1ae1f10a338440e7