Skip to content

Commit

Permalink
attempt simple check to see if provided pipelines are callable #195
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Aug 3, 2023
1 parent 819b00c commit 6513b8a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
34 changes: 32 additions & 2 deletions looper/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
from peppy.const import CONFIG_KEY, SAMPLE_NAME_ATTR, SAMPLE_YAML_EXT
from peppy.exceptions import RemoteYAMLError
from pipestat import PipestatError
from ubiquerg import expandpath
from ubiquerg import expandpath, is_command_callable
from yaml import dump
from yacman import YAMLConfigManager

from .const import *
from .exceptions import JobSubmissionException
from .exceptions import JobSubmissionException, SampleFailedException
from .processed_project import populate_sample_paths
from .utils import fetch_sample_flags, jinja_render_template_strictly


_LOGGER = logging.getLogger(__name__)


Expand Down Expand Up @@ -719,6 +720,10 @@ def write_script(self, pool, size):
namespaces=namespaces
)
_LOGGER.debug(f"namespace pipelines: { pl_iface }")

# check here to ensure command is executable
self.check_executable_path(pl_iface)

namespaces["pipeline"]["var_templates"] = pl_iface[VAR_TEMPL_KEY]
# pre_submit hook namespace updates
namespaces = _exec_pre_submit(pl_iface, namespaces)
Expand Down Expand Up @@ -767,6 +772,31 @@ def _reset_curr_skips(self):
self._curr_skip_pool = []
self._curr_skip_size = 0

def check_executable_path(self, pl_iface):
"""Determines if supplied pipelines are callable.
Raises error and exits Looper if not callable"""
pl_iface = pl_iface
pipeline_commands = []
if "path" in pl_iface.keys():
pipeline_commands.append(pl_iface["path"])
if (
"var_templates" in pl_iface.keys()
and "pipeline" in pl_iface["var_templates"].keys()
):
pipeline_commands.append(pl_iface["var_templates"]["pipeline"])
for command in pipeline_commands:
try:
result = is_command_callable(command)
except:
_LOGGER.error(f" {command} IS NOT EXECUTABLE. EXITING")
raise SampleFailedException
else:
if not result:
_LOGGER.error(f" {command} IS NOT EXECUTABLE. EXITING...")
raise SampleFailedException
else:
return True


def _use_sample(flag, skips):
return flag and not skips
Expand Down
2 changes: 1 addition & 1 deletion looper/pipeline_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pandas as pd
from eido import read_schema
from peppy import utils as peputil
from ubiquerg import expandpath, is_url
from ubiquerg import expandpath, is_url, is_command_callable
from yacman import load_yaml, YAMLConfigManager

from .const import *
Expand Down

0 comments on commit 6513b8a

Please sign in to comment.