From caadf01844a5e20fdc1965e1e18b0005e81be2e5 Mon Sep 17 00:00:00 2001 From: Christopher Sherman Date: Fri, 14 Jun 2024 10:15:53 -0700 Subject: [PATCH 1/5] Adding pygeos integrated test option --- geos-ats/src/geos/ats/test_builder.py | 63 ++++++++++++++++----------- geos-ats/src/geos/ats/test_steps.py | 33 +++++++++++--- 2 files changed, 66 insertions(+), 30 deletions(-) diff --git a/geos-ats/src/geos/ats/test_builder.py b/geos-ats/src/geos/ats/test_builder.py index 21ec98ea1..b0516c9d0 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 pygeos +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 42691063a..9ca081b76 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,34 @@ 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 + ( TestStepBase.commonParams[ "script" ] ) # type: ignore[operator] + + checkstepnames = [ "restartcheck" ] + + def label( self ): + return "pygeos" + + def executable( self ): + return os.path.join( config.geos_bin_dir, 'python' ) + + def makeArgs( self ): + args = [ os.path.join( self.p.test_directory, self.p.script ) ] + return args + super().makeArgs() + + ################################################################################ # restartcheck ################################################################################ From 0ec9364db94bb3aada65166bb010a7085b2067fa Mon Sep 17 00:00:00 2001 From: Christopher Sherman Date: Mon, 17 Jun 2024 12:03:19 -0700 Subject: [PATCH 2/5] Updating pygeos test input --- geos-ats/src/geos/ats/test_steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geos-ats/src/geos/ats/test_steps.py b/geos-ats/src/geos/ats/test_steps.py index 9ca081b76..d07909b93 100644 --- a/geos-ats/src/geos/ats/test_steps.py +++ b/geos-ats/src/geos/ats/test_steps.py @@ -521,7 +521,7 @@ class pygeos_test( geos ): command = "python [script] [-i ] [-r ] [-x ] [-y ] [-z ] [-s ] [-n ] [-o ] [ --suppress-pinned ] " - params = geos.params + ( TestStepBase.commonParams[ "script" ] ) # type: ignore[operator] + params = geos.params + ( TestParam( "script", "Pygeos run script." ) ) # type: ignore[operator] checkstepnames = [ "restartcheck" ] From ad1ce3f74ae30ecb681b39a17c6cb8678fe3e77e Mon Sep 17 00:00:00 2001 From: Christopher Sherman Date: Mon, 17 Jun 2024 12:23:26 -0700 Subject: [PATCH 3/5] Updating pygeos test input --- geos-ats/src/geos/ats/test_steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geos-ats/src/geos/ats/test_steps.py b/geos-ats/src/geos/ats/test_steps.py index d07909b93..16e765dba 100644 --- a/geos-ats/src/geos/ats/test_steps.py +++ b/geos-ats/src/geos/ats/test_steps.py @@ -521,7 +521,7 @@ class pygeos_test( geos ): command = "python [script] [-i ] [-r ] [-x ] [-y ] [-z ] [-s ] [-n ] [-o ] [ --suppress-pinned ] " - params = geos.params + ( TestParam( "script", "Pygeos run script." ) ) # type: ignore[operator] + params = geos.params + ( TestParam( "script", "Pygeos run script." ), ) # type: ignore[assignment] checkstepnames = [ "restartcheck" ] From 7f334aa28ebf64a72b8cb1e03fd70060d74fcf7d Mon Sep 17 00:00:00 2001 From: Christopher Sherman Date: Mon, 17 Jun 2024 12:30:24 -0700 Subject: [PATCH 4/5] Fixing pygeosx test --- geos-ats/src/geos/ats/test_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geos-ats/src/geos/ats/test_builder.py b/geos-ats/src/geos/ats/test_builder.py index b0516c9d0..564518952 100644 --- a/geos-ats/src/geos/ats/test_builder.py +++ b/geos-ats/src/geos/ats/test_builder.py @@ -16,7 +16,7 @@ has_pygeos = True try: - import pygeos + import pygeosx except ImportError: logger.warning( 'pygeos is not available on this system' ) has_pygeos = False From fc537068046d0d674ec4b9fc4418c1f26b50c1f4 Mon Sep 17 00:00:00 2001 From: Christopher Sherman Date: Mon, 17 Jun 2024 14:59:08 -0700 Subject: [PATCH 5/5] Fixing pygeosx path --- geos-ats/src/geos/ats/test_steps.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/geos-ats/src/geos/ats/test_steps.py b/geos-ats/src/geos/ats/test_steps.py index 16e765dba..176945bec 100644 --- a/geos-ats/src/geos/ats/test_steps.py +++ b/geos-ats/src/geos/ats/test_steps.py @@ -529,7 +529,10 @@ def label( self ): return "pygeos" def executable( self ): - return os.path.join( config.geos_bin_dir, 'python' ) + 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 ) ]