Skip to content

Commit

Permalink
Enabling code formatting checks, applying yapf
Browse files Browse the repository at this point in the history
  • Loading branch information
cssherman committed Jan 18, 2024
1 parent 8c38fb7 commit ac2cd8d
Show file tree
Hide file tree
Showing 88 changed files with 2,624 additions and 1,426 deletions.
35 changes: 10 additions & 25 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@

# Add python modules to be documented
python_root = '..'
python_modules = ('geosx_mesh_tools_package',
'geosx_xml_tools_package',
'geosx_mesh_doctor',
'geos_ats_package',
'hdf5_wrapper_package',
'pygeosx_tools_package',
python_modules = ('geosx_mesh_tools_package', 'geosx_xml_tools_package',
'geosx_mesh_doctor', 'geos_ats_package',
'hdf5_wrapper_package', 'pygeosx_tools_package',
'timehistory_package')
for m in python_modules:
sys.path.insert(0, os.path.abspath(os.path.join(python_root, m)))


# -- Project information -----------------------------------------------------

project = u'GEOS Python Packages'
Expand All @@ -40,7 +36,6 @@
# The full version, including alpha/beta/rc tags
release = u''


# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand All @@ -51,18 +46,14 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx_design',
'sphinx.ext.todo',
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.imgmath',
'sphinxarg.ext',
'sphinx.ext.napoleon',
'sphinxcontrib.programoutput'
'sphinx_design', 'sphinx.ext.todo', 'sphinx.ext.autodoc',
'sphinx.ext.doctest', 'sphinx.ext.imgmath', 'sphinxarg.ext',
'sphinx.ext.napoleon', 'sphinxcontrib.programoutput'
]


autodoc_mock_imports = ["pygeosx", "pylvarray", "meshio", "lxml", "mpi4py", "h5py", "ats", "scipy"]
autodoc_mock_imports = [
"pygeosx", "pylvarray", "meshio", "lxml", "mpi4py", "h5py", "ats", "scipy"
]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
Expand Down Expand Up @@ -90,27 +81,21 @@
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'


# -- Theme options ----------------------------------------------
extensions += [
'sphinx_rtd_theme',
]

html_theme = "sphinx_rtd_theme"

html_theme_options = {
'navigation_depth': -1,
'collapse_navigation': False
}
html_theme_options = {'navigation_depth': -1, 'collapse_navigation': False}

html_static_path = ['./_static']

html_css_files = [
'theme_overrides.css',
]


# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'geosPythonPackagesDoc'

116 changes: 85 additions & 31 deletions geos_ats_package/geos_ats/command_line_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,30 @@
from pydoc import locate

action_options = {
"run": "execute the test cases that previously did not pass.",
"rerun": "ignore the status from previous runs, and rerun the tests.",
"continue": "continue running, ignoring tests that have either passed or failed",
"list": "list the test cases.",
"commands": "display the command line of each test step.",
"reset": "Removes Failed status from any test case.",
"clean": "remove files generated by the test cases.",
"veryclean": "does a clean plus removes non testcase created files (TestLog, results, ...)",
"check": "skip the action steps and just run the check steps.",
"rebaseline": "rebaseline the testcases from a previous run.",
"rebaselinefailed": "rebaseline only failed testcases from a previous run.",
"report": "generate a text or html report, see config for the reporting options.",
"run":
"execute the test cases that previously did not pass.",
"rerun":
"ignore the status from previous runs, and rerun the tests.",
"continue":
"continue running, ignoring tests that have either passed or failed",
"list":
"list the test cases.",
"commands":
"display the command line of each test step.",
"reset":
"Removes Failed status from any test case.",
"clean":
"remove files generated by the test cases.",
"veryclean":
"does a clean plus removes non testcase created files (TestLog, results, ...)",
"check":
"skip the action steps and just run the check steps.",
"rebaseline":
"rebaseline the testcases from a previous run.",
"rebaselinefailed":
"rebaseline only failed testcases from a previous run.",
"report":
"generate a text or html report, see config for the reporting options.",
}

check_options = {
Expand All @@ -38,22 +50,47 @@
def build_command_line_parser():
parser = argparse.ArgumentParser(description="Runs GEOS integrated tests")

parser.add_argument("geos_bin_dir", type=str, help="GEOS binary directory.")
parser.add_argument("geos_bin_dir",
type=str,
help="GEOS binary directory.")

parser.add_argument("-w", "--workingDir", type=str, help="Initial working directory")
parser.add_argument("-w",
"--workingDir",
type=str,
help="Initial working directory")

action_names = ','.join(action_options.keys())
parser.add_argument("-a", "--action", type=str, default="run", help=f"Test actions options ({action_names})")
parser.add_argument("-a",
"--action",
type=str,
default="run",
help=f"Test actions options ({action_names})")

check_names = ','.join(check_options.keys())
parser.add_argument("-c", "--check", type=str, default="all", help=f"Test check options ({check_names})")
parser.add_argument("-c",
"--check",
type=str,
default="all",
help=f"Test check options ({check_names})")

verbosity_names = ','.join(verbose_options.keys())
parser.add_argument("-v", "--verbose", type=str, default="info", help=f"Log verbosity options ({verbosity_names})")

parser.add_argument("-d", "--detail", action="store_true", default=False, help="Show detailed action/check options")

parser.add_argument("-i", "--info", action="store_true", default=False, help="Info on various topics")
parser.add_argument("-v",
"--verbose",
type=str,
default="info",
help=f"Log verbosity options ({verbosity_names})")

parser.add_argument("-d",
"--detail",
action="store_true",
default=False,
help="Show detailed action/check options")

parser.add_argument("-i",
"--info",
action="store_true",
default=False,
help="Info on various topics")

parser.add_argument("-r",
"--restartCheckOverrides",
Expand All @@ -62,34 +99,49 @@ def build_command_line_parser():
help='Restart check parameter override (name value)',
default=[])

parser.add_argument("--salloc",
default=True,
help="Used by the chaosM machine to first allocate nodes with salloc, before running the tests")
parser.add_argument(
"--salloc",
default=True,
help=
"Used by the chaosM machine to first allocate nodes with salloc, before running the tests"
)

parser.add_argument(
"--sallocoptions",
type=str,
default="",
help="Used to override all command-line options for salloc. No other options with be used or added.")
help=
"Used to override all command-line options for salloc. No other options with be used or added."
)

parser.add_argument("--ats", nargs='+', default=[], action="append", help="pass arguments to ats")
parser.add_argument("--ats",
nargs='+',
default=[],
action="append",
help="pass arguments to ats")

parser.add_argument("--machine", default=None, help="name of the machine")

parser.add_argument("--machine-dir", default=None, help="Search path for machine definitions")
parser.add_argument("--machine-dir",
default=None,
help="Search path for machine definitions")

parser.add_argument("-l", "--logs", type=str, default=None)

parser.add_argument(
"--failIfTestsFail",
action="store_true",
default=False,
help="geos_ats normally exits with 0. This will cause it to exit with an error code if there was a failed test."
help=
"geos_ats normally exits with 0. This will cause it to exit with an error code if there was a failed test."
)

parser.add_argument("-n", "-N", "--numNodes", type=int, default="2")

parser.add_argument("ats_targets", type=str, nargs='*', help="ats files or directories.")
parser.add_argument("ats_targets",
type=str,
nargs='*',
help="ats files or directories.")

return parser

Expand All @@ -103,7 +155,8 @@ def parse_command_line_arguments(args):
check = options.check
if check not in check_options:
print(
f"Selected check option ({check}) not recognized. Try running with --help/--details for more information")
f"Selected check option ({check}) not recognized. Try running with --help/--details for more information"
)
exit_flag = True

action = options.action
Expand All @@ -120,7 +173,8 @@ def parse_command_line_arguments(args):

# Print detailed information
if options.detail:
for option_type, details in zip(['action', 'check'], [action_options, check_options]):
for option_type, details in zip(['action', 'check'],
[action_options, check_options]):
print(f'\nAvailable {option_type} options:')
for k, v in details.items():
print(f' {k}: {v}')
Expand Down
32 changes: 23 additions & 9 deletions geos_ats_package/geos_ats/common_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def Error(msg):


def Log(msg):
import ats # type: ignore[import]
import ats # type: ignore[import]
testmode = False
try:
testmode = ats.tests.AtsTest.getOptions().get("testmode")
Expand Down Expand Up @@ -48,7 +48,8 @@ def _getwidth(self):
maxwidth = 100
if os.name == "posix":
try:
sttyout = subprocess.Popen(["stty", "size"], stdout=subprocess.PIPE).communicate()[0]
sttyout = subprocess.Popen(
["stty", "size"], stdout=subprocess.PIPE).communicate()[0]
maxwidth = int(sttyout.split()[1])
except:
# If the stty size approach does not work, the use a default maxwidth
Expand Down Expand Up @@ -79,7 +80,10 @@ def printTable(self, outfile=sys.stdout):
# find the max column sizes
colWidth = []
for i in range(self.columns):
colWidth.append(max([len(str(row[i])) for row in self.table if row is not None]))
colWidth.append(
max([
len(str(row[i])) for row in self.table if row is not None
]))

# adjust the colWidths down if colmax is step
for i in range(self.columns):
Expand All @@ -89,7 +93,8 @@ def printTable(self, outfile=sys.stdout):

# last column is floating

total = sum(colWidth) + self.columns * (1 + len(self.sep)) + len(self.indent)
total = sum(colWidth) + self.columns * (1 + len(self.sep)) + len(
self.indent)
if total > self.maxwidth:
colWidth[-1] = max(10, self.maxwidth - (total - colWidth[-1]))

Expand All @@ -99,7 +104,9 @@ def printTable(self, outfile=sys.stdout):

# row break controls.
# if row is None then this is a break
addBreak = (row is None) or (self.rowbreak and rowbreakindex > 0 and rowbreakindex % self.rowbreak == 0)
addBreak = (row
is None) or (self.rowbreak and rowbreakindex > 0
and rowbreakindex % self.rowbreak == 0)
if addBreak:
table_str += self.indent
for i in range(self.columns):
Expand All @@ -125,9 +132,14 @@ def printTable(self, outfile=sys.stdout):
drow = str(row[i])

if i == self.columns - 1:
lines.append(textwrap.wrap(drow, colWidth[i], break_long_words=False))
lines.append(
textwrap.wrap(drow,
colWidth[i],
break_long_words=False))
else:
lines.append(textwrap.wrap(drow, colWidth[i], break_long_words=True))
lines.append(
textwrap.wrap(drow, colWidth[i],
break_long_words=True))

maxlines = max([len(x) for x in lines])

Expand Down Expand Up @@ -236,8 +248,10 @@ def removeLogDirectories(dir):
ff = os.path.join(dir, f)
if os.path.isdir(ff) and not os.path.islink(ff):
tests = [
all([os.path.exists(os.path.join(ff, "ats.log")),
os.path.exists(os.path.join(ff, "geos_ats.config"))]),
all([
os.path.exists(os.path.join(ff, "ats.log")),
os.path.exists(os.path.join(ff, "geos_ats.config"))
]),
f.find("TestLogs.") == 0
]
if any(tests):
Expand Down
Loading

0 comments on commit ac2cd8d

Please sign in to comment.