diff --git a/looper/conductor.py b/looper/conductor.py index 2001ad558..9796d7070 100644 --- a/looper/conductor.py +++ b/looper/conductor.py @@ -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__) @@ -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) @@ -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 diff --git a/looper/pipeline_interface.py b/looper/pipeline_interface.py index abe9a43d9..aca1bdd29 100644 --- a/looper/pipeline_interface.py +++ b/looper/pipeline_interface.py @@ -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 *