def for_path(path, temp_path=None): """Produce a class:`Runnable` for supplied path.""" runnable_type = None if os.path.isdir(path): runnable_type = RunnableType.directory elif looks_like_a_tool_cwl(path): runnable_type = RunnableType.cwl_tool elif looks_like_a_data_manager_xml(path): runnable_type = RunnableType.galaxy_datamanager elif looks_like_a_tool_xml(path): runnable_type = RunnableType.galaxy_tool elif is_a_yaml_with_class(path, ["GalaxyWorkflow"]): runnable_type = RunnableType.galaxy_workflow elif path.endswith(".ga"): runnable_type = RunnableType.galaxy_workflow elif looks_like_a_cwl_artifact(path, ["Workflow"]): runnable_type = RunnableType.cwl_workflow if runnable_type is None: error("Unable to determine runnable type for path [%s]" % path) raise ExitCodeException(EXIT_CODE_UNKNOWN_FILE_TYPE) if temp_path: path = _copy_runnable_tree(path, runnable_type, temp_path) return Runnable(path, runnable_type)
def cli(ctx, paths, **kwds): """Install conda packages for tool requirements.""" conda_context = build_conda_context(ctx, **kwds) if not conda_context.is_conda_installed(): auto_init = kwds.get("conda_auto_init", False) failed = True if auto_init: if conda_context.can_install_conda(): if conda_util.install_conda(conda_context): error("Attempted to install conda and failed.") else: failed = False else: error("Cannot install conda, failing conda_install.") else: error( "Conda not configured - run planemo conda_init' or pass --conda_auto_init to continue." ) if failed: raise ExitCodeException(EXIT_CODE_FAILED_DEPENDENCIES) return_codes = [] for conda_target in collect_conda_targets(ctx, paths): ctx.log("Install conda target %s" % conda_target) return_code = conda_util.install_conda_target( conda_target, conda_context=conda_context) return_codes.append(return_code) return coalesce_return_codes(return_codes, assert_at_least_one=True)
def for_path(path, temp_path=None): """Produce a class:`Runnable` for supplied path.""" runnable_type = None if os.path.isdir(path): runnable_type = RunnableType.directory elif looks_like_a_tool_cwl(path): runnable_type = RunnableType.cwl_tool elif looks_like_a_data_manager_xml(path): runnable_type = RunnableType.galaxy_datamanager elif looks_like_a_tool_xml(path): runnable_type = RunnableType.galaxy_tool elif is_a_yaml_with_class(path, ["GalaxyWorkflow"]): runnable_type = RunnableType.galaxy_workflow elif path.endswith(".ga"): runnable_type = RunnableType.galaxy_workflow elif looks_like_a_cwl_artifact(path, ["Workflow"]): runnable_type = RunnableType.cwl_workflow else: # Check to see if it is a Galaxy workflow with a different extension try: with open(path, "r") as f: as_dict = yaml.safe_load(f) if as_dict.get("a_galaxy_workflow", False): runnable_type = RunnableType.galaxy_workflow except Exception: pass if runnable_type is None: error("Unable to determine runnable type for path [%s]" % path) raise ExitCodeException(EXIT_CODE_UNKNOWN_FILE_TYPE) if temp_path: path = _copy_runnable_tree(path, runnable_type, temp_path) return Runnable(path, runnable_type)
def build_conda_context(ctx, **kwds): """Build a galaxy-lib CondaContext tailored to planemo use. Using planemo's common command-line/global config options. """ condarc_override_default = os.path.join(ctx.workspace, "condarc") conda_prefix = kwds.get("conda_prefix", None) use_planemo_shell = kwds.get("use_planemo_shell_exec", True) ensure_channels = kwds.get("conda_ensure_channels", "") condarc_override = kwds.get("condarc", condarc_override_default) use_local = kwds.get("conda_use_local", False) shell_exec = shell if use_planemo_shell else None conda_context = conda_util.CondaContext(conda_prefix=conda_prefix, ensure_channels=ensure_channels, condarc_override=condarc_override, use_local=use_local, shell_exec=shell_exec) handle_auto_init = kwds.get("handle_auto_init", False) if handle_auto_init and not conda_context.is_installed(): auto_init = kwds.get("conda_auto_init", True) failed = True if auto_init: if conda_context.can_install_conda(): if conda_util.install_conda(conda_context): error(MESSAGE_ERROR_FAILED_INSTALL) else: failed = False else: error(MESSAGE_ERROR_CANNOT_INSTALL) else: error(MESSAGE_ERROR_NOT_INSTALLING) if failed: raise ExitCodeException(EXIT_CODE_FAILED_DEPENDENCIES) if handle_auto_init: conda_context.ensure_conda_build_installed_if_needed() return conda_context
def exit(self, exit_code): """Exit planemo with the supplied exit code.""" self.vlog("Exiting planemo with exit code [%d]" % exit_code) raise ExitCodeException(exit_code)