def get_container_from_software_requirements(
        use_biocontainers: bool, builder: "HasReqsHints") -> Optional[str]:
    if use_biocontainers:
        ensure_galaxy_lib_available()
        from galaxy.tool_util.deps.containers import (
            DOCKER_CONTAINER_TYPE,
            ContainerRegistry,
        )
        from galaxy.tool_util.deps.dependencies import AppInfo, ToolInfo

        app_info = AppInfo(
            involucro_auto_init=True,
            enable_mulled_containers=True,
            container_image_cache_path=".",
        )  # type: AppInfo
        container_registry = ContainerRegistry(
            app_info)  # type: ContainerRegistry
        requirements = get_dependencies(builder)
        tool_info = ToolInfo(requirements=requirements)  # type: ToolInfo
        container_description = container_registry.find_best_container_description(
            [DOCKER_CONTAINER_TYPE], tool_info)
        if container_description:
            return container_description.identifier

    return None
Esempio n. 2
0
    def _configure_toolbox(self):
        if not isinstance(self, BasicSharedApp):
            raise Exception("Must inherit from BasicSharedApp")

        self.citations_manager = CitationsManager(self)
        self.biotools_metadata_source = get_galaxy_biotools_metadata_source(
            self.config)

        self.dynamic_tools_manager = DynamicToolManager(self)
        self._toolbox_lock = threading.RLock()
        self.toolbox = tools.ToolBox(self.config.tool_configs,
                                     self.config.tool_path, self)
        galaxy_root_dir = os.path.abspath(self.config.root)
        file_path = os.path.abspath(self.config.file_path)
        app_info = AppInfo(
            galaxy_root_dir=galaxy_root_dir,
            default_file_path=file_path,
            tool_data_path=self.config.tool_data_path,
            shed_tool_data_path=self.config.shed_tool_data_path,
            outputs_to_working_directory=self.config.
            outputs_to_working_directory,
            container_image_cache_path=self.config.container_image_cache_path,
            library_import_dir=self.config.library_import_dir,
            enable_mulled_containers=self.config.enable_mulled_containers,
            container_resolvers_config_file=self.config.
            container_resolvers_config_file,
            container_resolvers_config_dict=self.config.container_resolvers,
            involucro_path=self.config.involucro_path,
            involucro_auto_init=self.config.involucro_auto_init,
            mulled_channels=self.config.mulled_channels,
        )
        mulled_resolution_cache = None
        if self.config.mulled_resolution_cache_type:
            cache_opts = {
                "cache.type": self.config.mulled_resolution_cache_type,
                "cache.data_dir": self.config.mulled_resolution_cache_data_dir,
                "cache.lock_dir": self.config.mulled_resolution_cache_lock_dir,
                "cache.expire": self.config.mulled_resolution_cache_expire,
            }
            mulled_resolution_cache = CacheManager(
                **parse_cache_config_options(cache_opts)).get_cache(
                    'mulled_resolution')
        self.container_finder = containers.ContainerFinder(
            app_info, mulled_resolution_cache=mulled_resolution_cache)
        self._set_enabled_container_types()
        index_help = getattr(self.config, "index_tool_help", True)
        self.toolbox_search = ToolBoxSearch(
            self.toolbox,
            index_dir=self.config.tool_search_index_dir,
            index_help=index_help)