Skip to content

Commit 0357a21

Browse files
authored
Merge pull request #3 from GEOS-DEV/feature/sherman/migrateGeosATSPackage
Migrate geos ats package
2 parents c7269ce + 9aeecef commit 0357a21

35 files changed

+7108
-1
lines changed

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
python_modules = ('geosx_mesh_tools_package',
2222
'geosx_xml_tools_package',
2323
'geosx_mesh_doctor',
24+
'geos_ats_package',
2425
'hdf5_wrapper_package',
2526
'pygeosx_tools_package',
2627
'timehistory_package')
@@ -61,7 +62,7 @@
6162
]
6263

6364

64-
autodoc_mock_imports = ["pygeosx", "pylvarray", "meshio", "lxml", "mpi4py", "h5py"]
65+
autodoc_mock_imports = ["pygeosx", "pylvarray", "meshio", "lxml", "mpi4py", "h5py", "ats", "scipy"]
6566

6667
# The suffix(es) of source filenames.
6768
# You can specify multiple suffix as a list of string:

docs/geos_ats.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
GEOS ATS
3+
==========
4+
5+
The `geos_ats` python package includes tools for managing integrated tests for GEOS.
6+
It is built using the `Automated Test System <https://ats.readthedocs.io/en/latest/>`_ (ATS) package.
7+
The available console scripts for this package and its API are described below.
8+
9+
10+
run_geos_ats
11+
----------------
12+
13+
Primary entry point for running integrated tests.
14+
15+
.. argparse::
16+
:module: geos_ats.command_line_parsers
17+
:func: build_command_line_parser
18+
:prog: run_geos_ats
19+
20+
21+
.. note::
22+
Arguments can be passed to the underlying ATS system with the `--ats` argument.
23+
24+
25+
.. note::
26+
Other machine-specific options for ATS can be viewed by running `run_geos_ats --ats help`
27+
28+
29+
API
30+
------
31+
32+
33+
Restart Check
34+
^^^^^^^^^^^^^^^
35+
36+
.. automodule:: geos_ats.helpers.restart_check
37+
:members:
38+
39+
40+
Curve Check
41+
^^^^^^^^^^^^^^^
42+
43+
.. automodule:: geos_ats.helpers.curve_check
44+
:members:
45+
46+

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Packages
4343

4444
hdf5_wrapper
4545

46+
geos_ats
47+
4648
geosx_mesh_tools
4749

4850
geosx_xml_tools
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import sys
2+
from . import machines
3+
4+
# Add the machines module to the ats.atsMachines submodule,
5+
# So that ats can find our custom definitions at runtime
6+
sys.modules['ats.atsMachines.machines'] = machines
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
import logging
2+
import argparse
3+
import os
4+
import shutil
5+
from pydoc import locate
6+
7+
action_options = {
8+
"run": "execute the test cases that previously did not pass.",
9+
"rerun": "ignore the status from previous runs, and rerun the tests.",
10+
"continue": "continue running, ignoring tests that have either passed or failed",
11+
"list": "list the test cases.",
12+
"commands": "display the command line of each test step.",
13+
"reset": "Removes Failed status from any test case.",
14+
"clean": "remove files generated by the test cases.",
15+
"veryclean": "does a clean plus removes non testcase created files (TestLog, results, ...)",
16+
"check": "skip the action steps and just run the check steps.",
17+
"rebaseline": "rebaseline the testcases from a previous run.",
18+
"rebaselinefailed": "rebaseline only failed testcases from a previous run.",
19+
"report": "generate a text or html report, see config for the reporting options.",
20+
}
21+
22+
check_options = {
23+
"all": "run all checks",
24+
"none": "no additional checking",
25+
"stopcheck": "check the stop time and stop cycle",
26+
"curvecheck": "check the ultra curves",
27+
"restartcheck": "check the restart file",
28+
}
29+
30+
verbose_options = {
31+
"debug": "Show detailed log information",
32+
"info": "Show typical log information",
33+
"warnings": "Show warnings only",
34+
"errors": "Show errors only",
35+
}
36+
37+
38+
def build_command_line_parser():
39+
parser = argparse.ArgumentParser(description="Runs GEOS integrated tests")
40+
41+
parser.add_argument("geos_bin_dir", type=str, help="GEOS binary directory.")
42+
43+
parser.add_argument("-w", "--workingDir", type=str, help="Initial working directory")
44+
45+
action_names = ','.join(action_options.keys())
46+
parser.add_argument("-a", "--action", type=str, default="run", help=f"Test actions options ({action_names})")
47+
48+
check_names = ','.join(check_options.keys())
49+
parser.add_argument("-c", "--check", type=str, default="all", help=f"Test check options ({check_names})")
50+
51+
verbosity_names = ','.join(verbose_options.keys())
52+
parser.add_argument("-v", "--verbose", type=str, default="info", help=f"Log verbosity options ({verbosity_names})")
53+
54+
parser.add_argument("-d", "--detail", action="store_true", default=False, help="Show detailed action/check options")
55+
56+
parser.add_argument("-i", "--info", action="store_true", default=False, help="Info on various topics")
57+
58+
parser.add_argument("-r",
59+
"--restartCheckOverrides",
60+
nargs='+',
61+
action='append',
62+
help='Restart check parameter override (name value)',
63+
default=[])
64+
65+
parser.add_argument("--salloc",
66+
default=True,
67+
help="Used by the chaosM machine to first allocate nodes with salloc, before running the tests")
68+
69+
parser.add_argument(
70+
"--sallocoptions",
71+
type=str,
72+
default="",
73+
help="Used to override all command-line options for salloc. No other options with be used or added.")
74+
75+
parser.add_argument("--ats", nargs='+', default=[], action="append", help="pass arguments to ats")
76+
77+
parser.add_argument("--machine", default=None, help="name of the machine")
78+
79+
parser.add_argument("--machine-dir", default=None, help="Search path for machine definitions")
80+
81+
parser.add_argument("-l", "--logs", type=str, default=None)
82+
83+
parser.add_argument(
84+
"--failIfTestsFail",
85+
action="store_true",
86+
default=False,
87+
help="geos_ats normally exits with 0. This will cause it to exit with an error code if there was a failed test."
88+
)
89+
90+
parser.add_argument("-n", "-N", "--numNodes", type=int, default="2")
91+
92+
parser.add_argument("ats_targets", type=str, nargs='*', help="ats files or directories.")
93+
94+
return parser
95+
96+
97+
def parse_command_line_arguments(args):
98+
parser = build_command_line_parser()
99+
options, unkown_args = parser.parse_known_args()
100+
exit_flag = False
101+
102+
# Check action, check, verbosity items
103+
check = options.check
104+
if check not in check_options:
105+
print(
106+
f"Selected check option ({check}) not recognized. Try running with --help/--details for more information")
107+
exit_flag = True
108+
109+
action = options.action
110+
if action not in action_options:
111+
print(
112+
f"Selected action option ({action}) not recognized. Try running with --help/--details for more information"
113+
)
114+
exit_flag = True
115+
116+
verbose = options.verbose
117+
if verbose not in verbose_options:
118+
print(f"Selected verbose option ({verbose}) not recognized")
119+
exit_flag = True
120+
121+
# Print detailed information
122+
if options.detail:
123+
for option_type, details in zip(['action', 'check'], [action_options, check_options]):
124+
print(f'\nAvailable {option_type} options:')
125+
for k, v in details.items():
126+
print(f' {k}: {v}')
127+
exit_flag = True
128+
129+
if exit_flag:
130+
quit()
131+
132+
return options
133+
134+
135+
def patch_parser(parser):
136+
137+
def add_option_patch(*xargs, **kwargs):
138+
"""
139+
Convert type string to actual type instance
140+
"""
141+
tmp = kwargs.get('type', str)
142+
type_map = {'string': str}
143+
if isinstance(tmp, str):
144+
if tmp in type_map:
145+
tmp = type_map[tmp]
146+
else:
147+
tmp = locate(tmp)
148+
kwargs['type'] = tmp
149+
parser.add_argument(*xargs, **kwargs)
150+
151+
parser.add_option = add_option_patch

0 commit comments

Comments
 (0)