From bc6cb589e3f30d445737d984c122a9dc49034024 Mon Sep 17 00:00:00 2001 From: Alex Lin Date: Tue, 26 Jul 2016 13:40:38 -0500 Subject: [PATCH] Monte carlo AttributeError's caused by bad configuration still returns zero in master sim #269 The return code from parsing the monte carlo input was always set to zero and not checked. Retured the return code from parsing the input. Added an exit if the input was not parsed correctly. --- include/trick/MonteCarlo.hh | 1 + trick_source/sim_services/InputProcessor/IPPython.cpp | 5 +++-- .../sim_services/InputProcessor/input_processor_ext.cpp | 3 +-- .../sim_services/MonteCarlo/MonteCarlo_master_shutdown.cpp | 2 +- .../MonteCarlo/MonteCarlo_receive_slave_results.cpp | 7 +++++++ .../MonteCarlo/MonteCarlo_slave_process_run.cpp | 4 +++- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/trick/MonteCarlo.hh b/include/trick/MonteCarlo.hh index 745d3743..87e6d167 100644 --- a/include/trick/MonteCarlo.hh +++ b/include/trick/MonteCarlo.hh @@ -36,6 +36,7 @@ namespace Trick { CORED, /**< core dumped */ TIMEDOUT, /**< timed out */ NO_PERM, /**< could not write output files */ + BAD_INPUT, /**< problem parseing monte carlo input */ UNKNOWN /**< unrecognized return code */ }; diff --git a/trick_source/sim_services/InputProcessor/IPPython.cpp b/trick_source/sim_services/InputProcessor/IPPython.cpp index e7b39071..3a9b50d2 100644 --- a/trick_source/sim_services/InputProcessor/IPPython.cpp +++ b/trick_source/sim_services/InputProcessor/IPPython.cpp @@ -141,12 +141,13 @@ int Trick::IPPython::init() { //Command to parse the given string. int Trick::IPPython::parse(std::string in_string) { + int ret ; pthread_mutex_lock(&ip_mutex); in_string += "\n" ; - PyRun_SimpleString(in_string.c_str()) ; + ret = PyRun_SimpleString(in_string.c_str()) ; pthread_mutex_unlock(&ip_mutex); - return 0 ; + return ret ; } diff --git a/trick_source/sim_services/InputProcessor/input_processor_ext.cpp b/trick_source/sim_services/InputProcessor/input_processor_ext.cpp index 3d45fcfe..9a7b38f5 100644 --- a/trick_source/sim_services/InputProcessor/input_processor_ext.cpp +++ b/trick_source/sim_services/InputProcessor/input_processor_ext.cpp @@ -14,8 +14,7 @@ extern Trick::InputProcessor * the_ip ; extern "C" int ip_parse(const char * in_string) { - the_ip->parse(in_string) ; - return(0) ; + return the_ip->parse(in_string) ; } /** diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_master_shutdown.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_master_shutdown.cpp index 071b33ab..fe69407b 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_master_shutdown.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_master_shutdown.cpp @@ -60,7 +60,7 @@ void Trick::MonteCarlo::shutdown_slaves() { void Trick::MonteCarlo::print_statistics(FILE** fp) { static const char *exit_status_string[] = {"Incomplete", "Complete", "Core Dumped", "Timed Out", - "No Permission to Output Directory" } ; + "No Permission to Output Directory", "Bad Input" } ; fprintf(*fp, "\nMonte Carlo complete: %u runs (%zu successful) (%zu errors) (%u out of range)\n", diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_receive_slave_results.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_receive_slave_results.cpp index 22c8b417..73ab2d97 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_receive_slave_results.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_receive_slave_results.cpp @@ -68,6 +68,13 @@ void Trick::MonteCarlo::receive_slave_results() { } resolve_run(curr_slave, MonteRun::UNKNOWN); break; + case MonteRun::BAD_INPUT: + if (verbosity >= ERROR) { + message_publish(MSG_ERROR, "Monte [Master] %s:%d reported bad input for run %d. Skipping.\n", + curr_slave->machine_name.c_str(), curr_slave->id, curr_slave->current_run->id) ; + } + resolve_run(curr_slave, MonteRun::BAD_INPUT); + break; case MonteRun::CORED: if (verbosity >= ERROR) { message_publish(MSG_ERROR, "Monte [Master] %s:%d reported core dump for run %d. Skipping.\n", diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_slave_process_run.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_slave_process_run.cpp index bdb3ca42..f3f7baa8 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_slave_process_run.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_slave_process_run.cpp @@ -99,7 +99,9 @@ int Trick::MonteCarlo::slave_process_run() { } else { input[size] = '\0'; - ip_parse(input); + if ( ip_parse(input) != 0 ) { + exit(MonteRun::BAD_INPUT); + } /**