-
Notifications
You must be signed in to change notification settings - Fork 0
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
Allow restart check to wait for files to write #12
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c425c1d
Fixing logger bug during rebaseline step
cssherman 0ce7b1b
Allowing restartcheck to wait for missing hdf5 files
cssherman 8c4cd4b
Applying the formatter, adding debug entry script
cssherman 9e0e5fb
Adding debugging information to geos_ats docs
cssherman 64ce2a9
Adding a check for lfs pointer objects
cssherman adadf82
Updating error message, GEOS name
cssherman 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 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 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 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""" | ||
Entry point for debugging geos_ats | ||
|
||
To use this script, do the following: | ||
- Setup your ats environment (using the 'make ats_environment' command) | ||
- Create a copy of this script in the build/integratedTests directory | ||
- Debug this script with a tool like vscode | ||
|
||
Note: if you have a copy of the geosPythonPackages repository located | ||
in your user workspace, then this script will attempt to use that version | ||
of geos_ats instead of the one installed in your environment. | ||
""" | ||
|
||
import os | ||
import sys | ||
|
||
|
||
def debug_geos_ats(): | ||
# Check for a copy of geos_ats in the user's workspace to use | ||
# instead of any currently installed in python | ||
user = os.environ.get( 'USER', '' ) | ||
mod_path = f"/usr/workspace/{user}/geosPythonPackages/geos_ats_package" | ||
if os.path.isdir( mod_path ): | ||
sys.path.insert( 0, os.path.join( mod_path ) ) | ||
|
||
# Collect command line args from autogenerated script | ||
fname = os.path.join( os.path.dirname( __file__ ), 'geos_ats.sh' ) | ||
args = open( fname, 'r' ).readlines()[ 1 ].split()[ 1:-1 ] | ||
sys.argv.extend( args ) | ||
|
||
# Run ats | ||
from geos_ats import main | ||
main.main() | ||
|
||
|
||
if __name__ == '__main__': | ||
debug_geos_ats() |
This file was deleted.
Oops, something went wrong.
This file contains 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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,6 +6,7 @@ | |||||||||||
import re | ||||||||||||
import argparse | ||||||||||||
import logging | ||||||||||||
import time | ||||||||||||
from pathlib import Path | ||||||||||||
try: | ||||||||||||
from geos_ats.helpers.permute_array import permuteArray # type: ignore[import] | ||||||||||||
|
@@ -31,6 +32,36 @@ def write( output, msg ): | |||||||||||
output.write( msg ) | ||||||||||||
|
||||||||||||
|
||||||||||||
def is_lfs_pointer( fname ): | ||||||||||||
res = False | ||||||||||||
try: | ||||||||||||
header = str( open( fname, 'rb' ).read( 16 ) ) | ||||||||||||
if 'Git LFS pointer' in header: | ||||||||||||
res = True | ||||||||||||
except Exception: | ||||||||||||
pass | ||||||||||||
|
||||||||||||
return res | ||||||||||||
|
||||||||||||
|
||||||||||||
def load_hdf5( fname, max_wait_time=10, mode='r' ): | ||||||||||||
file = None | ||||||||||||
for ii in range( max_wait_time ): | ||||||||||||
if os.path.isfile( fname ): | ||||||||||||
try: | ||||||||||||
file = h5py.File( fname, mode ) | ||||||||||||
logger.debug( f'Opened file: {fname}' ) | ||||||||||||
break | ||||||||||||
except IOError: | ||||||||||||
logger.warning( f'Failed to open file: {fname} (attempt {ii+1}/{max_wait_time})' ) | ||||||||||||
if is_lfs_pointer( fname ): | ||||||||||||
raise Exception( f'Target LFS object is not initialized: {fname}' ) | ||||||||||||
|
||||||||||||
time.sleep( 1 ) | ||||||||||||
|
||||||||||||
return file | ||||||||||||
|
||||||||||||
|
||||||||||||
def h5PathJoin( p1, p2 ): | ||||||||||||
if p1 == "/": | ||||||||||||
return "/" + p2 | ||||||||||||
|
@@ -79,17 +110,20 @@ def __init__( self, | |||||||||||
assert ( self.atol >= 0.0 ) | ||||||||||||
|
||||||||||||
def filesDiffer( self ): | ||||||||||||
try: | ||||||||||||
with h5py.File( self.file_path, "r" ) as file, h5py.File( self.baseline_path, "r" ) as base_file: | ||||||||||||
self.file_path = file.filename | ||||||||||||
self.baseline_path = base_file.filename | ||||||||||||
self.output.write( "\nRank %s is comparing %s with %s \n" % | ||||||||||||
( MPI.COMM_WORLD.Get_rank(), self.file_path, self.baseline_path ) ) | ||||||||||||
self.compareGroups( file, base_file ) | ||||||||||||
|
||||||||||||
except IOError as e: | ||||||||||||
self.logger.debug( e ) | ||||||||||||
self.output.write( str( e ) ) | ||||||||||||
# Check to see if the file is on the disk, and wait in case there is any lag in IO | ||||||||||||
file = load_hdf5( self.file_path ) | ||||||||||||
base_file = load_hdf5( self.baseline_path ) | ||||||||||||
rank = MPI.COMM_WORLD.Get_rank() | ||||||||||||
self.output.write( f"\nRank {rank} is comparing {self.file_path} with {self.baseline_path} \n" ) | ||||||||||||
|
||||||||||||
# Compare the files | ||||||||||||
if ( file is not None ) and ( base_file is not None ): | ||||||||||||
self.file_path = file.filename | ||||||||||||
self.baseline_path = base_file.filename | ||||||||||||
self.compareGroups( file, base_file ) | ||||||||||||
|
||||||||||||
else: | ||||||||||||
self.output.write( f"\nRank {rank} Failed to load target and/or baseline files \n" ) | ||||||||||||
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. maybe it is useful to know which of the two failed.
Suggested change
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. And I wonder if we should add the path info. |
||||||||||||
self.different = True | ||||||||||||
|
||||||||||||
return self.different | ||||||||||||
|
This file contains 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.