Skip to content

Commit caadf01

Browse files
committed
Adding pygeos integrated test option
1 parent e5abdc8 commit caadf01

File tree

2 files changed

+66
-30
lines changed

2 files changed

+66
-30
lines changed

geos-ats/src/geos/ats/test_builder.py

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@
88
from ats.tests import AtsTest
99
from lxml import etree
1010
import logging
11-
from .test_steps import geos
11+
from .test_steps import geos, pygeos_test
1212
from .test_case import TestCase
1313

1414
test_build_failures = []
1515
logger = logging.getLogger( 'geos-ats' )
1616

17+
has_pygeos = True
18+
try:
19+
import pygeos
20+
except ImportError:
21+
logger.warning( 'pygeos is not available on this system' )
22+
has_pygeos = False
23+
1724

1825
@dataclass( frozen=True )
1926
class RestartcheckParameters:
@@ -43,6 +50,7 @@ class TestDeck:
4350
partitions: Iterable[ Tuple[ int, int, int ] ]
4451
restart_step: int
4552
check_step: int
53+
pygeos_script: str = ''
4654
restartcheck_params: RestartcheckParameters = None
4755
curvecheck_params: CurveCheckParameters = None
4856

@@ -121,33 +129,38 @@ def generate_geos_tests( decks: Iterable[ TestDeck ], test_type='smoke' ):
121129
if curvecheck_params:
122130
checks.append( 'curve' )
123131

124-
steps = [
125-
geos( deck=xml_file,
126-
name=base_name,
127-
np=N,
128-
ngpu=N,
129-
x_partitions=nx,
130-
y_partitions=ny,
131-
z_partitions=nz,
132-
restartcheck_params=restartcheck_params,
133-
curvecheck_params=curvecheck_params )
134-
]
132+
# Setup model inputs
133+
model_type = geos
134+
model_kwargs = {
135+
'deck': xml_file,
136+
'name': base_name,
137+
'np': N,
138+
'ngpu': N,
139+
'x_partitions': nx,
140+
'y_partitions': ny,
141+
'z_partitions': nz,
142+
'restartcheck_params': restartcheck_params,
143+
'curvecheck_params': curvecheck_params
144+
}
145+
146+
if deck.pygeos_script:
147+
if has_pygeos:
148+
model_type = pygeos_test
149+
model_kwargs[ 'script' ] = deck.pygeos_script
150+
else:
151+
logger.warning( f'Skipping test that requires pygeos: {deck.name}' )
152+
continue
153+
154+
steps = [ model_type( **model_kwargs ) ]
135155

136156
if deck.restart_step > 0:
137157
checks.append( 'restart' )
138-
steps.append(
139-
geos( deck=xml_file,
140-
name="{:d}to{:d}".format( deck.restart_step, deck.check_step ),
141-
np=N,
142-
ngpu=N,
143-
x_partitions=nx,
144-
y_partitions=ny,
145-
z_partitions=nz,
146-
restart_file=os.path.join( testcase_name,
147-
"{}_restart_{:09d}".format( base_name, deck.restart_step ) ),
148-
baseline_pattern=f"{base_name}_restart_[0-9]+\.root",
149-
allow_rebaseline=False,
150-
restartcheck_params=restartcheck_params ) )
158+
model_kwargs[ 'name' ] = "{:d}to{:d}".format( deck.restart_step, deck.check_step )
159+
model_kwargs[ 'restart_file' ] = os.path.join(
160+
testcase_name, "{}_restart_{:09d}".format( base_name, deck.restart_step ) )
161+
model_kwargs[ 'baseline_pattern' ] = f"{base_name}_restart_[0-9]+\.root"
162+
model_kwargs[ 'allow_rebaseline' ] = False
163+
steps.append( model_type( **model_kwargs ) )
151164

152165
AtsTest.stick( level=ii )
153166
AtsTest.stick( checks=','.join( checks ) )

geos-ats/src/geos/ats/test_steps.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,6 @@ def useMPI( self ):
431431
return True
432432

433433
def executable( self ):
434-
# python = os.path.join(binDir, "..", "lib", "PYGEOS", "bin", "python3")
435-
# pygeosDir = os.path.join(binDir, "..", "..", "src", "pygeos")
436-
# return python + " -m mpi4py " + os.path.join( pygeosDir, "reentrantTest.py" )
437-
# return python + " -m mpi4py " + os.path.join( pygeosDir, "test.py" )
438-
# return config.geos_bin_dir
439434
return os.path.join( config.geos_bin_dir, 'geosx' )
440435

441436
def update( self, dictionary ):
@@ -513,6 +508,34 @@ def rebaseline( self ):
513508
history.write_baseline_log( os.path.join( self.p.baseline_directory, '.baseline_info' ) )
514509

515510

511+
################################################################################
512+
# pygeos
513+
################################################################################
514+
class pygeos_test( geos ):
515+
"""
516+
Class for the pygeos test step.
517+
"""
518+
519+
doc = """
520+
This TestCase runs the pygeos executable."""
521+
522+
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 ] "
523+
524+
params = geos.params + ( TestStepBase.commonParams[ "script" ] ) # type: ignore[operator]
525+
526+
checkstepnames = [ "restartcheck" ]
527+
528+
def label( self ):
529+
return "pygeos"
530+
531+
def executable( self ):
532+
return os.path.join( config.geos_bin_dir, 'python' )
533+
534+
def makeArgs( self ):
535+
args = [ os.path.join( self.p.test_directory, self.p.script ) ]
536+
return args + super().makeArgs()
537+
538+
516539
################################################################################
517540
# restartcheck
518541
################################################################################

0 commit comments

Comments
 (0)