From fa67bf08b4988194b349b802e14051ebca00e840 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 7 Nov 2019 13:34:02 -0500 Subject: [PATCH] Make container resolution via dependency API optional, off by default. Makes resolution grid a dependency resolution grid. Deviates from the previous legacy API by not showing containers now - reasons for this are laid out here - https://github.com/galaxyproject/galaxy/pull/7125#issuecomment-539516275. --- .../components/admin/Dependencies/Landing.vue | 10 ++--- lib/galaxy/tool_util/deps/__init__.py | 3 ++ lib/galaxy/tool_util/deps/views.py | 4 ++ .../webapps/galaxy/api/tool_dependencies.py | 43 ++++++++++++++----- 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/client/galaxy/scripts/components/admin/Dependencies/Landing.vue b/client/galaxy/scripts/components/admin/Dependencies/Landing.vue index a2a5ce2fa840..880a941b4797 100644 --- a/client/galaxy/scripts/components/admin/Dependencies/Landing.vue +++ b/client/galaxy/scripts/components/admin/Dependencies/Landing.vue @@ -1,12 +1,12 @@ @@ -24,7 +24,7 @@ export default { components: { ContainerIndex, ResolutionIndex, UnusedIndex }, data: function() { return { - mode: "resolution" + mode: "dependencies" }; }, methods: { diff --git a/lib/galaxy/tool_util/deps/__init__.py b/lib/galaxy/tool_util/deps/__init__.py index c1ab1cb059f7..3e52f4744ac4 100644 --- a/lib/galaxy/tool_util/deps/__init__.py +++ b/lib/galaxy/tool_util/deps/__init__.py @@ -201,6 +201,7 @@ def _requirements_to_dependencies_dict(self, requirements, search=False, **kwds) index = kwds.get('index') install = kwds.get('install', False) resolver_type = kwds.get('resolver_type') + include_containers = kwds.get('include_containers', False) container_type = kwds.get('container_type') require_exact = kwds.get('exact', False) return_null_dependencies = kwds.get('return_null', False) @@ -239,6 +240,8 @@ def _requirements_to_dependencies_dict(self, requirements, search=False, **kwds) if hasattr(resolver, "resolve_all"): resolve = resolver.resolve_all elif isinstance(resolver, ContainerResolver): + if not include_containers: + continue if not install and resolver.builds_on_resolution: # don't want to build images here continue diff --git a/lib/galaxy/tool_util/deps/views.py b/lib/galaxy/tool_util/deps/views.py index 2263659c636e..5c2850fc5039 100644 --- a/lib/galaxy/tool_util/deps/views.py +++ b/lib/galaxy/tool_util/deps/views.py @@ -228,6 +228,8 @@ def summarize_requirements(self, **kwds): summary_kwds = {} if 'index' in kwds: summary_kwds['index'] = int(kwds['index']) + if 'include_containers' in kwds: + summary_kwds['include_containers'] = asbool(kwds['include_containers']) if 'container_type' in kwds: summary_kwds['container_type'] = kwds['container_type'] if 'resolver_type' in kwds: @@ -257,6 +259,8 @@ def summarize_tools(self, **kwds): summary_kwds = {} if 'index' in kwds: summary_kwds['index'] = int(kwds['index']) + if 'include_containers' in kwds: + summary_kwds['include_containers'] = asbool(kwds['include_containers']) if 'container_type' in kwds: summary_kwds['container_type'] = kwds['container_type'] if 'resolver_type' in kwds: diff --git a/lib/galaxy/webapps/galaxy/api/tool_dependencies.py b/lib/galaxy/webapps/galaxy/api/tool_dependencies.py index 30db2674976a..81d6a1abb92e 100644 --- a/lib/galaxy/webapps/galaxy/api/tool_dependencies.py +++ b/lib/galaxy/webapps/galaxy/api/tool_dependencies.py @@ -194,10 +194,23 @@ def summarize_toolbox(self, trans, **kwds): Summarize requirements across toolbox (for Tool Management grid). This is an experiemental API particularly tied to the GUI - expect breaking changes until this notice is removed. + Container resolution via this API is especially experimental and the container resolution + API should be used to summarize this information instead in most cases. + :type index: int :param index: index of the dependency resolver :type tool_ids: str :param tool_ids: tool_id to install dependency for + :type resolver_type: str + :param resolver_type: restrict to uninstall to specified resolver type + :type include_containers: bool + :param include_containers: include container resolvers in resolution + :type container_type: str + :param container_type: restrict to uninstall to specified container type + :type index_by: str + :param index_by: By default consider only context of requirements, group tools by requirements. + Set this to 'tools' to summarize across all tools though. Tools may provide additional + context for container resolution for instance. :rtype: list :returns: dictified descriptions of the dependencies, with attribute @@ -224,19 +237,24 @@ def toolbox_install(self, trans, payload, index=None, **kwds): :param index: index of the dependency resolver :type tool_ids: str :param tool_ids: tool_id to install dependency for - :type container_type: str - :param container_type: restrict to uninstall to specified container type :type resolver_type: str :param resolver_type: restrict to uninstall to specified resolver type + :type include_containers: bool + :param include_containers: include container resolvers in resolution + :type container_type: str + :param container_type: restrict to uninstall to specified container type """ tools_by_id = trans.app.toolbox.tools_by_id.copy() tool_ids = payload.get("tool_ids") requirements = set([tools_by_id[tid].tool_requirements for tid in tool_ids]) install_kwds = {} - if 'container_type' in payload: - install_kwds['container_type'] = payload['container_type'] - if 'resolver_type' in kwds: - install_kwds['resolver_type'] = payload['resolver_type'] + for source in [payload, kwds]: + if 'include_containers' in source: + install_kwds['include_containers'] = source['container_type'] + if 'container_type' in kwds: + install_kwds['container_type'] = source['container_type'] + if 'resolver_type' in source: + install_kwds['resolver_type'] = source['resolver_type'] [self._view.install_dependencies(requirements=r, index=index, **install_kwds) for r in requirements] @expose_api @@ -253,6 +271,8 @@ def toolbox_uninstall(self, trans, payload, index=None, **kwds): :param index: index of the dependency resolver :type tool_ids: str :param tool_ids: tool_id to install dependency for + :type include_containers: bool + :param include_containers: include container resolvers in resolution :type container_type: str :param container_type: restrict to uninstall to specified container type :type resolver_type: str @@ -262,10 +282,13 @@ def toolbox_uninstall(self, trans, payload, index=None, **kwds): tool_ids = payload.get("tool_ids") requirements = set([tools_by_id[tid].tool_requirements for tid in tool_ids]) install_kwds = {} - if 'container_type' in payload: - install_kwds['container_type'] = payload['container_type'] - if 'resolver_type' in kwds: - install_kwds['resolver_type'] = payload['resolver_type'] + for source in [payload, kwds]: + if 'include_containers' in source: + install_kwds['include_containers'] = source['container_type'] + if 'container_type' in kwds: + install_kwds['container_type'] = source['container_type'] + if 'resolver_type' in source: + install_kwds['resolver_type'] = source['resolver_type'] [self._view.uninstall_dependencies(index=index, requirements=r, **install_kwds) for r in requirements]