Skip to content

Commit

Permalink
Fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hwikle-lanl committed Sep 9, 2024
1 parent 8701d64 commit 5a50fa8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/pavilion/path_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def append_path(suffix: Pathlike) -> Callable[[Path], Path]:
"""Constructs a function that appends the given suffix
to a path. Intended for use with map."""

def f(path: Path) -> Path:
def func(path: Path) -> Path:
return path / suffix

return f
return func

def shortpath(path: Path, parents: int = 1) -> Path:
"""Return an abbreviated version of a path, where only
Expand Down
33 changes: 20 additions & 13 deletions lib/pavilion/resolver/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@


class ConfigInfo:
def __init__(self, name: str, type: str, path: Path, label: str = None, from_suite: bool = False):
def __init__(self, name: str, type: str, path: Path, label: str = None,
from_suite: bool = False):

self.name = name
self.type = type
self.label = label
Expand Down Expand Up @@ -116,7 +118,8 @@ def __init__(self, pav_cfg, op_sys: str = None, host: str = None,
# Raw loaded test suites
self._suites: Dict[Dict] = {}

def _get_config_dirname(self, cfg_type: str, use_suites_dir: bool = False) -> str:
@staticmethod
def _get_config_dirname(cfg_type: str, use_suites_dir: bool = False) -> str:
"""Returns the canonical config directory name for a given config type."""

dirname = cfg_type.lower()
Expand All @@ -129,7 +132,8 @@ def _get_config_dirname(self, cfg_type: str, use_suites_dir: bool = False) -> st

return dirname

def _get_config_fname(self, cfg_type: str) -> str:
@staticmethod
def _get_config_fname(cfg_type: str) -> str:
"""Given a config type, returns the name of the file in the
suites directory corresponding to that type."""

Expand Down Expand Up @@ -171,7 +175,8 @@ def _get_test_config_path(self, cfg_name: str, cfg_type: str) -> Tuple[str, Opti

return res

def _config_path_from_suite(self, suite_name: str, conf_type: str) -> Tuple[str, Optional[Path]]:
def _config_path_from_suite(self, suite_name: str,
conf_type: str) -> Tuple[str, Optional[Path]]:
"""Given a suite name, return the path to the config file of the specified
type, if one exists. If the file does not exist in any known suites directory,
returns None."""
Expand All @@ -180,7 +185,7 @@ def _config_path_from_suite(self, suite_name: str, conf_type: str) -> Tuple[str,
labels = list(self.config_labels)

cfg_fname = self._get_config_fname(conf_type)

if conf_type == "suite":
paths.extend(listmap(append_path(f"{suite_name}.yaml"), self.suites_dirs))
labels *= 2
Expand All @@ -205,7 +210,7 @@ def find_config(self, cfg_type: str, cfg_name: str, suite_name: str = None) -> C
:return: A tuple of the path to that config, if it exists, and a boolean
indicating whether it was found in the suites directory (True) or not (False).
"""

cfg_path = None

if suite_name is not None:
Expand Down Expand Up @@ -465,7 +470,7 @@ def load_iter(self, tests: List[str], modes: List[str] = None, overrides: List[s
raw_tests.append(raw_test)

ready_to_resolve.extend(permutations)

# Now resolve all the string syntax and variables those tests at once.
new_resolved_tests = []
for ptest in self._resolve_escapes(ready_to_resolve):
Expand Down Expand Up @@ -606,8 +611,9 @@ def _resolve_escapes(self, ptests: ProtoTest) -> List[ProtoTest]:
resolved_tests = remaining

return multiplied_tests

def _safe_load_config(self, cfg: ConfigInfo, loader: yc.YamlConfigLoader) -> TestConfig:

@staticmethod
def _safe_load_config(cfg: ConfigInfo, loader: yc.YamlConfigLoader) -> TestConfig:
"""Given a path to a config, load the config, and raise an appropriate
error if it can't be loaded"""

Expand Down Expand Up @@ -639,7 +645,8 @@ def _safe_load_config(self, cfg: ConfigInfo, loader: yc.YamlConfigLoader) -> Tes

return raw_cfg

def _load_raw_config(self, cfg_info: ConfigInfo, loader: yc.YamlConfigLoader, optional: bool = False) -> Optional[TestConfig]:
def _load_raw_config(self, cfg_info: ConfigInfo, loader: yc.YamlConfigLoader,
optional: bool = False) -> Optional[TestConfig]:
"""Given a path to a config file and a loader, attempt to load the config, handle errors
appropriately."""

Expand All @@ -663,7 +670,7 @@ def _load_raw_config(self, cfg_info: ConfigInfo, loader: yc.YamlConfigLoader, op

raw_cfg = self._safe_load_config(cfg_info, loader)

if cfg_info.from_suite and cfg_info.type is not "suite":
if cfg_info.from_suite and cfg_info.type != "suite":
raw_cfg = raw_cfg.get(cfg_info.name)

if raw_cfg is None:
Expand Down Expand Up @@ -1012,7 +1019,7 @@ def apply_modes(self, test_cfg, modes: List[str], suite_name: str = None):

for mode in modes:
mode_cfg_path = None

if suite_name is not None:
label, mode_cfg_path = self._config_path_from_suite(suite_name, "mode")
if mode_cfg_path is None:
Expand All @@ -1024,7 +1031,7 @@ def apply_modes(self, test_cfg, modes: List[str], suite_name: str = None):
loader = self._suite_loader

cfg_info = ConfigInfo(mode, "mode", mode_cfg_path, label, from_suite)

raw_mode_cfg = self._load_raw_config(cfg_info, loader)

try:
Expand Down
3 changes: 2 additions & 1 deletion lib/pavilion/series/test_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,8 @@ def mark_completed(self) -> int:

TEST_WAIT_PERIOD = 0.5

def wait(self, wait_for_all=False, wait_period: int = TEST_WAIT_PERIOD, timeout: int = None) -> int:
def wait(self, wait_for_all=False, wait_period: int = TEST_WAIT_PERIOD,
timeout: int = None) -> int:
"""Wait for tests to complete. Returns the number of jobs that completed for this
call to wait.
Expand Down

0 comments on commit 5a50fa8

Please sign in to comment.