Skip to content

Commit

Permalink
add check for PEP file types first THEN attempt registry path, some t…
Browse files Browse the repository at this point in the history
…ests broken due to exceptions
  • Loading branch information
donaldcampbelljr committed Mar 19, 2024
1 parent c9781d7 commit 089f9ee
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
36 changes: 21 additions & 15 deletions looper/cli_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
init_generic_pipeline,
read_yaml_file,
inspect_looper_config_file,
is_PEP_file_type,
)

from typing import List, Tuple
Expand Down Expand Up @@ -176,41 +177,46 @@ def run_looper(args: TopLevelParser, parser: ArgumentParser, test_args=None):
subcommand_args.ignore_flags = True

# Initialize project
if is_registry_path(subcommand_args.config_file):
if vars(subcommand_args)[SAMPLE_PL_ARG]:
if is_PEP_file_type(subcommand_args.config_file) and os.path.exists(subcommand_args.config_file):
try:
p = Project(
cfg=subcommand_args.config_file,
amendments=subcommand_args.amend,
divcfg_path=divcfg,
runp=subcommand_name == "runp",
project_dict=PEPHubClient()._load_raw_pep(
registry_path=subcommand_args.config_file
),
**{
attr: getattr(subcommand_args, attr)
for attr in CLI_PROJ_ATTRS
if attr in subcommand_args
},
)
else:
raise MisconfigurationException(
f"`sample_pipeline_interface` is missing. Provide it in the parameters."
)
else:
try:
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):
if vars(subcommand_args)[SAMPLE_PL_ARG]:
p = Project(
cfg=subcommand_args.config_file,
amendments=subcommand_args.amend,
divcfg_path=divcfg,
runp=subcommand_name == "runp",
project_dict=PEPHubClient()._load_raw_pep(
registry_path=subcommand_args.config_file
),
**{
attr: getattr(subcommand_args, attr)
for attr in CLI_PROJ_ATTRS
if attr in subcommand_args
},
)
except yaml.parser.ParserError as e:
_LOGGER.error(f"Project config parse failed -- {e}")
sys.exit(1)
else:
raise MisconfigurationException(
f"`sample_pipeline_interface` is missing. Provide it in the parameters."
)
else:
raise MisconfigurationException(
f"Cannot load PEP. Check file path or registry path to pep."
)


selected_compute_pkg = p.selected_compute_package or DEFAULT_COMPUTE_RESOURCES_NAME
if p.dcc is not None and not p.dcc.activate_package(selected_compute_pkg):
Expand Down
8 changes: 2 additions & 6 deletions looper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,8 @@ def is_PEP_file_type(input_string: str) -> bool:

PEP_FILE_TYPES = ["yaml", "csv"]

parsed_path = parse_registry_path(input_string)

if parsed_path["subitem"] in PEP_FILE_TYPES:
return True
else:
return False
res = list(filter(input_string.endswith, PEP_FILE_TYPES)) != []
return res


def is_registry_path(input_string: str) -> bool:
Expand Down

0 comments on commit 089f9ee

Please sign in to comment.