From 8fbeb459d845440dd5a02658d5c70206894bc248 Mon Sep 17 00:00:00 2001 From: Christopher Sherman Date: Fri, 2 Feb 2024 10:38:24 -0800 Subject: [PATCH] Fixing curve check paths --- .../geos_ats/helpers/curve_check.py | 25 ++++++++----------- geos_ats_package/geos_ats/test_steps.py | 12 +++++++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/geos_ats_package/geos_ats/helpers/curve_check.py b/geos_ats_package/geos_ats/helpers/curve_check.py index bdf2213..1353f62 100644 --- a/geos_ats_package/geos_ats/helpers/curve_check.py +++ b/geos_ats_package/geos_ats/helpers/curve_check.py @@ -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(): diff --git a/geos_ats_package/geos_ats/test_steps.py b/geos_ats_package/geos_ats/test_steps.py index 7f09908..54f7a2f 100644 --- a/geos_ats_package/geos_ats/test_steps.py +++ b/geos_ats_package/geos_ats/test_steps.py @@ -657,7 +657,7 @@ class curvecheck( CheckTestStepBase ): params = TestStepBase.defaultParams + CheckTestStepBase.checkParams + ( TestStepBase.commonParams[ "deck" ], TestStepBase.commonParams[ "name" ], TestStepBase.commonParams[ "np" ], TestStepBase.commonParams[ "allow_rebaseline" ], TestStepBase.commonParams[ "baseline_directory" ], - TestStepBase.commonParams[ "output_directory" ], + TestStepBase.commonParams[ "output_directory" ], TestStepBase.commonParams[ "test_directory" ], TestParam( "filename", "Name of the target curve file written by GEOS." ), TestParam( "curves", "A list of parameter, setname value pairs." ), TestParam( @@ -713,6 +713,7 @@ def update( self, dictionary ): self.requireParam( "deck" ) self.requireParam( "baseline_directory" ) self.requireParam( "output_directory" ) + self.requireParam( "test_directory" ) self.baseline_file = os.path.join( self.p.baseline_directory, self.p.filename ) self.target_file = os.path.join( self.p.output_directory, self.p.filename ) @@ -742,7 +743,14 @@ def makeArgs( self ): if self.p.script_instructions is not None: for c in self.p.script_instructions.split( ';' ): args += [ "-s" ] - args += c.split( ',' ) + + # Split the args and set the absolute script + tmp = c.split( ',' ) + tmp[ 0 ] = os.path.abspath( os.path.join( self.p.test_directory, tmp[ 0 ] ) ) + if not os.path.isfile( tmp[ 0 ] ): + raise FileNotFoundError( f"Could not find requested script for curve check: {tmp[0]}" ) + + args += tmp if self.p.warnings_are_errors: args += [ "-w" ]