From 0894b265a2f00f539451fc7e639f942525e6f109 Mon Sep 17 00:00:00 2001 From: Emily Howell Date: Mon, 28 Oct 2024 08:35:28 -0700 Subject: [PATCH] Adding an error to handle empty pipelines and a test to verify functionality (#1409) --- .../ascent/runtimes/ascent_main_runtime.cpp | 5 +++ src/tests/ascent/t_ascent_ascent_runtime.cpp | 43 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/libs/ascent/runtimes/ascent_main_runtime.cpp b/src/libs/ascent/runtimes/ascent_main_runtime.cpp index 4a2629641..0b8332d27 100644 --- a/src/libs/ascent/runtimes/ascent_main_runtime.cpp +++ b/src/libs/ascent/runtimes/ascent_main_runtime.cpp @@ -848,6 +848,11 @@ AscentRuntime::ConvertPipelineToFlow(const conduit::Node &pipeline, const std::vector &child_names = pipeline.child_names(); + if(child_names.empty()) + { + ASCENT_ERROR("Pipeline " << pipeline_name << " empty. Must specify a filter."); + } + for(int i = 0; i < pipeline.number_of_children(); ++i) { const std::string cname = child_names[i]; diff --git a/src/tests/ascent/t_ascent_ascent_runtime.cpp b/src/tests/ascent/t_ascent_ascent_runtime.cpp index 623237e81..c56378bde 100644 --- a/src/tests/ascent/t_ascent_ascent_runtime.cpp +++ b/src/tests/ascent/t_ascent_ascent_runtime.cpp @@ -269,3 +269,46 @@ TEST(ascent_pipeline, test_register_transform) EXPECT_TRUE(check_test_image(output_file)); } +TEST(ascent_pipeline, test_empty_pipeline_filter) +{ + Ascent ascent; + Node ascent_opts; + ascent_opts["exceptions"] = "forward"; + ascent.open(ascent_opts); + + // Initialize a pipeline and then remove the filter. This is what we are testing and should cause an error. + conduit::Node pipelines; + pipelines["pl1/f1/type"] = "garbage"; + pipelines.remove("pl1/f1"); + + conduit::Node scenes; + scenes["s1/plots/p1/type"] = "pseudocolor"; + scenes["s1/plots/p1/field"] = "pl"; + scenes["s1/plots/p1/pipeline"] = "pl1"; + + conduit::Node actions; + // add the pipeline + conduit::Node &add_pipelines= actions.append(); + add_pipelines["action"] = "add_pipelines"; + add_pipelines["pipelines"] = pipelines; + // add the scenes + conduit::Node &add_scenes= actions.append(); + add_scenes["action"] = "add_scenes"; + add_scenes["scenes"] = scenes; + // Save info + conduit::Node &save_info= actions.append(); + save_info["action"] = "save_info"; + + bool error_message = false; + + try + { + ascent.execute(actions); + } + catch (conduit::Error e) + { + error_message = e.message().find("Pipeline pl1 empty")!=std::string::npos; + } + + EXPECT_TRUE(error_message); +} \ No newline at end of file