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

Log refactor - Table logging features #2984

Merged
merged 113 commits into from
Jun 4, 2024
Merged

Conversation

arng40
Copy link
Contributor

@arng40 arng40 commented Feb 9, 2024

This PR is the first one of a work in collaboration with @MelReyCG that aim to standardize logs and make them more readable.
Today's logs are complicated to read:

  • Data is output in different formats
  • Alignments are random

This PR aim to help to format the logs in a clearer way by providing table drawing :

  • Separation of : the collect, the format and dump.
  • Compile time verification of value added
  • Dynamic table and column size
  • Optional title
  • Optional columns
  • Custom column lignment
  • Margin between columns sides

This feature will be used in a first time for the well data output. According to the well control log level, the column of previous and next element can be displayed.

An example of the refactored Well Log:

Dumping 5 Elements into Log and CSV

1. Data collection

TableData tableData;
loop (over data)
{
tableData.addRow(val1,val42val3,val4,val5);
}

2. Format the data

TableLayout tableLayout( {"Element no.",  "CordX", "CoordY", " CoordZ",  "Prev\nelement", "Next\nelement"} );         

3. Dumping the data

  • Using TableTextFormatter
TableTextFormatter tableText(tableLayout);
  • or dumping to a csv file
std::ofstream os( joinPath( OutputBase::getOutputDirectory(), filename + ".csv" ) );
TableCSVFormatter csvFormat( tableLayout );
os << csvFormat.headerToString();
os << csvFormat.dataToString( tableData );

Log Output

An example of current well log, 3 elements displayed

++++++++++++++++++++++++++
InternalWellGenerator = well_injector1
MPI rank = 0

Number of well elements = 30
Well element #0
Coordinates of the element center: { 9.5, 0.2, 11.9583 }
No next well element
Previous well element #1
First well node: #0
Second well node: #1
Well element #1
Coordinates of the element center: { 9.5, 0.2, 11.875 }
Next well element # = 0
Previous well element #2
First well node: #1
Second well node: #2
Well element #2
Coordinates of the element center: { 9.5, 0.2, 11.7917 }
[...]

With the new log

--------------------------------------------------------------------------------------
|                        Well 'well_injector1' Element Table                         |
--------------------------------------------------------------------------------------
|  Element no.  |  CoordX  |  CoordY  |              CoordZ  |     Prev  |     Next  |
|               |          |          |                      |  Element  |  Element  |
--------------------------------------------------------------------------------------
|            0  |     9.5  |     0.2  |  11.958333333333334  |        1  |           |
|            1  |     9.5  |     0.2  |              11.875  |        2  |        0  |
|            2  |     9.5  |     0.2  |  11.791666666666666  |        3  |        1  |
|            3  |     9.5  |     0.2  |  11.708333333333334  |        4  |        2  |
|            4  |     9.5  |     0.2  |              11.625  |        5  |        3  |
--------------------------------------------------------------------------------------

@arng40 arng40 requested a review from MelReyCG February 9, 2024 15:46
@arng40 arng40 self-assigned this Feb 9, 2024
Copy link
Contributor

@MelReyCG MelReyCG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First wave

src/coreComponents/codingUtilities/StringUtilities.hpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.cpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.cpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.cpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.cpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.cpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.cpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.cpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.cpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@MelReyCG MelReyCG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

second wave

src/coreComponents/codingUtilities/tests/testTable.cpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.cpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.hpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.hpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.hpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.hpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.hpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.hpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.cpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.hpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.hpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.hpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.hpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.hpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.hpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/Table.hpp Outdated Show resolved Hide resolved
Copy link

codecov bot commented Feb 23, 2024

Codecov Report

Attention: Patch coverage is 83.46883% with 61 lines in your changes missing coverage. Please review.

Project coverage is 53.70%. Comparing base (79856a0) to head (5b46e14).

Files Patch % Lines
...reComponents/mesh/generators/WellGeneratorBase.cpp 4.00% 24 Missing ⚠️
src/coreComponents/fileIO/Table/TableFormatter.cpp 86.70% 23 Missing ⚠️
src/coreComponents/common/DataTypes.hpp 0.00% 4 Missing ⚠️
src/coreComponents/fileIO/Table/TableData.cpp 87.09% 4 Missing ⚠️
...oreComponents/fileIO/Table/unitTests/testTable.cpp 96.73% 3 Missing ⚠️
src/coreComponents/fileIO/Table/TableLayout.cpp 92.00% 2 Missing ⚠️
src/coreComponents/fileIO/Table/TableFormatter.hpp 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2984      +/-   ##
===========================================
+ Coverage    53.56%   53.70%   +0.14%     
===========================================
  Files         1003     1010       +7     
  Lines        85295    85637     +342     
===========================================
+ Hits         45685    45992     +307     
- Misses       39610    39645      +35     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arng40 arng40 added the ci: run CUDA builds Allows to triggers (costly) CUDA jobs label May 23, 2024
@arng40 arng40 requested review from TotoGaz and MelReyCG May 24, 2024 07:41
Copy link
Contributor

@MelReyCG MelReyCG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New batch! I hope it will be the last one.

src/coreComponents/fileIO/Table/TableFormatter.cpp Outdated Show resolved Hide resolved
src/coreComponents/fileIO/Table/TableFormatter.cpp Outdated Show resolved Hide resolved
src/coreComponents/fileIO/Table/TableFormatter.cpp Outdated Show resolved Hide resolved
src/coreComponents/fileIO/Table/TableFormatter.cpp Outdated Show resolved Hide resolved
src/coreComponents/codingUtilities/TableFormatter.hpp Outdated Show resolved Hide resolved
Copy link
Contributor

@MelReyCG MelReyCG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good to me!

Copy link
Contributor

@MelReyCG MelReyCG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good to me!

@arng40 arng40 requested a review from ryar9534 May 31, 2024 14:06
{
m_errorsMsg.push_back( splitErrors );
}
m_errorsMsg.push_back( msg );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe inline it now? (Or even remove it: it seems to be used once for a push_back...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function deleted

Comment on lines 124 to 126
static constexpr char m_sideCross = '+';
/// symbol to delimit a table column
static constexpr string_view innerCross = "+";
static constexpr char m_innerCross = '+';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are m_sideCross and m_innerCross used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They aren't used anymore, they are just for customisation purpose
if we want to have a table with this style +-----+, we can use them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there is no longer code that use these contants, you must remove it. If someone will need to change the style of the tables, he will re-write them.
Keeping them would be confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, it's removed

@paveltomin paveltomin merged commit ce4e169 into develop Jun 4, 2024
26 checks passed
@paveltomin paveltomin deleted the feature/dudes/table-layout branch June 4, 2024 17:57
@paveltomin paveltomin added the flag: no rebaseline Does not require rebaseline label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI flag: no rebaseline Does not require rebaseline type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add PVT data tables in the log (density, saturation...), Add a data table logging feature,
6 participants