Skip to content

Commit

Permalink
move to more yaml output and fix for sparse field filtering (#1144)
Browse files Browse the repository at this point in the history
* fix for field filtering with sparse fields

* yaml instead of json in several places
  • Loading branch information
cyrush committed May 18, 2023
1 parent 78783ff commit 744a36a
Show file tree
Hide file tree
Showing 17 changed files with 259 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/examples/proxies/kripke/Kripke/Sweep_Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void writeAscentData(Ascent &ascent, Grid_Data *grid_data, int timeStep)
conduit::Node verify_info;
if(!conduit::blueprint::mesh::verify(data,verify_info))
{
CONDUIT_INFO("blueprint verify failed!" + verify_info.to_json());
CONDUIT_INFO("blueprint verify failed!" + verify_info.to_yaml());
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/examples/proxies/lulesh2.0.3/lulesh-init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Domain::Domain(Int_t numRanks, Int_t myRank,
conduit::Node verify_info;
if(!conduit::blueprint::mesh::verify(m_ascent_node,verify_info))
{
CONDUIT_INFO("blueprint verify failed!" + verify_info.to_json());
CONDUIT_INFO("blueprint verify failed!" + verify_info.to_yaml());
}

/*--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ascent/runtimes/ascent_empty_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ EmptyRuntime::Publish(const conduit::Node &data)
{
ASCENT_ERROR("Mesh Blueprint Verify failed!"
<< std::endl
<< verify_info.to_json());
<< verify_info.to_yaml());
}
#endif

Expand Down
12 changes: 11 additions & 1 deletion src/libs/ascent/runtimes/ascent_main_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ AscentRuntime::CreateScenes(const conduit::Node &scenes)
conduit::Node scene = scenes.child(i);
if(!scene.has_path("plots"))
{
ASCENT_ERROR("Scene must have at least one plot: "<<scene.to_json());
ASCENT_ERROR("Scene must have at least one plot: "<<scene.to_yaml());
}

// create the default render
Expand Down Expand Up @@ -2005,6 +2005,16 @@ void AscentRuntime::SourceFieldFilter()
dom.remove("fields/"+names[f]);
}
} // for fields

// if all fields were removed - also remove the fields node
// or else blueprint verify will fail
//
// (this can happen when some domains do not have selected fields)
//
if(dom["fields"].number_of_children() == 0)
{
dom.remove_child("fields");
}
}
} // for doms

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,18 @@ BlueprintVerify::execute()
// some MPI tasks may not have data, that is fine
// but blueprint verify will fail, so if the
// input node is empty skip verify
int local_verify_ok = 0;
int local_verify_ok = 0;
int local_verify_err = 0;

std::string verify_err_msg = "";
if(!n_input->dtype().is_empty())
{
if(!conduit::blueprint::verify(protocol,
*n_input,
v_info))
{
n_input->schema().print();
v_info.print();
ASCENT_ERROR("blueprint verify failed for protocol"
<< protocol << std::endl
<< "details:" << std::endl
<< v_info.to_json());
verify_err_msg = v_info.to_yaml();
local_verify_err = 1;
}
else
{
Expand All @@ -158,17 +157,50 @@ BlueprintVerify::execute()

// make sure some MPI task actually had bp data
#ifdef ASCENT_MPI_ENABLED
// reduce flag for some valid data
int global_verify_ok = 0;
MPI_Comm mpi_comm = MPI_Comm_f2c(flow::Workspace::default_mpi_comm());
MPI_Allreduce((void *)(&local_verify_ok),
(void *)(&global_verify_ok),
1,
MPI_INT,
MPI_SUM,
mpi_comm);
(void *)(&global_verify_ok),
1,
MPI_INT,
MPI_SUM,
mpi_comm);
local_verify_ok = global_verify_ok;

// reduce flag for errors
int global_verify_err = 0;
MPI_Allreduce((void *)(&local_verify_err),
(void *)(&global_verify_err),
1,
MPI_INT,
MPI_SUM,
mpi_comm);
local_verify_err = global_verify_err;


#endif

// check for an error on any rank
if(local_verify_err == 1)
{
if(verify_err_msg != "")
{
ASCENT_ERROR("blueprint verify failed for protocol"
<< protocol << std::endl
<< "one one more more ranks." << std::endl
<< "Details:" << std::endl
<< verify_err_msg);
}
else
{
ASCENT_ERROR("blueprint verify failed for protocol"
<< protocol << std::endl
<< "one one more more ranks." << std::endl);
}
}

// check for no data
if(local_verify_ok == 0)
{
ASCENT_ERROR("blueprint verify failed: published data is empty");
Expand Down
14 changes: 13 additions & 1 deletion src/libs/flow/flow_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,23 @@ Data::to_json() const
return oss.str();
}

//-----------------------------------------------------------------------------
std::string
Data::to_yaml() const
{
Node out;
info(out);
ostringstream oss;
out.to_yaml_stream(oss);
return oss.str();
}


//-----------------------------------------------------------------------------
void
Data::print() const
{
CONDUIT_INFO(to_json());
CONDUIT_INFO(to_yaml());
}

//-----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/libs/flow/flow_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class FLOW_API Data

void info(conduit::Node &out) const;
std::string to_json() const;
std::string to_yaml() const;
void print() const;

protected:
Expand Down
14 changes: 13 additions & 1 deletion src/libs/flow/flow_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,23 @@ Filter::to_json() const
return oss.str();
}

//-----------------------------------------------------------------------------
std::string
Filter::to_yaml() const
{
Node out;
info(out);
ostringstream oss;
out.to_yaml_stream(oss);
return oss.str();
}


//-----------------------------------------------------------------------------
void
Filter::print() const
{
CONDUIT_INFO(to_json());
CONDUIT_INFO(to_yaml());
}


Expand Down
4 changes: 3 additions & 1 deletion src/libs/flow/flow_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ class FLOW_API Filter
void info(conduit::Node &out) const;
/// create json string from info
std::string to_json() const;
/// print json version of info
/// create yaml string from info
std::string to_yaml() const;
/// print yaml version of info
void print() const;


Expand Down
8 changes: 4 additions & 4 deletions src/libs/flow/flow_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Graph::add_filter(const std::string &filter_type,
CONDUIT_ERROR("Cannot create filter " << f_name
<< " because verify_params failed." << std::endl
<< "Details:" << std::endl
<< v_info.to_json());
<< v_info.to_yaml());
return NULL;
}

Expand Down Expand Up @@ -357,7 +357,7 @@ Graph::connections(Node &out) const
void
Graph::add_filters(const Node &filters)
{
CONDUIT_INFO(filters.to_json());
// CONDUIT_INFO(filters.to_json());

NodeConstIterator filters_itr = filters.children();

Expand Down Expand Up @@ -424,7 +424,7 @@ Graph::add_filters(const Node &filters)
void
Graph::add_connections(const Node &conns)
{
CONDUIT_INFO(conns.to_json());
// CONDUIT_INFO(conns.to_json());

NodeConstIterator conns_itr = conns.children();
while(conns_itr.has_next())
Expand Down Expand Up @@ -702,7 +702,7 @@ Graph::save_dot_html(const std::string &ofile) const
void
Graph::print() const
{
CONDUIT_INFO(to_json());
CONDUIT_INFO(to_yaml());
}


Expand Down
13 changes: 12 additions & 1 deletion src/libs/flow/flow_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,22 @@ Registry::to_json() const
return oss.str();
}

//-----------------------------------------------------------------------------
std::string
Registry::to_yaml() const
{
Node out;
info(out);
ostringstream oss;
out.to_yaml_stream(oss);
return oss.str();
}

//-----------------------------------------------------------------------------
void
Registry::print() const
{
CONDUIT_INFO(to_json());
CONDUIT_INFO(to_yaml());
}

//-----------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion src/libs/flow/flow_registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ class FLOW_API Registry
void info(conduit::Node &out) const;
/// create json string from info
std::string to_json() const;
/// print json version of info
/// create yaml string from info
std::string to_yaml() const;
/// print yaml version of info
void print() const;


Expand Down
18 changes: 15 additions & 3 deletions src/libs/flow/flow_workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,23 @@ Workspace::to_json() const
return oss.str();
}


//-----------------------------------------------------------------------------
std::string
Workspace::to_yaml() const
{
Node out;
info(out);
ostringstream oss;
out.to_yaml_stream(oss);
return oss.str();
}

//-----------------------------------------------------------------------------
void
Workspace::print() const
{
CONDUIT_INFO(to_json());
CONDUIT_INFO(to_yaml());
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -525,7 +537,7 @@ Workspace::register_filter_type(FilterFactoryMethod fr)
CONDUIT_ERROR("filter type interface verify failed." << std::endl
<< f_type_name << std::endl
<< "Details:" << std::endl
<< v_info.to_json());
<< v_info.to_yaml());
}

f_type_name =i_test["type_name"].as_string();
Expand Down Expand Up @@ -577,7 +589,7 @@ Workspace::register_filter_type(const std::string &filter_type_name,
CONDUIT_ERROR("filter type interface verify failed." << std::endl
<< f_type_name << std::endl
<< "Details:" << std::endl
<< v_info.to_json());
<< v_info.to_yaml());
}

f_type_name =i_test["type_name"].as_string();
Expand Down
4 changes: 3 additions & 1 deletion src/libs/flow/flow_workspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ class FLOW_API Workspace
void info(conduit::Node &out) const;
/// create json string from info
std::string to_json() const;
/// print json version of info
/// create yaml string from info
std::string to_yaml() const;
/// print yaml version of info
void print() const;

/// resets state used to capture timing events
Expand Down
Loading

0 comments on commit 744a36a

Please sign in to comment.