Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Group & Wrapper source XML line in errors #2404

Merged
merged 86 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from 84 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
7601706
Adding context to errors when reading wrapper from xml
MelReyCG Mar 23, 2023
622f8d6
added XML hierarchy to the wrapper parsing error
MelReyCG Mar 24, 2023
a5fb1fe
Modified testXmlWrapper so it expect exceptions
MelReyCG Mar 27, 2023
4524704
Changed the regexs so the schema detects more errors
MelReyCG Mar 27, 2023
c36a052
updating LvArray submodule
MelReyCG Mar 27, 2023
081939c
Adding documentation
MelReyCG Mar 28, 2023
a123a15
added C++17 string_view comments
MelReyCG Apr 6, 2023
0b1cd21
- Added the ability to know the line of xml nodes & attributes
MelReyCG Apr 20, 2023
7a7331f
merge branch "feature/rey/error-xml-line-2" with PR branch "bugfix/re…
MelReyCG Apr 20, 2023
d56087e
Merge remote-tracking branch 'origin/bugfix/rey/2320-xml-errors-feedb…
MelReyCG Apr 20, 2023
fb418c8
Indentation, code style, naming
MelReyCG Apr 24, 2023
e995b0c
Renaming SourceContext to DataContext
MelReyCG Apr 24, 2023
7b793c9
comment update in Logger.hpp
jeannepellerin Apr 24, 2023
e1af0c6
- Added xml line to messages from PR 2341 & 2357
MelReyCG Apr 24, 2023
3e95803
Added getWrapperDataContext()
MelReyCG Apr 27, 2023
cbfa507
uncrustify + documentation corrections
MelReyCG Apr 27, 2023
c69a98d
added compatibility with GEOS_FMT
MelReyCG Apr 28, 2023
703d88b
Adapted getGroupByPath test with new error message
MelReyCG May 10, 2023
7a7e053
error message improvements + bugfixes + removed unused header
MelReyCG May 10, 2023
9445618
Group::printDataHierarchy : wrapper type fix + layout
MelReyCG May 10, 2023
f25415e
Merge branch 'develop' into feature/rey/error-xml-line-2
MelReyCG May 11, 2023
8f26f6d
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG May 11, 2023
7d08ddc
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG May 16, 2023
0267860
uncrustify
MelReyCG May 16, 2023
40aae17
code style
MelReyCG May 16, 2023
f5f1276
update LvArray version
MelReyCG May 16, 2023
faa7358
update LvArray version
MelReyCG May 16, 2023
be91af3
improved messages with group/wrapper path
MelReyCG May 16, 2023
5fae7b6
rewrited WrapperContext message
MelReyCG May 16, 2023
585d59d
Documentation
MelReyCG May 17, 2023
d79b0c9
code style / factorization + constness
MelReyCG May 23, 2023
7ab5641
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG May 23, 2023
f7217ee
docs fixes
MelReyCG May 24, 2023
186d212
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG May 25, 2023
b8fb6bf
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Jun 5, 2023
17759eb
code cleaning / refactoring, docs improvements
MelReyCG Jun 20, 2023
4045ce2
removing circular dependency:
MelReyCG Jun 20, 2023
b7b756e
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Jun 20, 2023
041d4a7
Docs fixes & params names
MelReyCG Jun 26, 2023
1a5c02a
Refactorization: removing "isDataFileContext()"
MelReyCG Jun 29, 2023
1508b00
memleak fix
MelReyCG Jul 3, 2023
8db1cc3
Refactorization: removed getWrapperSeparator()
MelReyCG Jul 3, 2023
e416cdf
getTargetNameInPath() docs
MelReyCG Jul 3, 2023
5750d12
removed virtual destructors
MelReyCG Jul 3, 2023
8f35760
Refactorings
MelReyCG Jul 4, 2023
b96630b
Added a test for DataContext string formatting
MelReyCG Jul 4, 2023
f5e823f
improved getAttributeLine() robustness
MelReyCG Jul 5, 2023
729df9f
Refactoring: hide xml_document implementation
MelReyCG Jul 6, 2023
4864a30
xmlDocument refactorings
MelReyCG Jul 7, 2023
d5ab61a
WIP: more wrapping (xmlNode+xmlAttribute)
MelReyCG Jul 7, 2023
d463a93
Revert "WIP: more wrapping (xmlNode+xmlAttribute)"
MelReyCG Jul 7, 2023
c03e81f
Merge commit '08ba8f7e2c04af6ad07ff7d3ddc54f091b8e8564' into feature/…
MelReyCG Jul 10, 2023
dad53ce
wrong method name
MelReyCG Jul 10, 2023
39a0cdc
DataContext architecture refactorization
MelReyCG Jul 12, 2023
ee76f62
GroupContext / WrapperContext fixes
MelReyCG Jul 17, 2023
b627575
Extended test for WrapperContext::toString()
MelReyCG Jul 17, 2023
1a69a92
Merge branch 'develop' into feature/rey/error-xml-line-2
MelReyCG Jul 17, 2023
374223d
docs fixes
MelReyCG Jul 17, 2023
3b188ae
improving testGroupPath with more implicit groups & wrapper
MelReyCG Jul 18, 2023
e1ffd1d
GroupContext::toString() rewrite
MelReyCG Jul 18, 2023
630efc7
compilation bugfix
MelReyCG Jul 19, 2023
8cc3e8f
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Jul 19, 2023
7bdf50f
compilation warning fix
MelReyCG Jul 20, 2023
a7fb525
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Jul 21, 2023
fa4f7f2
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Jul 24, 2023
971ea0f
Merge branch 'develop' into feature/rey/error-xml-line-2
MelReyCG Jul 28, 2023
6eae848
Merge branch 'develop' into feature/rey/error-xml-line-2
TotoGaz Aug 8, 2023
9bcee6a
removed loadBuffer in favor of loadString
MelReyCG Aug 21, 2023
60599e5
missing a pugi::node_declaration wrapping
MelReyCG Aug 21, 2023
290285f
Merge branch 'feature/rey/error-xml-line-2' of https://github.com/GEO…
MelReyCG Aug 21, 2023
ebffe3f
changed to /** doxygen syntax
MelReyCG Aug 21, 2023
9795f54
Refactorings
MelReyCG Aug 22, 2023
5262422
Added a dedicated WrapperContext cpp & hpp file
MelReyCG Aug 22, 2023
83c5116
refactoring
MelReyCG Aug 22, 2023
9640797
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Aug 22, 2023
4501dc4
uncrustify
MelReyCG Aug 23, 2023
44f4fed
Docs fixes
MelReyCG Aug 23, 2023
40879dd
reverse iterator bugfix
MelReyCG Aug 23, 2023
b792974
DataContext format options fix
MelReyCG Aug 25, 2023
212e611
DataContext toString bugfix when no DataFileContext exist
MelReyCG Aug 25, 2023
42f53b5
Added docs for xmlWrapper attribute line search
MelReyCG Aug 25, 2023
0bc5032
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Aug 25, 2023
38d33d7
removed Group::forAllDataContext in profit of a private function in t…
MelReyCG Aug 25, 2023
1bcf5ba
refactoring DataContext::ToStringInfo
MelReyCG Aug 25, 2023
919830b
a few refactorings
MelReyCG Aug 30, 2023
071b10c
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Aug 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/coreComponents/common/DataTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include <unordered_map>
#include <vector>
#include <set>
#include <string_view>

/**
* top level geosx namespace contains all code that is specific to GEOSX
Expand Down Expand Up @@ -129,6 +130,9 @@ using globalIndex = GEOSX_GLOBALINDEX_TYPE;
/// String type.
using string = std::string;

/// String type.
using string_view = std::string_view;

/// 32-bit floating point type.
using real32 = float;
/// 64-bit floating point type.
Expand Down
6 changes: 3 additions & 3 deletions src/coreComponents/common/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@ struct InputError : public std::runtime_error
{}

/**
* @brief Construct an InputError from an underlying exception.
* @param subException An exception to base this new one on.
* @param msgToInsert The error message. It will be inserted into the one inside of subException.
* @brief Constructs an InputError from an underlying exception.
* @param subException The exception on which the created one is based.
* @param msgToInsert The error message that will be inserted in the subException error message.
*/
InputError( std::exception const & subException, std::string const & msgToInsert );
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,16 @@ void testDruckerPragerDriver()
"</Constitutive>";

xmlWrapper::xmlDocument xmlDocument;
xmlWrapper::xmlResult xmlResult = xmlDocument.load_buffer( inputStream.c_str(),
inputStream.size() );
xmlWrapper::xmlResult xmlResult = xmlDocument.loadString( inputStream );
if( !xmlResult )
{
GEOS_LOG_RANK_0( "XML parsed with errors!" );
GEOS_LOG_RANK_0( "Error description: " << xmlResult.description());
GEOS_LOG_RANK_0( "Error offset: " << xmlResult.offset );
}

xmlWrapper::xmlNode xmlConstitutiveNode = xmlDocument.child( "Constitutive" );
constitutiveManager.processInputFileRecursive( xmlConstitutiveNode );
xmlWrapper::xmlNode xmlConstitutiveNode = xmlDocument.getChild( "Constitutive" );
constitutiveManager.processInputFileRecursive( xmlDocument, xmlConstitutiveNode );
constitutiveManager.postProcessInputRecursive();

localIndex constexpr numElem = 2;
Expand Down Expand Up @@ -189,17 +188,16 @@ void testDruckerPragerExtendedDriver()
"</Constitutive>";

xmlWrapper::xmlDocument xmlDocument;
xmlWrapper::xmlResult xmlResult = xmlDocument.load_buffer( inputStream.c_str(),
inputStream.size() );
xmlWrapper::xmlResult xmlResult = xmlDocument.loadString( inputStream );
if( !xmlResult )
{
GEOS_LOG_RANK_0( "XML parsed with errors!" );
GEOS_LOG_RANK_0( "Error description: " << xmlResult.description());
GEOS_LOG_RANK_0( "Error offset: " << xmlResult.offset );
}

xmlWrapper::xmlNode xmlConstitutiveNode = xmlDocument.child( "Constitutive" );
constitutiveManager.processInputFileRecursive( xmlConstitutiveNode );
xmlWrapper::xmlNode xmlConstitutiveNode = xmlDocument.getChild( "Constitutive" );
constitutiveManager.processInputFileRecursive( xmlDocument, xmlConstitutiveNode );
constitutiveManager.postProcessInputRecursive();

localIndex constexpr numElem = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ TEST( ElasticIsotropicTests, testStateUpdatePoint )
"</Constitutive>";

xmlWrapper::xmlDocument xmlDocument;
xmlWrapper::xmlResult xmlResult = xmlDocument.load_buffer( inputStream.c_str(), inputStream.size() );
xmlWrapper::xmlResult xmlResult = xmlDocument.loadString( inputStream );
if( !xmlResult )
{
GEOS_LOG_RANK_0( "XML parsed with errors!" );
GEOS_LOG_RANK_0( "Error description: " << xmlResult.description());
GEOS_LOG_RANK_0( "Error offset: " << xmlResult.offset );
}

xmlWrapper::xmlNode xmlConstitutiveNode = xmlDocument.child( "Constitutive" );
constitutiveManager.processInputFileRecursive( xmlConstitutiveNode );
xmlWrapper::xmlNode xmlConstitutiveNode = xmlDocument.getChild( "Constitutive" );
constitutiveManager.processInputFileRecursive( xmlDocument, xmlConstitutiveNode );
constitutiveManager.postProcessInputRecursive();

dataRepository::Group disc( "discretization", &rootGroup );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,16 @@ void testModifiedCamClayDriver()
"</Constitutive>";

xmlWrapper::xmlDocument xmlDocument;
xmlWrapper::xmlResult xmlResult = xmlDocument.load_buffer( inputStream.c_str(),
inputStream.size() );
xmlWrapper::xmlResult xmlResult = xmlDocument.loadString( inputStream );
if( !xmlResult )
{
GEOS_LOG_RANK_0( "XML parsed with errors!" );
GEOS_LOG_RANK_0( "Error description: " << xmlResult.description());
GEOS_LOG_RANK_0( "Error offset: " << xmlResult.offset );
}

xmlWrapper::xmlNode xmlConstitutiveNode = xmlDocument.child( "Constitutive" );
constitutiveManager.processInputFileRecursive( xmlConstitutiveNode );
xmlWrapper::xmlNode xmlConstitutiveNode = xmlDocument.getChild( "Constitutive" );
constitutiveManager.processInputFileRecursive( xmlDocument, xmlConstitutiveNode );
constitutiveManager.postProcessInputRecursive();

localIndex constexpr numElem = 2;
Expand Down
14 changes: 10 additions & 4 deletions src/coreComponents/dataRepository/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ set( dataRepository_headers
WrapperBase.hpp
wrapperHelpers.hpp
xmlWrapper.hpp
)
DataContext.hpp
GroupContext.hpp
WrapperContext.hpp
)

#
# Specify all sources
Expand All @@ -35,7 +38,10 @@ set( dataRepository_sources
Utilities.cpp
WrapperBase.cpp
xmlWrapper.cpp
)
DataContext.cpp
GroupContext.cpp
WrapperContext.cpp
)

set( dependencyList ${parallelDeps} codingUtilities pugixml )

Expand All @@ -56,11 +62,11 @@ blt_add_library( NAME dataRepository
HEADERS ${dataRepository_headers}
DEPENDS_ON ${dependencyList}
OBJECT ${GEOSX_BUILD_OBJ_LIBS}
)
)

target_include_directories( dataRepository PUBLIC ${CMAKE_SOURCE_DIR}/coreComponents )

geosx_add_code_checks(PREFIX dataRepository )
geosx_add_code_checks( PREFIX dataRepository )


if( GEOS_ENABLE_TESTS )
Expand Down
107 changes: 107 additions & 0 deletions src/coreComponents/dataRepository/DataContext.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* ------------------------------------------------------------------------------------------------------------
* SPDX-License-Identifier: LGPL-2.1-only
*
* Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2018-2020 TotalEnergies
* Copyright (c) 2019- GEOSX Contributors
* All rights reserved
*
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
* ------------------------------------------------------------------------------------------------------------
*/

/**
* @file DataContext.cpp
*/

#include "DataContext.hpp"

namespace geos
{
namespace dataRepository
{


DataContext::DataContext( string const & targetName ):
m_targetName( targetName )
{}

std::ostream & operator<<( std::ostream & os, DataContext const & ctx )
{
os << ctx.toString();
return os;
}

DataContext::ToStringInfo::ToStringInfo( string const & targetName, string const & filePath, size_t line ):
m_targetName( targetName ),
m_filePath( filePath ),
m_line( line )
{}
DataContext::ToStringInfo::ToStringInfo( string const & targetName ):
m_targetName( targetName )
{}


/**
* @return the node 'name' attribute if it exists, return the node tag name otherwise.
* @param node the target node.
*/
string getNodeName( xmlWrapper::xmlNode const & node )
{
xmlWrapper::xmlAttribute const nameAtt = node.attribute( "name" );
if( !nameAtt.empty() )
{
return string( node.attribute( "name" ).value() );
}
else
{
return string( node.name() );
}
}

DataFileContext::DataFileContext( xmlWrapper::xmlNode const & targetNode,
xmlWrapper::xmlNodePos const & nodePos ):
DataContext( getNodeName( targetNode ) ),
m_typeName( targetNode.name() ),
m_filePath( nodePos.filePath ),
m_line( nodePos.line ),
m_offsetInLine( nodePos.offsetInLine ),
m_offset( nodePos.offset )
{}

DataFileContext::DataFileContext( xmlWrapper::xmlNode const & targetNode,
xmlWrapper::xmlAttribute const & att,
xmlWrapper::xmlAttributePos const & attPos ):
DataContext( getNodeName( targetNode ) + '/' + att.name() ),
m_typeName( att.name() ),
m_filePath( attPos.filePath ),
m_line( attPos.line ),
m_offsetInLine( attPos.offsetInLine ),
m_offset( attPos.offset )
{}

string DataFileContext::toString() const
{
if( m_line != xmlWrapper::xmlDocument::npos )
{
return GEOS_FMT( "{} ({}, l.{})", m_targetName, splitPath( m_filePath ).second, m_line );
}
else if( m_offset != xmlWrapper::xmlDocument::npos )
{
return GEOS_FMT( "{} ({}, offset {})", m_targetName, splitPath( m_filePath ).second, m_offset );
}
else
{
return GEOS_FMT( "{} (Source file not found)", m_targetName );
}
}

DataContext::ToStringInfo DataFileContext::getToStringInfo() const
{ return ToStringInfo( m_targetName, m_filePath, m_line ); }



} /* namespace dataRepository */
} /* namespace geos */
Loading