Skip to content

Add pygeosx integrated tests #22

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 38 additions & 25 deletions geos-ats/src/geos/ats/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 ) )
Expand Down
36 changes: 31 additions & 5 deletions geos-ats/src/geos/ats/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ):
Expand Down Expand Up @@ -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 <deck>] [-r <restart_file>] [-x <x_partitions>] [-y <y_partitions>] [-z <z_partitions>] [-s <schema_level>] [-n <problem_name>] [-o <output_directory>] [ --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
################################################################################
Expand Down
Loading