Skip to content

Commit

Permalink
refactor remove unnecessary tests
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Mar 20, 2024
1 parent a383391 commit fad869f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 28 deletions.
4 changes: 2 additions & 2 deletions looper/cli_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from .utils import (
dotfile_path,
enrich_args_via_cfg,
is_registry_path,
is_pephub_registry_path,
read_looper_config_file,
read_looper_dotfile,
initiate_looper_config,
Expand Down Expand Up @@ -195,7 +195,7 @@ def run_looper(args: TopLevelParser, parser: ArgumentParser, test_args=None):
except yaml.parser.ParserError as e:
_LOGGER.error(f"Project config parse failed -- {e}")
sys.exit(1)
elif is_registry_path(subcommand_args.config_file):
elif is_pephub_registry_path(subcommand_args.config_file):
if vars(subcommand_args)[SAMPLE_PL_ARG]:
p = Project(
amendments=subcommand_args.amend,
Expand Down
27 changes: 15 additions & 12 deletions looper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def initiate_looper_config(
return False

if pep_path:
if is_registry_path(pep_path):
if is_pephub_registry_path(pep_path):
pass
else:
pep_path = expandpath(pep_path)
Expand Down Expand Up @@ -562,10 +562,20 @@ def read_looper_config_file(looper_config_path: str) -> dict:
for k, v in return_dict.items():
if isinstance(v, str):
v = expandpath(v)
if not os.path.isabs(v) and not is_registry_path(v):
return_dict[k] = os.path.join(config_dir_path, v)
else:
# TODO this is messy because is_pephub_registry needs to fail on anything NOT a pephub registry path
# https://github.com/pepkit/ubiquerg/issues/43
if is_PEP_file_type(v):
if not os.path.isabs(v):
return_dict[k] = os.path.join(config_dir_path, v)
else:
return_dict[k] = v
elif is_pephub_registry_path(v):
return_dict[k] = v
else:
if not os.path.isabs(v):
return_dict[k] = os.path.join(config_dir_path, v)
else:
return_dict[k] = v

return return_dict

Expand Down Expand Up @@ -609,19 +619,12 @@ def is_PEP_file_type(input_string: str) -> bool:
return res


def is_registry_path(input_string: str) -> bool:
def is_pephub_registry_path(input_string: str) -> bool:
"""
Check if input is a registry path to pephub
:param str input_string: path to the PEP (or registry path)
:return bool: True if input is a registry path
"""
try:
if input_string.endswith(".yaml") or input_string.endswith(".csv"):
return False
except AttributeError:
raise RegistryPathException(
msg=f"Malformed registry path. Unable to parse {input_string} as a registry path."
)
try:
registry_path = RegistryPath(**parse_registry_path(input_string))
except (ValidationError, TypeError):
Expand Down
15 changes: 1 addition & 14 deletions tests/smoketests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,20 +594,7 @@ class TestLooperPEPhub:
],
)
def test_pephub_registry_path_recognition(self, pep_path):
assert is_registry_path(pep_path) is True

@pytest.mark.parametrize(
"pep_path",
[
"some/path/to/pep.yaml",
"different/path.yaml",
"default/path/to/file/without/yaml",
"file_in_folder.yaml",
"not_yaml_file",
],
)
def test_config_recognition(self, pep_path):
assert is_registry_path(pep_path) is False
assert is_pephub_registry_path(pep_path) is True

def test_init_project_using_dict(self, prep_temp_config_with_pep):
"""Verify looper runs using pephub in a basic case and return code is 0"""
Expand Down

0 comments on commit fad869f

Please sign in to comment.