Skip to content

Commit

Permalink
Out of Place GEOS ATS (#6)
Browse files Browse the repository at this point in the history
* Removing unused code, fixing reports

* Using dataclass in geos_ats.reporting

* Updating the reporting dataclass for geos_ats

* Adding an error for tests without restart or curve checks

* Fixing curve check paths

* Adding duplicate test check
  • Loading branch information
cssherman authored Feb 13, 2024
1 parent 653b6cf commit d543c04
Show file tree
Hide file tree
Showing 12 changed files with 374 additions and 1,805 deletions.
36 changes: 14 additions & 22 deletions geos_ats_package/geos_ats/command_line_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ def build_command_line_parser():

parser.add_argument( "geos_bin_dir", type=str, help="GEOS binary directory." )

parser.add_argument( "-w", "--workingDir", type=str, help="Initial working directory" )
parser.add_argument( "ats_target", type=str, help="ats file" )

parser.add_argument( "-w", "--workingDir", type=str, help="Root working directory" )

parser.add_argument( "-b", "--baselineDir", type=str, help="Root baseline directory" )

action_names = ','.join( action_options.keys() )
parser.add_argument( "-a", "--action", type=str, default="run", help=f"Test actions options ({action_names})" )
Expand Down Expand Up @@ -89,6 +93,8 @@ def build_command_line_parser():

parser.add_argument( "-l", "--logs", type=str, default=None )

parser.add_argument( "-f", "--allow-failed-tests", default=False, action='store_true' )

parser.add_argument(
"--failIfTestsFail",
action="store_true",
Expand All @@ -98,8 +104,6 @@ def build_command_line_parser():

parser.add_argument( "-n", "-N", "--numNodes", type=int, default="2" )

parser.add_argument( "ats_targets", type=str, nargs='*', help="ats files or directories." )

return parser


Expand Down Expand Up @@ -127,6 +131,13 @@ def parse_command_line_arguments( args ):
print( f"Selected verbose option ({verbose}) not recognized" )
exit_flag = True

# Paths
if not options.workingDir:
options.workingDir = os.path.basename( options.ats_target )

if not options.baselineDir:
options.baselineDir = options.workingDir

# Print detailed information
if options.detail:
for option_type, details in zip( [ 'action', 'check' ], [ action_options, check_options ] ):
Expand All @@ -139,22 +150,3 @@ def parse_command_line_arguments( args ):
quit()

return options


def patch_parser( parser ):

def add_option_patch( *xargs, **kwargs ):
"""
Convert type string to actual type instance
"""
tmp = kwargs.get( 'type', str )
type_map = { 'string': str }
if isinstance( tmp, str ):
if tmp in type_map:
tmp = type_map[ tmp ]
else:
tmp = locate( tmp )
kwargs[ 'type' ] = tmp
parser.add_argument( *xargs, **kwargs )

parser.add_option = add_option_patch
11 changes: 1 addition & 10 deletions geos_ats_package/geos_ats/configuration_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def initializeConfig( configFile, configOverride, options ):
geos_atsdir = os.path.realpath( os.path.dirname( __file__ ) )

# configfile
config.add( "testbaseline_dir", str, "", "Base directory that contains all the baselines" )
config.add( "testbaseline_directory", str, "", "Base directory that contains all the baselines" )

config.add( "geos_bin_dir", str, "", "Directory that contains 'geos' and related executables." )

Expand All @@ -194,11 +194,6 @@ def initializeConfig( configFile, configOverride, options ):
config.add( "report_doc_remake", bool, False,
"Remake test documentation, even if it already exists (used with html reports)" )

config.add( "report_text", bool, True, "True if you want text results to be generated with the report action" )
config.add( "report_text_file", str, "test_results.txt", "Location to write the text report" )
config.add( "report_text_echo", bool, True, "If True, echo the report to stdout" )
config.add( "report_wait", bool, False, "Wait until all tests are complete before reporting" )

config.add( "report_ini", bool, True, "True if you want ini results to be generated with the report action" )
config.add( "report_ini_file", str, "test_results.ini", "Location to write the ini report" )

Expand All @@ -213,10 +208,6 @@ def initializeConfig( configFile, configOverride, options ):
config.add( "checkmessages_never_ignore_regexp", type( [] ), [ "not yet implemented" ],
"Regular expression to not ignore in all checkmessages steps." )

config.add( "report_timing", bool, False, "True if you want timing file to be generated with the report action" )
config.add( "report_timing_overwrite", bool, False,
"True if you want timing file to overwrite existing timing file rather than augment it" )

# timing and priority
config.add( "priority", str, "equal", "Method of prioritization of tests: [\"equal\", \"processors\",\"timing\"]" )
config.add( "timing_file", str, "timing.txt", "Location of timing file" )
Expand Down
21 changes: 15 additions & 6 deletions geos_ats_package/geos_ats/environment_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@
import argparse


def setup_ats( src_path, build_path, ats_xargs, ats_machine, ats_machine_dir ):
def setup_ats( src_path, build_path, baseline_dir, working_dir, ats_xargs, ats_machine, ats_machine_dir ):
bin_dir = os.path.join( build_path, "bin" )
geos_ats_fname = os.path.join( bin_dir, "run_geos_ats" )
ats_dir = os.path.abspath( os.path.join( src_path, "integratedTests", "tests", "allTests" ) )
test_path = os.path.join( build_path, "integratedTests" )
link_path = os.path.join( test_path, "integratedTests" )
run_script_fname = os.path.join( test_path, "geos_ats.sh" )
log_dir = os.path.join( test_path, "TestResults" )
baseline_dir = os.path.abspath( baseline_dir )
working_dir = os.path.abspath( working_dir )
ats_main_file = os.path.abspath( os.path.join( src_path, 'inputFiles', 'main.ats' ) )

# Create a symbolic link to test directory
# Create a symbolic link to working directory
for d in [ baseline_dir, working_dir, test_path ]:
os.makedirs( d, exist_ok=True )
if os.path.islink( link_path ):
print( 'integratedTests symlink already exists' )
else:
os.symlink( ats_dir, link_path )
os.symlink( working_dir, link_path )

# Build extra arguments that should be passed to ATS
joined_args = [ ' '.join( x ) for x in ats_xargs ]
Expand All @@ -30,7 +34,9 @@ def setup_ats( src_path, build_path, ats_xargs, ats_machine, ats_machine_dir ):
# Write the bash script to run ats.
with open( run_script_fname, "w" ) as g:
g.write( "#!/bin/bash\n" )
g.write( f"{geos_ats_fname} {bin_dir} --workingDir {ats_dir} --logs {log_dir} {ats_args} \"$@\"\n" )
g.write(
f"{geos_ats_fname} {bin_dir} {ats_main_file} --workingDir {working_dir} --baselineDir {baseline_dir} --logs {log_dir} {ats_args} \"$@\"\n"
)

# Make the script executable
st = os.stat( run_script_fname )
Expand All @@ -46,6 +52,8 @@ def main():
parser = argparse.ArgumentParser( description="Setup ATS script" )
parser.add_argument( "src_path", type=str, help="GEOS src path" )
parser.add_argument( "build_path", type=str, help="GEOS build path" )
parser.add_argument( "baseline_dir", type=str, help="GEOS test baseline root directory" )
parser.add_argument( "working_dir", type=str, help="GEOS test working root directory" )
parser.add_argument( "--ats",
nargs='+',
default=[],
Expand All @@ -54,7 +62,8 @@ def main():
parser.add_argument( "--machine", type=str, default='', help="ATS machine name" )
parser.add_argument( "--machine-dir", type=str, default='', help="ATS machine directory" )
options, unkown_args = parser.parse_known_args()
setup_ats( options.src_path, options.build_path, options.ats, options.machine, options.machine_dir )
setup_ats( options.src_path, options.build_path, options.baseline_dir, options.working_dir, options.ats,
options.machine, options.machine_dir )


if __name__ == '__main__':
Expand Down
25 changes: 11 additions & 14 deletions geos_ats_package/geos_ats/helpers/curve_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,20 +275,17 @@ def compare_time_history_curves( fname, baseline, curve, tolerance, output, outp
# Generate script-based curve
if script_instructions and ( len( data ) > 0 ):
data[ 'script' ] = {}
try:
for script, fn, p, s in script_instructions:
k = location_strings[ p ]
data[ 'script' ][ f'{p} Time' ] = data[ 'target' ][ f'{p} Time' ]
key = f'{p} {k}'
key2 = f'{p}'
if s != DEFAULT_SET_NAME:
key += f' {s}'
key2 += f' {s}'
data[ 'script' ][ key ] = data[ 'target' ][ key ]
data[ 'script' ][ key2 ] = evaluate_external_script( script, fn, data[ 'target' ] )
data_sizes[ p ][ s ][ 'script' ] = list( np.shape( data[ 'script' ][ key2 ] ) )
except Exception as e:
errors.append( str( e ) )
for script, fn, p, s in script_instructions:
k = location_strings[ p ]
data[ 'script' ][ f'{p} Time' ] = data[ 'target' ][ f'{p} Time' ]
key = f'{p} {k}'
key2 = f'{p}'
if s != DEFAULT_SET_NAME:
key += f' {s}'
key2 += f' {s}'
data[ 'script' ][ key ] = data[ 'target' ][ key ]
data[ 'script' ][ key2 ] = evaluate_external_script( script, fn, data[ 'target' ] )
data_sizes[ p ][ s ][ 'script' ] = list( np.shape( data[ 'script' ][ key2 ] ) )

# Reshape data if necessary so that they have a predictable number of dimensions
for k in data.keys():
Expand Down
4 changes: 2 additions & 2 deletions geos_ats_package/geos_ats/machines/batchGeosatsMoab.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#BATS:batchGeosatsMoab batchGeosatsMoab BatchGeosatsMoab -1

from ats import machines, configuration, log, atsut, times, AtsTest # type: ignore[import]
import subprocess, sys, os, shlex, time, socket, re
import utils, batchTemplate # type: ignore[import]
import subprocess, sys, os, time, socket, re
import utils # type: ignore[import]
from batch import BatchMachine # type: ignore[import]
import logging

Expand Down
Loading

0 comments on commit d543c04

Please sign in to comment.