Skip to content

Commit

Permalink
Merge pull request #87 from LLNL/feature/nselliott/list-warn
Browse files Browse the repository at this point in the history
Change error to warning when trying to import conduit lists into Sidre
  • Loading branch information
nselliott committed Sep 3, 2019
2 parents 2936fb7 + 81c5c4b commit acbc882
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
19 changes: 13 additions & 6 deletions src/axom/sidre/core/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2046,8 +2046,9 @@ void Group::importFrom(conduit::Node& node,
*************************************************************************
*/

void Group::importConduitTree(const conduit::Node &node, bool preserve_contents)
bool Group::importConduitTree(const conduit::Node &node, bool preserve_contents)
{
bool success = true;
if (!preserve_contents)
{
destroyGroups();
Expand All @@ -2069,7 +2070,7 @@ void Group::importConduitTree(const conduit::Node &node, bool preserve_contents)
{
// create group
Group* grp = createGroup(cld_name);
grp->importConduitTree(cld_node, preserve_contents);
success = grp->importConduitTree(cld_node, preserve_contents);
}
else if(cld_dtype.is_empty())
{
Expand Down Expand Up @@ -2125,8 +2126,9 @@ void Group::importConduitTree(const conduit::Node &node, bool preserve_contents)
}
else if (cld_dtype.is_list())
{
SLIC_ERROR( "Group " << getPathName() <<
SLIC_WARNING( "Group " << getPathName() <<
" cannot import Conduit list " << cld_name);
success = false;
}
else
{
Expand All @@ -2143,10 +2145,13 @@ void Group::importConduitTree(const conduit::Node &node, bool preserve_contents)
SLIC_ERROR( "Group " << getPathName() <<
" cannot import non-object Conduit Node");
}

return success;
}

void Group::importConduitTreeExternal(conduit::Node &node, bool preserve_contents)
bool Group::importConduitTreeExternal(conduit::Node &node, bool preserve_contents)
{
bool success = true;
if (!preserve_contents)
{
destroyGroups();
Expand All @@ -2168,7 +2173,7 @@ void Group::importConduitTreeExternal(conduit::Node &node, bool preserve_content
{
// create group
Group* grp = createGroup(cld_name);
grp->importConduitTreeExternal(cld_node, preserve_contents);
success = grp->importConduitTreeExternal(cld_node, preserve_contents);
}
else if(cld_dtype.is_empty())
{
Expand Down Expand Up @@ -2201,8 +2206,9 @@ void Group::importConduitTreeExternal(conduit::Node &node, bool preserve_content
}
else if (cld_dtype.is_list())
{
SLIC_ERROR( "Group " << getPathName() <<
SLIC_WARNING( "Group " << getPathName() <<
" cannot import Conduit list " << cld_name);
success = false;
}
else
{
Expand All @@ -2220,6 +2226,7 @@ void Group::importConduitTreeExternal(conduit::Node &node, bool preserve_content
" cannot import non-object Conduit Node");
}

return success;
}

/*
Expand Down
22 changes: 16 additions & 6 deletions src/axom/sidre/core/Group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,9 @@ class Group
* same tree structure.
*
* This does not support conduit's list datatype. If the Node contains a
* list any where in its tree, an error will occur.
* list any where in its tree, the list and any child Nodes descending from
* the list will not be imported. A warning will occur and an unsuccessful
* return value will be returned.
*
* If preserve_contents is true, then the names of the children held by the
* Node cannot be the same as the names of the children already held by this
Expand All @@ -1271,9 +1273,12 @@ class Group
* \param preserve_contents If true, any child Groups and Views held by
* this Group remain in place. If false, all
* child Groups and Views are destroyed before
* importing data from the Node.
* importing data from the Node.
*
* \return true for success, false if the full conduit
* tree is not succesfully imported.
*/
void importConduitTree(const conduit::Node& node,
bool importConduitTree(const conduit::Node& node,
bool preserve_contents = false);

/*!
Expand All @@ -1287,7 +1292,9 @@ class Group
* same tree structure.
*
* This does not support conduit's list datatype. If the Node contains a
* list any where in its tree, an error will occur.
* list any where in its tree, the list and any child Nodes descending from
* the list will not be imported. A warning will occur and an unsuccessful
* return value will be returned.
*
* If preserve_contents is true, then the names of the children held by the
* Node cannot be the same as the names of the children already held by this
Expand All @@ -1297,9 +1304,12 @@ class Group
* \param preserve_contents If true, any child Groups and Views held by
* this Group remain in place. If false, all
* child Groups and Views are destroyed before
* importing data from the Node.
* importing data from the Node.
*
* \return true for success, false if the full conduit
* tree is not succesfully imported.
*/
void importConduitTreeExternal(conduit::Node& node,
bool importConduitTreeExternal(conduit::Node& node,
bool preserve_contents = false);

private:
Expand Down
6 changes: 3 additions & 3 deletions src/axom/sidre/tests/sidre_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2076,7 +2076,7 @@ TEST(sidre_group,import_conduit)

DataStore ds;

ds.getRoot()->importConduitTree(input);
EXPECT_TRUE(ds.getRoot()->importConduitTree(input));

Group* flds = ds.getRoot()->getGroup("fields");

Expand Down Expand Up @@ -2120,7 +2120,7 @@ TEST(sidre_group,import_conduit_external)
DataStore ds;

//Zero copy of array data
ds.getRoot()->importConduitTreeExternal(input);
EXPECT_TRUE(ds.getRoot()->importConduitTreeExternal(input));

Group* flds = ds.getRoot()->getGroup("fields");

Expand Down Expand Up @@ -2150,7 +2150,7 @@ TEST(sidre_group,import_conduit_external)
EXPECT_EQ(iarray[j],sidre_data_ptr[j]);
}

//Change a value in the original conduit array, test that it's changed
//Change a value in the original conduit array, then test that it's changed
//in the Sidre external view.
if (ndata > 3)
{
Expand Down

0 comments on commit acbc882

Please sign in to comment.