Skip to content
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

Enable Code Formatting Checks #5

Merged
merged 5 commits into from
Jan 29, 2024
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
python -m pip install --upgrade pip
python -m pip install pytest yapf toml
python -m pip install .
# - name: Lint with yapf
# working-directory: ./${{ matrix.package-name }}
# run: |
# yapf -r --diff .
- name: Lint with yapf
working-directory: ./${{ matrix.package-name }}
run: |
yapf -r --diff . --style ../.style.yapf
# - name: Test with pytest
# working-directory: ./${{ matrix.package-name }}
# run: |
Expand Down
6 changes: 6 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[style]
based_on_style = pep8
spaces_before_comment = 2
split_before_logical_operator = true
column_limit = 120
space_inside_brackets = true
38 changes: 9 additions & 29 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@

# 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',
'timehistory_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)))

sys.path.insert( 0, os.path.abspath( os.path.join( python_root, m ) ) )

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

Expand All @@ -40,7 +34,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 +44,11 @@
# 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 All @@ -83,34 +69,28 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store', 'cmake/*']
exclude_patterns = [ u'_build', 'Thumbs.db', '.DS_Store', 'cmake/*' ]

todo_include_todos = True

# 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_static_path = [ './_static' ]

html_css_files = [
'theme_overrides.css',
]


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

2 changes: 1 addition & 1 deletion geos_ats_package/geos_ats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

# Add the machines module to the ats.atsMachines submodule,
# So that ats can find our custom definitions at runtime
sys.modules['ats.atsMachines.machines'] = machines
sys.modules[ 'ats.atsMachines.machines' ] = machines
93 changes: 51 additions & 42 deletions geos_ats_package/geos_ats/command_line_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,49 +36,58 @@


def build_command_line_parser():
parser = argparse.ArgumentParser(description="Runs GEOS integrated tests")
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})")
action_names = ','.join( action_options.keys() )
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})")
check_names = ','.join( check_options.keys() )
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})")
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( "-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( "-i", "--info", action="store_true", default=False, help="Info on various topics" )

parser.add_argument("-r",
"--restartCheckOverrides",
nargs='+',
action='append',
help='Restart check parameter override (name value)',
default=[])
parser.add_argument( "-r",
"--restartCheckOverrides",
nargs='+',
action='append',
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", 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( "-l", "--logs", type=str, default=None )

parser.add_argument(
"--failIfTestsFail",
Expand All @@ -87,14 +96,14 @@ def build_command_line_parser():
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( "-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


def parse_command_line_arguments(args):
def parse_command_line_arguments( args ):
parser = build_command_line_parser()
options, unkown_args = parser.parse_known_args()
exit_flag = False
Expand All @@ -103,7 +112,7 @@ 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 @@ -115,15 +124,15 @@ def parse_command_line_arguments(args):

verbose = options.verbose
if verbose not in verbose_options:
print(f"Selected verbose option ({verbose}) not recognized")
print( f"Selected verbose option ({verbose}) not recognized" )
exit_flag = True

# Print detailed information
if options.detail:
for option_type, details in zip(['action', 'check'], [action_options, check_options]):
print(f'\nAvailable {option_type} 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}')
print( f' {k}: {v}' )
exit_flag = True

if exit_flag:
Expand All @@ -132,20 +141,20 @@ def parse_command_line_arguments(args):
return options


def patch_parser(parser):
def patch_parser( parser ):

def add_option_patch(*xargs, **kwargs):
def add_option_patch( *xargs, **kwargs ):
"""
Convert type string to actual type instance
"""
tmp = kwargs.get('type', str)
type_map = {'string': str}
if isinstance(tmp, str):
tmp = kwargs.get( 'type', str )
type_map = { 'string': str }
if isinstance( tmp, str ):
if tmp in type_map:
tmp = type_map[tmp]
tmp = type_map[ tmp ]
else:
tmp = locate(tmp)
kwargs['type'] = tmp
parser.add_argument(*xargs, **kwargs)
tmp = locate( tmp )
kwargs[ 'type' ] = tmp
parser.add_argument( *xargs, **kwargs )

parser.add_option = add_option_patch
Loading
Loading