Janitor : Move disable exception print before any HDF5 operations

Some regression tests cause exceptions to trigger based on the HDF5 data present in test dataset. This causes the regression test to hang.
This commit is contained in:
Magne Sjaastad 2021-11-05 10:59:15 +01:00
parent 12d0e9b89d
commit b2433bf185
2 changed files with 55 additions and 26 deletions

View File

@ -119,6 +119,8 @@ std::vector<QDateTime> RifHdf5Reader::timeSteps() const
try
{
H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately
H5::H5File mainFile( m_fileName.toStdString().c_str(),
H5F_ACC_RDONLY ); // initial date part is an attribute of SourSimRL main file
@ -182,6 +184,8 @@ QStringList RifHdf5Reader::propertyNames() const
try
{
H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately
H5::H5File file( fileName.c_str(), H5F_ACC_RDONLY );
std::vector<std::string> resultNames = getResultNames( file, groupName );
@ -286,6 +290,8 @@ int RifHdf5Reader::getIntAttribute( H5::H5File file, std::string groupName, std:
{
try
{
H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately
H5::Group group = file.openGroup( groupName.c_str() );
H5::Attribute attr = group.openAttribute( attributeName.c_str() );
@ -310,6 +316,8 @@ double RifHdf5Reader::getDoubleAttribute( H5::H5File file, std::string groupName
{
try
{
H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately
H5::Group group = file.openGroup( groupName.c_str() );
H5::Attribute attr = group.openAttribute( attributeName.c_str() );
@ -334,6 +342,8 @@ std::string RifHdf5Reader::getStringAttribute( H5::H5File file, std::string grou
{
try
{
H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately
H5::Group group = file.openGroup( groupName.c_str() );
H5::Attribute attr = group.openAttribute( attributeName.c_str() );
@ -385,6 +395,10 @@ std::vector<std::string> RifHdf5Reader::getResultNames( H5::H5File file, std::st
//--------------------------------------------------------------------------------------------------
void RifHdf5Reader::getElementResultValues( H5::H5File file, std::string groupName, std::vector<double>* resultValues ) const
{
try
{
H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately
H5::Group group = file.openGroup( groupName.c_str() );
H5::DataSet dataset = H5::DataSet( group.openDataSet( "values" ) );
@ -394,6 +408,10 @@ void RifHdf5Reader::getElementResultValues( H5::H5File file, std::string groupNa
( *resultValues ).resize( dims[0] );
dataset.read( resultValues->data(), H5::PredType::NATIVE_DOUBLE );
}
catch ( ... )
{
}
}
//--------------------------------------------------------------------------------------------------
@ -403,6 +421,10 @@ std::vector<std::string> RifHdf5ReaderTools::getSubGroupNames( H5::H5File* file,
{
if ( file )
{
try
{
H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately
H5::Group baseGroup = file->openGroup( baseGroupName.c_str() );
std::vector<std::string> subGroupNames;
@ -422,6 +444,10 @@ std::vector<std::string> RifHdf5ReaderTools::getSubGroupNames( H5::H5File* file,
return subGroupNames;
}
catch ( ... )
{
}
}
return {};
}

View File

@ -49,6 +49,8 @@ std::vector<std::string> RifHdf5SummaryReader::vectorNames()
{
try
{
H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately
auto h5File = H5::H5File( m_fileName.c_str(), H5F_ACC_RDONLY );
std::vector<std::string> names;
@ -76,6 +78,8 @@ std::vector<time_t> RifHdf5SummaryReader::timeSteps() const
{
try
{
H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately
auto h5File = H5::H5File( m_fileName.c_str(), H5F_ACC_RDONLY );
std::vector<time_t> times;
@ -124,11 +128,11 @@ std::vector<double> RifHdf5SummaryReader::values( const std::string& vectorName,
{
try
{
auto h5File = H5::H5File( m_fileName.c_str(), H5F_ACC_RDONLY );
H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately
std::string idText = std::to_string( smspecKeywordIndex );
auto h5File = H5::H5File( m_fileName.c_str(), H5F_ACC_RDONLY );
std::string idText = std::to_string( smspecKeywordIndex );
std::string groupPath = "summary_vectors/" + vectorName + "/" + idText;
{
@ -160,10 +164,9 @@ std::vector<double> RifHdf5SummaryReader::values( const std::string& vectorName
{
try
{
auto h5File = H5::H5File( m_fileName.c_str(), H5F_ACC_RDONLY );
H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately
auto h5File = H5::H5File( m_fileName.c_str(), H5F_ACC_RDONLY );
std::string groupPath = "summary_vectors/" + vectorName;
auto groupNames = RifHdf5ReaderTools::getSubGroupNames( &h5File, groupPath );
@ -199,10 +202,10 @@ time_t RifHdf5SummaryReader::startDate() const
{
try
{
auto h5File = H5::H5File( m_fileName.c_str(), H5F_ACC_RDONLY );
H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately
auto h5File = H5::H5File( m_fileName.c_str(), H5F_ACC_RDONLY );
QString groupPath = QString( "general" );
H5::Group GridFunction_00002 = h5File.openGroup( groupPath.toStdString().c_str() );