Skip to content

Commit

Permalink
Adding an error to handle empty pipelines and a test to verify functi…
Browse files Browse the repository at this point in the history
…onality (#1409)
  • Loading branch information
emily-howell authored Oct 28, 2024
1 parent bd1182d commit 0894b26
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libs/ascent/runtimes/ascent_main_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,11 @@ AscentRuntime::ConvertPipelineToFlow(const conduit::Node &pipeline,

const std::vector<std::string> &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];
Expand Down
43 changes: 43 additions & 0 deletions src/tests/ascent/t_ascent_ascent_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 0894b26

Please sign in to comment.