diff --git a/geos-ats/src/geos/ats/test_builder.py b/geos-ats/src/geos/ats/test_builder.py index 21ec98ea..56451895 100644 --- a/geos-ats/src/geos/ats/test_builder.py +++ b/geos-ats/src/geos/ats/test_builder.py @@ -8,12 +8,19 @@ from ats.tests import AtsTest from lxml import etree import logging -from .test_steps import geos +from .test_steps import geos, pygeos_test from .test_case import TestCase test_build_failures = [] logger = logging.getLogger( 'geos-ats' ) +has_pygeos = True +try: + import pygeosx +except ImportError: + logger.warning( 'pygeos is not available on this system' ) + has_pygeos = False + @dataclass( frozen=True ) class RestartcheckParameters: @@ -43,6 +50,7 @@ class TestDeck: partitions: Iterable[ Tuple[ int, int, int ] ] restart_step: int check_step: int + pygeos_script: str = '' restartcheck_params: RestartcheckParameters = None curvecheck_params: CurveCheckParameters = None @@ -121,33 +129,38 @@ def generate_geos_tests( decks: Iterable[ TestDeck ], test_type='smoke' ): if curvecheck_params: checks.append( 'curve' ) - steps = [ - geos( deck=xml_file, - name=base_name, - np=N, - ngpu=N, - x_partitions=nx, - y_partitions=ny, - z_partitions=nz, - restartcheck_params=restartcheck_params, - curvecheck_params=curvecheck_params ) - ] + # Setup model inputs + model_type = geos + model_kwargs = { + 'deck': xml_file, + 'name': base_name, + 'np': N, + 'ngpu': N, + 'x_partitions': nx, + 'y_partitions': ny, + 'z_partitions': nz, + 'restartcheck_params': restartcheck_params, + 'curvecheck_params': curvecheck_params + } + + if deck.pygeos_script: + if has_pygeos: + model_type = pygeos_test + model_kwargs[ 'script' ] = deck.pygeos_script + else: + logger.warning( f'Skipping test that requires pygeos: {deck.name}' ) + continue + + steps = [ model_type( **model_kwargs ) ] if deck.restart_step > 0: checks.append( 'restart' ) - steps.append( - geos( deck=xml_file, - name="{:d}to{:d}".format( deck.restart_step, deck.check_step ), - np=N, - ngpu=N, - x_partitions=nx, - y_partitions=ny, - z_partitions=nz, - restart_file=os.path.join( testcase_name, - "{}_restart_{:09d}".format( base_name, deck.restart_step ) ), - baseline_pattern=f"{base_name}_restart_[0-9]+\.root", - allow_rebaseline=False, - restartcheck_params=restartcheck_params ) ) + model_kwargs[ 'name' ] = "{:d}to{:d}".format( deck.restart_step, deck.check_step ) + model_kwargs[ 'restart_file' ] = os.path.join( + testcase_name, "{}_restart_{:09d}".format( base_name, deck.restart_step ) ) + model_kwargs[ 'baseline_pattern' ] = f"{base_name}_restart_[0-9]+\.root" + model_kwargs[ 'allow_rebaseline' ] = False + steps.append( model_type( **model_kwargs ) ) AtsTest.stick( level=ii ) AtsTest.stick( checks=','.join( checks ) ) diff --git a/geos-ats/src/geos/ats/test_steps.py b/geos-ats/src/geos/ats/test_steps.py index 42691063..176945be 100644 --- a/geos-ats/src/geos/ats/test_steps.py +++ b/geos-ats/src/geos/ats/test_steps.py @@ -431,11 +431,6 @@ def useMPI( self ): return True def executable( self ): - # python = os.path.join(binDir, "..", "lib", "PYGEOS", "bin", "python3") - # pygeosDir = os.path.join(binDir, "..", "..", "src", "pygeos") - # return python + " -m mpi4py " + os.path.join( pygeosDir, "reentrantTest.py" ) - # return python + " -m mpi4py " + os.path.join( pygeosDir, "test.py" ) - # return config.geos_bin_dir return os.path.join( config.geos_bin_dir, 'geosx' ) def update( self, dictionary ): @@ -513,6 +508,37 @@ def rebaseline( self ): history.write_baseline_log( os.path.join( self.p.baseline_directory, '.baseline_info' ) ) +################################################################################ +# pygeos +################################################################################ +class pygeos_test( geos ): + """ + Class for the pygeos test step. + """ + + doc = """ + This TestCase runs the pygeos executable.""" + + command = "python [script] [-i ] [-r ] [-x ] [-y ] [-z ] [-s ] [-n ] [-o ] [ --suppress-pinned ] " + + params = geos.params + ( TestParam( "script", "Pygeos run script." ), ) # type: ignore[assignment] + + checkstepnames = [ "restartcheck" ] + + def label( self ): + return "pygeos" + + def executable( self ): + p = os.path.abspath(os.path.join( config.geos_bin_dir, 'python' )) + if os.path.islink(p): + p = os.readlink(p) + return p + + def makeArgs( self ): + args = [ os.path.join( self.p.test_directory, self.p.script ) ] + return args + super().makeArgs() + + ################################################################################ # restartcheck ################################################################################