diff --git a/python/morpheus/morpheus/_lib/include/morpheus/controllers/monitor_controller.hpp b/python/morpheus/morpheus/_lib/include/morpheus/controllers/monitor_controller.hpp index d665a0120d..65a072ffef 100644 --- a/python/morpheus/morpheus/_lib/include/morpheus/controllers/monitor_controller.hpp +++ b/python/morpheus/morpheus/_lib/include/morpheus/controllers/monitor_controller.hpp @@ -42,7 +42,6 @@ #include namespace morpheus { -/****** Component public implementations *******************/ /******************* MonitorController**********************/ /** @@ -51,8 +50,7 @@ namespace morpheus { * @file */ -// A singleton that manages the lifetime of progress bars from any MonitorController instances -// and customized streambuf +// A singleton that manages the lifetime of progress bars related to any MonitorController instances class ProgressBarContextManager { public: @@ -70,7 +68,7 @@ class ProgressBarContextManager // DynamicProgress should take ownership over progressbars: https://github.com/p-ranav/indicators/issues/134 // The fix to this issue is not yet released, so we need to: - // - Maintain the lifetime of the progress bar in MultiProgressBarContext while it is being used + // - Maintain the lifetime of the progress bar in m_progress_bars // - Push the underlying progress bar object to the DynamicProgress container, since it accepts // Indicator &bar rather than std::unique_ptr bar before the fix return m_dynamic_progress_bars.push_back(*m_progress_bars.back()); @@ -90,12 +88,19 @@ class ProgressBarContextManager }; /** - * @brief + * @brief A controller class that manages the display of progress bars that used by MonitorStage. */ template class MonitorController { public: + /** + * @brief Construct a new Monitor Controller object + * + * @param description : A text label displayed on the left side of the progress bars + * @param unit : the unit of message count + * @param determine_count_fn : A function that computes the count for each incoming message + */ MonitorController(const std::string& description, std::string unit = "messages", std::optional> determine_count_fn = std::nullopt); diff --git a/python/morpheus/morpheus/_lib/include/morpheus/stages/monitor.hpp b/python/morpheus/morpheus/_lib/include/morpheus/stages/monitor.hpp index 19a9384816..0672acedf8 100644 --- a/python/morpheus/morpheus/_lib/include/morpheus/stages/monitor.hpp +++ b/python/morpheus/morpheus/_lib/include/morpheus/stages/monitor.hpp @@ -29,8 +29,8 @@ #include namespace morpheus { -/****** Component public implementations *******************/ -/****** MonitorStage********************************/ +/*************** Component public implementations ***************/ +/******************** MonitorStage ********************/ /** * @addtogroup controllers @@ -39,7 +39,7 @@ namespace morpheus { */ /** - * @brief + * @brief Displays descriptive progress bars including throughput metrics for the messages passing through the pipeline. */ template class MORPHEUS_EXPORT MonitorStage : public mrc::pymrc::PythonNode, std::shared_ptr> @@ -50,6 +50,13 @@ class MORPHEUS_EXPORT MonitorStage : public mrc::pymrc::PythonNode> determine_count_fn = std::nullopt); @@ -94,6 +101,16 @@ MonitorStage::subscribe_fn_t MonitorStage::build_operator() template struct MORPHEUS_EXPORT MonitorStageInterfaceProxy { + /** + * @brief Create and initialize a MonitorStage, and return the result + * + * @param builder : Pipeline context object reference + * @param name : Name of a stage reference + * @param description : A text label displayed on the left side of the progress bars + * @param unit : the unit of message count + * @param determine_count_fn : A function that computes the count for each incoming message + * @return std::shared_ptr>> + */ static std::shared_ptr>> init( mrc::segment::Builder& builder, const std::string& name, diff --git a/python/morpheus/morpheus/_lib/tests/controllers/test_monitor_controller.cpp b/python/morpheus/morpheus/_lib/tests/controllers/test_monitor_controller.cpp index dcc4f3c2c8..3f99cec009 100644 --- a/python/morpheus/morpheus/_lib/tests/controllers/test_monitor_controller.cpp +++ b/python/morpheus/morpheus/_lib/tests/controllers/test_monitor_controller.cpp @@ -106,30 +106,3 @@ TEST_F(TestMonitorController, TestAutoCountFn) // Test invalid message type EXPECT_THROW(MonitorController("invalid message type"), std::runtime_error); } - -TEST_F(TestMonitorController, TestProgressBar) -{ - auto message_meta_mc = MonitorController>("test_message_meta"); - auto meta = MessageMeta::create_from_cpp(std::move(create_cudf_table_with_metadata(10, 2))); - auto message_meta_mc_2 = MonitorController>("test_message_meta_2"); - auto meta_2 = MessageMeta::create_from_cpp(std::move(create_cudf_table_with_metadata(10, 2))); - auto message_meta_mc_3 = MonitorController>("test_message_meta_3"); - auto meta_3 = MessageMeta::create_from_cpp(std::move(create_cudf_table_with_metadata(10, 2))); - - auto control_message_mc = MonitorController>("test_control_message"); - auto control_message = std::make_shared(); - auto cm_meta = MessageMeta::create_from_cpp(std::move(create_cudf_table_with_metadata(20, 3))); - control_message->payload(cm_meta); - - for (int i = 0; i < 10; i++) - { - // std::cout << "log message" << std::endl; - message_meta_mc.progress_sink(meta); - // std::cout << "log message 2" << std::endl; - message_meta_mc_2.progress_sink(meta_2); - // std::cout << "log message 3" << std::endl; - message_meta_mc_3.progress_sink(meta_3); - control_message_mc.progress_sink(control_message); - std::this_thread::sleep_until(std::chrono::system_clock::now() + std::chrono::milliseconds(100)); - } -} diff --git a/tests/test_monitor_stage_pipe.py b/tests/test_monitor_stage_pipe.py index f0380a8de1..d017168ed8 100755 --- a/tests/test_monitor_stage_pipe.py +++ b/tests/test_monitor_stage_pipe.py @@ -36,15 +36,6 @@ from morpheus.stages.preprocess.deserialize_stage import DeserializeStage -def build_expected(df: pd.DataFrame, threshold: float, class_labels: typing.List[str]): - """ - Generate the expected output of an add class by filtering by a threshold and applying the class labels - """ - df = (df > threshold) - # Replace input columns with the class labels - return df.rename(columns=dict(zip(df.columns, class_labels))) - - def sample_message_meta_generator(df_rows: int, df_cols: int, count: int) -> Generator[MessageMeta, None, None]: data = {f'col_{i}': range(df_rows) for i in range(df_cols)} df = cudf.DataFrame(data)