Skip to content

Commit

Permalink
Pass unit tests and pre-commit checks
Browse files Browse the repository at this point in the history
  • Loading branch information
forsyth2 committed May 25, 2023
1 parent 129494b commit 3b2338e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
8 changes: 8 additions & 0 deletions tests/test_sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def test_sections(self):
"output": "OUTPUT",
"nodes": 1,
"partition": "SHORT",
"plugins": [],
"qos": "regular",
"templateDir": "zppy/templates",
"vars": "FSNTOA,FLUT,FSNT,FLNT,FSNS,FLNS,SHFLX,QFLX,TAUX,TAUY,PRECC,PRECL,PRECSC,PRECSL,TS,TREFHT,CLDTOT,CLDHGH,CLDMED,CLDLOW,U",
Expand Down Expand Up @@ -132,6 +133,7 @@ def test_sections(self):
"nodes": 1,
"output": "OUTPUT",
"partition": "SHORT",
"plugins": [],
"qos": "regular",
"subsection": None,
"templateDir": "zppy/templates",
Expand Down Expand Up @@ -179,6 +181,7 @@ def test_sections(self):
"nodes": 4,
"output": "OUTPUT",
"partition": "SHORT",
"plugins": [],
"qos": "regular",
"subsection": None,
"templateDir": "zppy/templates",
Expand Down Expand Up @@ -227,6 +230,7 @@ def test_subsections(self):
"nodes": 1,
"output": "OUTPUT",
"partition": "SHORT",
"plugins": [],
"qos": "regular",
"templateDir": "zppy/templates",
"vars": "FSNTOA,FLUT,FSNT,FLNT,FSNS,FLNS,SHFLX,QFLX,TAUX,TAUY,PRECC,PRECL,PRECSC,PRECSL,TS,TREFHT,CLDTOT,CLDHGH,CLDMED,CLDLOW,U",
Expand Down Expand Up @@ -296,6 +300,7 @@ def test_subsections(self):
"nodes": 1,
"output": "OUTPUT",
"partition": "SHORT",
"plugins": [],
"qos": "regular",
"subsection": "ts_grid1",
"templateDir": "zppy/templates",
Expand Down Expand Up @@ -331,6 +336,7 @@ def test_subsections(self):
"nodes": 1,
"output": "OUTPUT",
"partition": "SHORT",
"plugins": [],
"qos": "regular",
"subsection": "ts_grid2",
"templateDir": "zppy/templates",
Expand Down Expand Up @@ -392,6 +398,7 @@ def test_subsections(self):
"nodes": 4,
"output": "OUTPUT",
"partition": "SHORT",
"plugins": [],
"qos": "regular",
"subsection": "climo_grid1",
"templateDir": "zppy/templates",
Expand Down Expand Up @@ -422,6 +429,7 @@ def test_subsections(self):
"nodes": 4,
"output": "OUTPUT",
"partition": "LONG",
"plugins": [],
"qos": "regular",
"subsection": "climo_grid2",
"templateDir": "zppy/templates",
Expand Down
27 changes: 14 additions & 13 deletions zppy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,21 @@ def main(): # noqa: C901

# Load all external plugins. Build a list.
plugins = []
for plugin_name in user_config["default"]["plugins"]:
# Load plugin module
try:
plugin_module = importlib.import_module(plugin_name)
except BaseException:
raise ValueError(
"Could not load external zppy plugin module {}".format(plugin_name)
if "plugins" in user_config["default"].keys():
for plugin_name in user_config["default"]["plugins"]:
# Load plugin module
try:
plugin_module = importlib.import_module(plugin_name)
except BaseException:
raise ValueError(
"Could not load external zppy plugin module {}".format(plugin_name)
)
# Path
plugin_path = plugin_module.__path__[0]
# Add to list
plugins.append(
{"name": plugin_name, "module": plugin_module, "path": plugin_path}
)
# Path
plugin_path = plugin_module.__path__[0]
# Add to list
plugins.append(
{"name": plugin_name, "module": plugin_module, "path": plugin_path}
)

# Read configuration files again, this time including all plugins
with open(default_config) as f:
Expand Down
7 changes: 5 additions & 2 deletions zppy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import stat
import time
from subprocess import PIPE, Popen
from typing import Any, Dict, List

# -----------------------------------------------------------------------------
# Process specified section and its sub-sections to build list of tasks
Expand All @@ -14,10 +15,12 @@

def getTasks(config, section_name):

tasks = []
# mypy: resolves error: Need type annotation for "tasks" (hint: "tasks: List[<type>] = ...")
tasks: List[Dict[str, Any]] = []

# Sanity check
if not section_name in config:
# flake8: resolves E713 test for membership should be 'not in'
if section_name not in config:
print('WARNING: Skipping section not found = "%s"' % (section_name))
return tasks

Expand Down

0 comments on commit 3b2338e

Please sign in to comment.