Skip to content

Commit

Permalink
Adding actions for adjusting the logging and echo thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
emily-howell committed Jan 15, 2025
1 parent be30d4a commit fd260e8
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/libs/ascent/runtimes/ascent_main_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1941,7 +1941,7 @@ AscentRuntime::BuildGraph(const conduit::Node &actions)
{
// Open Ascent Logging Stream
// This starts logging
ascent::Logger::instance().set_log_threshold(ascent::Logger::LOG_ALL_ID);
ascent::Logger::instance().set_log_threshold(ascent::Logger::LOG_DEBUG_ID);
std::string file_pattern = action.has_path("file_pattern") ?
action["file_pattern"].as_string() : "ascent_log_output.yaml";
ASCENT_LOG_OPEN(file_pattern);
Expand All @@ -1952,6 +1952,30 @@ AscentRuntime::BuildGraph(const conduit::Node &actions)
// This is so they can be seen before ascent is closed out
ASCENT_LOG_FLUSH();
}
else if(action_name == "set_log_threshold")
{
// Change the logging level
if (action.has_path("log_threshold"))
{
ascent::Logger::instance().set_log_threshold(action["log_threshold"].as_string());
}
else
{
ASCENT_WARN("No Log Threshold level given. No changes to logging behavior made.");
}
}
else if(action_name == "set_echo_threshold")
{
// Change the echo to standard output level
if (action.has_path("echo_threshold"))
{
ascent::Logger::instance().set_log_threshold(action["echo_threshold"].as_string());
}
else
{
ASCENT_WARN("No Echo Threshold level given. No changes to echo output behavior made.");
}
}
else if(action_name == "close_log")
{
// Closes current log stream
Expand Down
82 changes: 82 additions & 0 deletions src/tests/ascent/t_ascent_logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,86 @@ TEST(ascent_logging, test_logging_actions)
conduit::Node log_file_contents;
log_file_contents.load(log_file);
EXPECT_EQ(log_file_contents.number_of_children(), 5);
}

TEST(ascent_logging, test_logging_actions_threshold)
{
Node n;
ascent::about(n);
// only run this test if ascent was built with vtkm support
if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
{
ASCENT_INFO("Ascent vtkm support disabled, skipping test");
return;
}

//
// Create an example mesh.
//
Node data, verify_info;
conduit::blueprint::mesh::examples::braid("hexs",
5,
5,
5,
data);
EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));


string output_path = prepare_output_dir();
string output_file = conduit::utils::join_file_path(output_path,"tout_logging_render4");
string log_file = conduit::utils::join_file_path(output_path,"ascent_action_log_thresholded.yaml");

// remove old images/log files before rendering
remove_test_image(output_file);
conduit::utils::remove_path_if_exists(log_file);
EXPECT_FALSE(conduit::utils::is_file(log_file));

conduit::Node actions;
conduit::Node &add_scenes= actions.append();
add_scenes["action"] = "add_scenes";
conduit::Node &scenes = add_scenes["scenes"];
scenes["s1/plots/p1/type"] = "pseudocolor";
scenes["s1/plots/p1/field"] = "braid";
scenes["s1/image_prefix"] = output_file;

conduit::Node actions_begin_logs;
conduit::Node &begin_logs= actions_begin_logs.append();
begin_logs["action"] = "open_log";
begin_logs["file_pattern"] = log_file;
conduit::Node &set_threshold_logs_open= actions_begin_logs.append();
set_threshold_logs_open["action"] = "set_log_threshold";
set_threshold_logs_open["log_threshold"] = "error";

conduit::Node actions_flush_logs;
conduit::Node &flush_logs= actions_flush_logs.append();
flush_logs["action"] = "flush_log";

conduit::Node actions_close_logs;
conduit::Node &set_threshold_logs_close= actions_close_logs.append();
set_threshold_logs_close["action"] = "set_log_threshold";
set_threshold_logs_close["log_threshold"] = "debug";
conduit::Node &close_logs= actions_close_logs.append();
close_logs["action"] = "close_log";

//
// Run Ascent
//

Ascent ascent;

ascent.open();
ascent.publish(data);
ascent.execute(actions_begin_logs);
ascent.execute(actions);
ascent.execute(actions_flush_logs);
ascent.execute(actions_close_logs);
ascent.close();

// check that the log file exists
EXPECT_TRUE(conduit::utils::is_file(log_file));

// check that the log file has the expected number of logs in it (1 open, 3 execution, 1 close)
conduit::Node log_file_contents;
log_file_contents.load(log_file);
EXPECT_EQ(log_file_contents.number_of_children(), 2);
}

0 comments on commit fd260e8

Please sign in to comment.