-
Notifications
You must be signed in to change notification settings - Fork 0
fix: Add an error counter to stop workflow if one step failed #231
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
Open
RomainBaville
wants to merge
6
commits into
main
Choose a base branch
from
RomainBaville/fix/FixGeomechanicsWorkflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
26d731c
Add an error counter to stop geomechanics workflow
RomainBaville ee9d219
Refactor SurfaceGeomechanics to stop workflow if an error is logged
RomainBaville b6b796c
Refactor Extract and Merge blocks to stop workflow if an error is logged
RomainBaville 7207a02
Rename CountWarningHandler to CountVerbosityHandler
RomainBaville d5f0de0
Clean CountVerbosityHandler call and doc
RomainBaville f0207e2
clean for the ci
RomainBaville File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,7 +16,7 @@ | |||||
| from geos.mesh.utils.genericHelpers import ( getLocalBasisVectors, convertAttributeFromLocalToXYZForOneCell ) | ||||||
| import geos.geomechanics.processing.geomechanicsCalculatorFunctions as fcts | ||||||
| from geos.utils.pieceEnum import Piece | ||||||
| from geos.utils.Logger import ( getLogger, Logger, CountWarningHandler, isHandlerInLogger, getLoggerHandlerType ) | ||||||
| from geos.utils.Logger import ( getLogger, Logger, CountVerbosityHandler, isHandlerInLogger, getLoggerHandlerType ) | ||||||
| from geos.utils.PhysicalConstants import ( DEFAULT_FRICTION_ANGLE_RAD, DEFAULT_ROCK_COHESION ) | ||||||
| from geos.utils.GeosOutputsConstants import ( ComponentNameEnum, GeosMeshOutputsEnum, PostProcessingOutputsEnum ) | ||||||
|
|
||||||
|
|
@@ -65,7 +65,7 @@ | |||||
| # Do calculations | ||||||
| try: | ||||||
| sg.applyFilter() | ||||||
| except ( ValueError, VTKError, AttributeError, AssertionError ) as e: | ||||||
| except ( ValueError, VTKError, AttributeError, AssertionError, TypeError ) as e: | ||||||
| sg.logger.error( f"The filter { sg.logger.name } failed due to: { e }" ) | ||||||
| except Exception as e: | ||||||
| mess: str = f"The filter { sg.logger.name } failed due to: { e }" | ||||||
|
|
@@ -119,8 +119,8 @@ def __init__( | |||||
| self.logger.setLevel( logging.INFO ) | ||||||
| self.logger.propagate = False | ||||||
|
|
||||||
| counter: CountWarningHandler = CountWarningHandler() | ||||||
| self.counter: CountWarningHandler | ||||||
| counter: CountVerbosityHandler = CountVerbosityHandler() | ||||||
| self.counter: CountVerbosityHandler | ||||||
| self.nbWarnings: int = 0 | ||||||
| try: | ||||||
| self.counter = getLoggerHandlerType( type( counter ), self.logger ) | ||||||
|
|
@@ -131,9 +131,6 @@ def __init__( | |||||
|
|
||||||
| self.logger.addHandler( self.counter ) | ||||||
|
|
||||||
| # Input surfacic mesh | ||||||
| if not surfacicMesh.IsA( "vtkPolyData" ): | ||||||
| self.logger.error( f"Input surface is expected to be a vtkPolyData, not a { type( surfacicMesh ) }." ) | ||||||
| self.inputMesh: vtkPolyData = surfacicMesh | ||||||
| # Identification of the input surface (logging purpose) | ||||||
| self.name: Union[ str, None ] = None | ||||||
|
|
@@ -241,13 +238,18 @@ def applyFilter( self: Self ) -> None: | |||||
| """Compute Geomechanical properties on input surface. | ||||||
|
|
||||||
| Raises: | ||||||
| TypeError: Error With the type of the input mesh. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ValueError: Errors during the creation of an attribute. | ||||||
| VTKError: Error raises during the call of VTK function. | ||||||
| AttributeError: Attributes must be on cell. | ||||||
| AssertionError: Something went wrong during the shearCapacityUtilization computation. | ||||||
| """ | ||||||
| self.logger.info( f"Apply filter { self.logger.name }." ) | ||||||
|
|
||||||
| # Input surfacic mesh | ||||||
| if not self.inputMesh.IsA( "vtkPolyData" ): | ||||||
| raise TypeError( f"Input surface is expected to be a vtkPolyData, not a { type( self.inputMesh ) }." ) | ||||||
|
|
||||||
| self.outputMesh = vtkPolyData() | ||||||
| self.outputMesh.ShallowCopy( self.inputMesh ) | ||||||
|
|
||||||
|
|
@@ -265,6 +267,7 @@ def applyFilter( self: Self ) -> None: | |||||
| else: | ||||||
| self.logger.info( f"{ result }." ) | ||||||
|
|
||||||
| # Keep number of warnings logged during the filter application and reset the warnings count in case the filter is apply again. | ||||||
| self.nbWarnings = self.counter.warningCount | ||||||
| self.counter.resetWarningCount() | ||||||
|
|
||||||
|
|
@@ -352,6 +355,9 @@ def __computeXYZCoordinates( | |||||
|
|
||||||
| Returns: | ||||||
| npt.NDArray[np.float64]: Vector of new coordinates of the attribute. | ||||||
|
|
||||||
| Raises: | ||||||
| ValueError: Error with the shape of attrArray or the computation of the attribute coordinate. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| """ | ||||||
| attrXYZ: npt.NDArray[ np.float64 ] = np.full_like( attrArray, np.nan ) | ||||||
|
|
||||||
|
|
@@ -369,17 +375,12 @@ def __computeXYZCoordinates( | |||||
| attrXYZ[ i ] = convertAttributeFromLocalToXYZForOneCell( cellAttribute, cellLocalBasis ) | ||||||
|
|
||||||
| if not np.any( np.isfinite( attrXYZ ) ): | ||||||
| self.logger.error( "Attribute new coordinate calculation failed." ) | ||||||
| raise ValueError( "Attribute new coordinate calculation failed." ) | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| return attrXYZ | ||||||
|
|
||||||
| def computeShearCapacityUtilization( self: Self ) -> None: | ||||||
| """Compute the shear capacity utilization (SCU) on surface. | ||||||
|
|
||||||
| Raises: | ||||||
| ValueError: Something went wrong during the creation of an attribute. | ||||||
| AssertionError: Something went wrong during the shearCapacityUtilization computation. | ||||||
| """ | ||||||
| """Compute the shear capacity utilization (SCU) on surface.""" | ||||||
| SCUAttributeName: str = PostProcessingOutputsEnum.SCU.attributeName | ||||||
|
|
||||||
| if not isAttributeInObject( self.outputMesh, SCUAttributeName, self.attributePiece ): | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please correct it in all the files :)