From aa0af352cdd034872d24b3a5f497a04204c9c017 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Tue, 24 Jan 2017 22:37:37 +0100 Subject: [PATCH 1/6] Add a simple UI to manage tool dependencies This page simply lists all loaded tools and their dependency status. On the left are checkboxes to select multiple tools, and at the bottom is a button to install the selected tool dependencies. --- lib/galaxy/web/base/controllers/admin.py | 12 ++++ templates/webapps/galaxy/admin/index.mako | 1 + .../galaxy/admin/manage_dependencies.mako | 63 +++++++++++++++++++ .../webapps/tool_shed/repository/common.mako | 63 ++++++++++--------- 4 files changed, 109 insertions(+), 30 deletions(-) create mode 100644 templates/webapps/galaxy/admin/manage_dependencies.mako diff --git a/lib/galaxy/web/base/controllers/admin.py b/lib/galaxy/web/base/controllers/admin.py index 8c671160008..41d5d85eede 100644 --- a/lib/galaxy/web/base/controllers/admin.py +++ b/lib/galaxy/web/base/controllers/admin.py @@ -1123,6 +1123,18 @@ class Admin( object ): job=job, message="Back" ) + @web.expose + @web.require_admin + def manage_tool_dependencies( self, trans, install_dependencies=False, install_for_tools=[]): + if install_dependencies: + # install the dependencies for the tools in the install_for_tools list + if not isinstance(install_for_tools, list): + install_for_tools = [install_for_tools] + requirements = set([trans.app.toolbox.tools_by_id[tid].tool_requirements for tid in install_for_tools]) + [trans.app.toolbox.tools_by_id[install_for_tools[0]]._view.install_dependencies(r) for r in requirements] + return trans.fill_template( '/webapps/galaxy/admin/manage_dependencies.mako', + tools=trans.app.toolbox.tools_by_id ) + @web.expose @web.require_admin def sanitize_whitelist( self, trans, submit_whitelist=False, tools_to_whitelist=[]): diff --git a/templates/webapps/galaxy/admin/index.mako b/templates/webapps/galaxy/admin/index.mako index 0f8bc97b659..c0b5e049e7a 100644 --- a/templates/webapps/galaxy/admin/index.mako +++ b/templates/webapps/galaxy/admin/index.mako @@ -78,6 +78,7 @@
Review tool migration stages
View Tool Error Logs
Manage Display Whitelist
+
Manage Tool Dependencies
diff --git a/templates/webapps/galaxy/admin/manage_dependencies.mako b/templates/webapps/galaxy/admin/manage_dependencies.mako new file mode 100644 index 00000000000..f87493395b5 --- /dev/null +++ b/templates/webapps/galaxy/admin/manage_dependencies.mako @@ -0,0 +1,63 @@ +<%inherit file="/base.mako"/> +<%namespace file="/webapps/tool_shed/repository/common.mako" import="render_dependency_status"/> +<%namespace file="/message.mako" import="render_msg" /> + +<%def name="render_tool_dependencies( requirements_status, ctr=False )"> + %for i, dependency in enumerate(requirements_status): + %if i != 0: + + %if ctr % 2 == 1: + + %else: + + %endif + + + + %endif + ${render_dependency_status(dependency)} + %endfor + + +%if message: + ${render_msg( message, status )} +%endif + +
+
+
Manage dependencies for loaded tools
+
+ + + + + + + + + + + + <% ctr = 0 %> + %for tool in tools.values(): + %if tool.tool_requirements: + %if ctr % 2 == 1: + + %else: + + %endif + + + + ${render_tool_dependencies( tool._view.get_requirements_status({tool.id: tool.tool_requirements}, tool.installed_tool_dependencies), ctr=ctr) } + + <% ctr += 1 %> + %endif + %endfor +
InstallNameIDRequirementVersionResolverExact
+ + ${ tool.name | h }${ tool.id | h }
+
+
+ +
diff --git a/templates/webapps/tool_shed/repository/common.mako b/templates/webapps/tool_shed/repository/common.mako index e6889081909..ad45e2bc965 100644 --- a/templates/webapps/tool_shed/repository/common.mako +++ b/templates/webapps/tool_shed/repository/common.mako @@ -1026,6 +1026,38 @@ %> +<%def name="render_dependency_status( dependency, prepare_for_install=False)"> + ${dependency['name'] | h} + ${dependency['version'] | h} + %if not prepare_for_install: + %if dependency['dependency_type']: + ${dependency['dependency_type'].title() | h} + %else: + ${dependency['dependency_type'] | h} + %endif + ${dependency['exact'] | h} + %endif + %if dependency['dependency_type'] == None: + + + %if prepare_for_install: + Not Installed + %endif + + %elif not dependency['exact']: + + + + %else: + + + %if prepare_for_install: + Installed through ${dependency['dependency_type'].title() | h} + %endif + + %endif + + <%def name="render_tool_dependency_resolver( requirements_status, prepare_for_install=False )"> @@ -1043,37 +1075,8 @@ %for dependency in requirements_status: + ${render_dependency_status(dependency, prepare_for_install)} - ${dependency['name'] | h} - ${dependency['version'] | h} - %if not prepare_for_install: - %if dependency['dependency_type']: - ${dependency['dependency_type'].title() | h} - %else: - ${dependency['dependency_type'] | h} - %endif - ${dependency['exact'] | h} - %endif - %if dependency['dependency_type'] == None: - - - %if prepare_for_install: - Not Installed - %endif - - %elif not dependency['exact']: - - - - %else: - - - %if prepare_for_install: - Installed through ${dependency['dependency_type'].title() | h} - %endif - - %endif - %endfor From 818c10832a1429b79e65906d106b6fda0ed28a35 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 26 Jan 2017 14:25:58 +0100 Subject: [PATCH 2/6] Build the dependency status more efficiently: Pass a dictionary with ToolRequirements object as key and requirements status as value --- lib/galaxy/web/base/controllers/admin.py | 21 ++++++++++++++----- .../galaxy/admin/manage_dependencies.mako | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/web/base/controllers/admin.py b/lib/galaxy/web/base/controllers/admin.py index 41d5d85eede..81b5f033273 100644 --- a/lib/galaxy/web/base/controllers/admin.py +++ b/lib/galaxy/web/base/controllers/admin.py @@ -1,7 +1,7 @@ import logging import os from datetime import datetime, timedelta -from six import string_types +import six from string import punctuation as PUNCTUATION from sqlalchemy import and_, false, func, or_ @@ -1125,15 +1125,26 @@ class Admin( object ): @web.expose @web.require_admin - def manage_tool_dependencies( self, trans, install_dependencies=False, install_for_tools=[]): + def manage_tool_dependencies( self, trans, install_dependencies=False, build_cache=False, install_for_tools=[]): + tools_by_id = trans.app.toolbox.tools_by_id if install_dependencies: # install the dependencies for the tools in the install_for_tools list if not isinstance(install_for_tools, list): install_for_tools = [install_for_tools] - requirements = set([trans.app.toolbox.tools_by_id[tid].tool_requirements for tid in install_for_tools]) + requirements = set([tools_by_id[tid].tool_requirements for tid in install_for_tools]) [trans.app.toolbox.tools_by_id[install_for_tools[0]]._view.install_dependencies(r) for r in requirements] + else: + view = six.next(six.itervalues(trans.app.toolbox.tools_by_id))._view + tool_ids_by_requirements = {} + for tid, tool in trans.app.toolbox.tools_by_id.items(): + if not tool.tool_requirements in tool_ids_by_requirements: + tool_ids_by_requirements[tool.tool_requirements] = [tid] + else: + tool_ids_by_requirements[tool.tool_requirements].append(tid) + requirements_status = {r: view.get_requirements_status({tid: r}, tools_by_id[tids[0]].installed_tool_dependencies) for r, tids in tool_ids_by_requirements.items()} return trans.fill_template( '/webapps/galaxy/admin/manage_dependencies.mako', - tools=trans.app.toolbox.tools_by_id ) + tools=tools_by_id, + requirements_status=requirements_status) @web.expose @web.require_admin @@ -1142,7 +1153,7 @@ class Admin( object ): # write the configured sanitize_whitelist_file with new whitelist # and update in-memory list. with open(trans.app.config.sanitize_whitelist_file, 'wt') as f: - if isinstance(tools_to_whitelist, string_types): + if isinstance(tools_to_whitelist, six.string_types): tools_to_whitelist = [tools_to_whitelist] new_whitelist = sorted([tid for tid in tools_to_whitelist if tid in trans.app.toolbox.tools_by_id]) f.write("\n".join(new_whitelist)) diff --git a/templates/webapps/galaxy/admin/manage_dependencies.mako b/templates/webapps/galaxy/admin/manage_dependencies.mako index f87493395b5..784568140de 100644 --- a/templates/webapps/galaxy/admin/manage_dependencies.mako +++ b/templates/webapps/galaxy/admin/manage_dependencies.mako @@ -51,7 +51,7 @@ ${ tool.name | h } ${ tool.id | h } - ${render_tool_dependencies( tool._view.get_requirements_status({tool.id: tool.tool_requirements}, tool.installed_tool_dependencies), ctr=ctr) } + ${render_tool_dependencies( requirements_status[tool.tool_requirements], ctr=ctr) } <% ctr += 1 %> %endif From f882a14886de65b0079d5eea72a7bea044ab4a02 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 26 Jan 2017 17:24:52 +0100 Subject: [PATCH 3/6] Add new view that primarily manages dependencies --- lib/galaxy/tools/deps/resolvers/conda.py | 2 +- lib/galaxy/web/base/controllers/admin.py | 23 ++-- .../galaxy/admin/manage_dependencies.mako | 110 ++++++++++++------ 3 files changed, 90 insertions(+), 45 deletions(-) diff --git a/lib/galaxy/tools/deps/resolvers/conda.py b/lib/galaxy/tools/deps/resolvers/conda.py index c77b0d96cf9..0d8765f0d74 100644 --- a/lib/galaxy/tools/deps/resolvers/conda.py +++ b/lib/galaxy/tools/deps/resolvers/conda.py @@ -232,7 +232,7 @@ class CondaDependencyResolver(DependencyResolver, MultipleDependencyResolver, Li if job_directory: conda_environment = os.path.join(job_directory, conda_env) else: - conda_environment = None + conda_environment = self.conda_context.env_path(conda_target.install_environment) return CondaDependency( self.conda_context, diff --git a/lib/galaxy/web/base/controllers/admin.py b/lib/galaxy/web/base/controllers/admin.py index 81b5f033273..4fd10225821 100644 --- a/lib/galaxy/web/base/controllers/admin.py +++ b/lib/galaxy/web/base/controllers/admin.py @@ -1125,7 +1125,7 @@ class Admin( object ): @web.expose @web.require_admin - def manage_tool_dependencies( self, trans, install_dependencies=False, build_cache=False, install_for_tools=[]): + def manage_tool_dependencies( self, trans, install_dependencies=False, build_cache=False, install_for_tools=[], viewkey='View tool-centric dependencies'): tools_by_id = trans.app.toolbox.tools_by_id if install_dependencies: # install the dependencies for the tools in the install_for_tools list @@ -1133,18 +1133,19 @@ class Admin( object ): install_for_tools = [install_for_tools] requirements = set([tools_by_id[tid].tool_requirements for tid in install_for_tools]) [trans.app.toolbox.tools_by_id[install_for_tools[0]]._view.install_dependencies(r) for r in requirements] - else: - view = six.next(six.itervalues(trans.app.toolbox.tools_by_id))._view - tool_ids_by_requirements = {} - for tid, tool in trans.app.toolbox.tools_by_id.items(): - if not tool.tool_requirements in tool_ids_by_requirements: - tool_ids_by_requirements[tool.tool_requirements] = [tid] - else: - tool_ids_by_requirements[tool.tool_requirements].append(tid) - requirements_status = {r: view.get_requirements_status({tid: r}, tools_by_id[tids[0]].installed_tool_dependencies) for r, tids in tool_ids_by_requirements.items()} + view = six.next(six.itervalues(trans.app.toolbox.tools_by_id))._view + tool_ids_by_requirements = {} + for tid, tool in trans.app.toolbox.tools_by_id.items(): + if tool.tool_requirements not in tool_ids_by_requirements: + tool_ids_by_requirements[tool.tool_requirements] = [tid] + else: + tool_ids_by_requirements[tool.tool_requirements].append(tid) + requirements_status = {r: view.get_requirements_status({tid: r}, tools_by_id[tids[0]].installed_tool_dependencies) for r, tids in tool_ids_by_requirements.items()} return trans.fill_template( '/webapps/galaxy/admin/manage_dependencies.mako', tools=tools_by_id, - requirements_status=requirements_status) + requirements_status=requirements_status, + tool_ids_by_requirements=tool_ids_by_requirements, + viewkey=viewkey ) @web.expose @web.require_admin diff --git a/templates/webapps/galaxy/admin/manage_dependencies.mako b/templates/webapps/galaxy/admin/manage_dependencies.mako index 784568140de..96fd4382c4c 100644 --- a/templates/webapps/galaxy/admin/manage_dependencies.mako +++ b/templates/webapps/galaxy/admin/manage_dependencies.mako @@ -2,7 +2,7 @@ <%namespace file="/webapps/tool_shed/repository/common.mako" import="render_dependency_status"/> <%namespace file="/message.mako" import="render_msg" /> -<%def name="render_tool_dependencies( requirements_status, ctr=False )"> +<%def name="render_tool_dependencies( requirements_status, ctr=False, ncols_extra=4, show_environment_path=False )"> %for i, dependency in enumerate(requirements_status): %if i != 0: @@ -11,51 +11,95 @@ %else: %endif - - - + %for i in range(ncols_extra-1): + + %endfor + %endif + %if show_environment_path: + ${dependency.get('environment_path', '') | h} %endif ${render_dependency_status(dependency)} %endfor +<%def name="render_tool_centric_table( tools, requirements_status)"> + + Install + Name + ID + Requirement + Version + Resolver + Exact + + + <% ctr = 0 %> + %for tool in tools.values(): + %if tool.tool_requirements: + %if ctr % 2 == 1: + + %else: + + %endif + + + + ${ tool.name | h } + ${ tool.id | h } + ${render_tool_dependencies( requirements_status[tool.tool_requirements], ctr=ctr) } + + <% ctr += 1 %> + %endif + %endfor + + +<%def name="render_dependencies_details( tools, requirements_status, tool_ids_by_requirements)"> + + Install + Used by + Environment Path + Requirement + Version + Resolver + Exact + + + <% ctr = 0 %> + %for requirements, r_status in requirements_status.items(): + %if requirements: + <% tool_ids = tool_ids_by_requirements[requirements] %> + %if ctr % 2 == 1: + + %else: + + %endif + + + + ${ ", ".join([tools[tid].name for tid in tool_ids]) | h } + ${render_tool_dependencies( r_status, ctr=ctr, show_environment_path=True, ncols_extra=3) } + + %endif + <% ctr += 1 %> + %endfor + + %if message: ${render_msg( message, status )} %endif
+ +
-
Manage dependencies for loaded tools
+
${viewkey}
- - - - - - - - - - - <% ctr = 0 %> - %for tool in tools.values(): - %if tool.tool_requirements: - %if ctr % 2 == 1: - - %else: - - %endif - - - - ${render_tool_dependencies( requirements_status[tool.tool_requirements], ctr=ctr) } - - <% ctr += 1 %> - %endif - %endfor + %if viewkey == "View tool-centric dependencies": + ${render_tool_centric_table(tools, requirements_status)} + %else: + ${render_dependencies_details(tools, requirements_status, tool_ids_by_requirements)} + %endif
InstallNameIDRequirementVersionResolverExact
- - ${ tool.name | h }${ tool.id | h }
From f1bb5a6a7114f1aa4dc331622183432604e9dbc7 Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Fri, 3 Mar 2017 14:27:49 -0500 Subject: [PATCH 4/6] close opened div --- templates/webapps/galaxy/admin/manage_dependencies.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/webapps/galaxy/admin/manage_dependencies.mako b/templates/webapps/galaxy/admin/manage_dependencies.mako index 96fd4382c4c..257fdbd87b4 100644 --- a/templates/webapps/galaxy/admin/manage_dependencies.mako +++ b/templates/webapps/galaxy/admin/manage_dependencies.mako @@ -92,7 +92,7 @@
-
${viewkey} +
${viewkey}
%if viewkey == "View tool-centric dependencies": From 96ae2893b3610e28101445f58966cffd61f873eb Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Fri, 3 Mar 2017 14:46:26 -0500 Subject: [PATCH 5/6] improve the markup and UX a bit --- .../galaxy/admin/manage_dependencies.mako | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/templates/webapps/galaxy/admin/manage_dependencies.mako b/templates/webapps/galaxy/admin/manage_dependencies.mako index 257fdbd87b4..bc8e0342c74 100644 --- a/templates/webapps/galaxy/admin/manage_dependencies.mako +++ b/templates/webapps/galaxy/admin/manage_dependencies.mako @@ -88,20 +88,24 @@ ${render_msg( message, status )} %endif - - - + +%if viewkey == "Switch to tool-centric view": +
-
${viewkey}
+
Tool-centric dependencies
+
+
+ ${render_tool_centric_table(tools, requirements_status)} +%else: + +
+
Dependency details
- %if viewkey == "View tool-centric dependencies": - ${render_tool_centric_table(tools, requirements_status)} - %else: ${render_dependencies_details(tools, requirements_status, tool_ids_by_requirements)} - %endif +%endif
- + From 5dc73b7966d3c9e90e0a58823e34bc26663d5d71 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 8 Mar 2017 12:06:05 +0100 Subject: [PATCH 6/6] Add title and explanation for Manage Tool Dependencies page. --- templates/webapps/galaxy/admin/manage_dependencies.mako | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/webapps/galaxy/admin/manage_dependencies.mako b/templates/webapps/galaxy/admin/manage_dependencies.mako index bc8e0342c74..a7f0d6fb554 100644 --- a/templates/webapps/galaxy/admin/manage_dependencies.mako +++ b/templates/webapps/galaxy/admin/manage_dependencies.mako @@ -88,6 +88,9 @@ ${render_msg( message, status )} %endif +

Manage Tool Dependencies

+

This page gives an overview of all tool dependencies required by all tools currently loaded, including tools not installed through the Tool Shed.

+
%if viewkey == "Switch to tool-centric view":