Merge pull request #3479 from mvdbeek/manage_tool_dependencies

Add a simple UI to manage tool dependencies
This commit is contained in:
Martin Cech
2017-03-08 09:34:45 -05:00
committed by GitHub
5 changed files with 175 additions and 33 deletions
+1 -1
View File
@@ -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,
+26 -2
View File
@@ -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_
@@ -1123,6 +1123,30 @@ class Admin( object ):
job=job,
message="<a href='jobs'>Back</a>" )
@web.expose
@web.require_admin
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
if not isinstance(install_for_tools, list):
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]
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,
tool_ids_by_requirements=tool_ids_by_requirements,
viewkey=viewkey )
@web.expose
@web.require_admin
def sanitize_whitelist( self, trans, submit_whitelist=False, tools_to_whitelist=[]):
@@ -1130,7 +1154,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))
@@ -78,6 +78,7 @@
<div class="toolTitle"><a href="${h.url_for( controller='admin', action='review_tool_migration_stages' )}" target="galaxy_main">Review tool migration stages</a></div>
<div class="toolTitle"><a href="${h.url_for( controller='admin', action='tool_errors' )}" target="galaxy_main">View Tool Error Logs</a></div>
<div class="toolTitle"><a href="${h.url_for( controller='admin', action='sanitize_whitelist' )}" target="galaxy_main">Manage Display Whitelist</a></div>
<div class="toolTitle"><a href="${h.url_for( controller='admin', action='manage_tool_dependencies' )}" target="galaxy_main">Manage Tool Dependencies</a></div>
</div>
</div>
<div class="toolSectionPad"></div>
@@ -0,0 +1,114 @@
<%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, ncols_extra=4, show_environment_path=False )">
%for i, dependency in enumerate(requirements_status):
%if i != 0:
</tr>
%if ctr % 2 == 1:
<tr class="odd_row">
%else:
<tr class="tr">
%endif
%for i in range(ncols_extra-1):
<td></td>
%endfor
%endif
%if show_environment_path:
<td>${dependency.get('environment_path', '') | h}</td>
%endif
${render_dependency_status(dependency)}
%endfor
</%def>
<%def name="render_tool_centric_table( tools, requirements_status)">
<tr>
<th bgcolor="#D8D8D8">Install</th>
<th bgcolor="#D8D8D8">Name</th>
<th bgcolor="#D8D8D8">ID</th>
<th bgcolor="#D8D8D8">Requirement</th>
<th bgcolor="#D8D8D8">Version</th>
<th bgcolor="#D8D8D8">Resolver</th>
<th bgcolor="#D8D8D8">Exact</th>
<th bgcolor="#D8D8D8"></th>
</tr>
<% ctr = 0 %>
%for tool in tools.values():
%if tool.tool_requirements:
%if ctr % 2 == 1:
<tr class="odd_row">
%else:
<tr class="tr">
%endif
<td>
<input type="checkbox" name="install_for_tools" value="${tool.id}"/>
</td>
<td>${ tool.name | h }</td>
<td>${ tool.id | h }</td>
${render_tool_dependencies( requirements_status[tool.tool_requirements], ctr=ctr) }
</tr>
<% ctr += 1 %>
%endif
%endfor
</%def>
<%def name="render_dependencies_details( tools, requirements_status, tool_ids_by_requirements)">
<tr>
<th bgcolor="#D8D8D8">Install</th>
<th bgcolor="#D8D8D8">Used by</th>
<th bgcolor="#D8D8D8">Environment Path</th>
<th bgcolor="#D8D8D8">Requirement</th>
<th bgcolor="#D8D8D8">Version</th>
<th bgcolor="#D8D8D8">Resolver</th>
<th bgcolor="#D8D8D8">Exact</th>
<th bgcolor="#D8D8D8"></th>
</tr>
<% ctr = 0 %>
%for requirements, r_status in requirements_status.items():
%if requirements:
<% tool_ids = tool_ids_by_requirements[requirements] %>
%if ctr % 2 == 1:
<tr class="odd_row">
%else:
<tr class="tr">
%endif
<td>
<input type="checkbox" name="install_for_tools" value="${tool_ids[0]}"/>
</td>
<td>${ ", ".join([tools[tid].name for tid in tool_ids]) | h }</td>
${render_tool_dependencies( r_status, ctr=ctr, show_environment_path=True, ncols_extra=3) }
</tr>
%endif
<% ctr += 1 %>
%endfor
</%def>
%if message:
${render_msg( message, status )}
%endif
<h2>Manage Tool Dependencies</h2>
<p>This page gives an overview of all tool dependencies required by all tools currently loaded, including tools not installed through the Tool Shed.</p>
<form name="manage_tool_dependencies" action="${h.url_for( controller='admin', action='manage_tool_dependencies' )}">
%if viewkey == "Switch to tool-centric view":
<input type="submit" name="viewkey" value="Switch to details view"/>
<div class="toolForm">
<div class="toolFormTitle">Tool-centric dependencies</div>
<div class="toolFormBody">
<table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%">
${render_tool_centric_table(tools, requirements_status)}
%else:
<input type="submit" name="viewkey" value="Switch to tool-centric view"/>
<div class="toolForm">
<div class="toolFormTitle">Dependency details</div>
<div class="toolFormBody">
<table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%">
${render_dependencies_details(tools, requirements_status, tool_ids_by_requirements)}
%endif
</table>
</div>
</div>
<input type="submit" name="install_dependencies" value="Install checked dependencies using Conda"/>
</form>
@@ -1026,6 +1026,38 @@
%>
</%def>
<%def name="render_dependency_status( dependency, prepare_for_install=False)">
<td>${dependency['name'] | h}</td>
<td>${dependency['version'] | h}</td>
%if not prepare_for_install:
%if dependency['dependency_type']:
<td>${dependency['dependency_type'].title() | h}</td>
%else:
<td>${dependency['dependency_type'] | h}</td>
%endif
<td>${dependency['exact'] | h}</td>
%endif
%if dependency['dependency_type'] == None:
<td>
<img src="${h.url_for('/static')}/images/icon_error_sml.gif" title='Dependency not resolved'/>
%if prepare_for_install:
Not Installed
%endif
</td>
%elif not dependency['exact']:
<td>
<img src="${h.url_for('/static')}/images/icon_warning_sml.gif" title='Dependency resolved, but version ${dependency['version']} not found'/>
</td>
%else:
<td>
<img src="${h.url_for('/static')}/june_2007_style/blue/ok_small.png"/>
%if prepare_for_install:
Installed through ${dependency['dependency_type'].title() | h}
%endif
</td>
%endif
</%def>
<%def name="render_tool_dependency_resolver( requirements_status, prepare_for_install=False )">
<tr class="datasetRow">
<td style="padding-left: 20 px;">
@@ -1043,37 +1075,8 @@
</head>
<body>
%for dependency in requirements_status:
${render_dependency_status(dependency, prepare_for_install)}
<tr>
<td>${dependency['name'] | h}</td>
<td>${dependency['version'] | h}</td>
%if not prepare_for_install:
%if dependency['dependency_type']:
<td>${dependency['dependency_type'].title() | h}</td>
%else:
<td>${dependency['dependency_type'] | h}</td>
%endif
<td>${dependency['exact'] | h}</td>
%endif
%if dependency['dependency_type'] == None:
<td>
<img src="${h.url_for('/static')}/images/icon_error_sml.gif" title='Dependency not resolved'/>
%if prepare_for_install:
Not Installed
%endif
</td>
%elif not dependency['exact']:
<td>
<img src="${h.url_for('/static')}/images/icon_warning_sml.gif" title='Dependency resolved, but version ${dependency['version']} not found'/>
</td>
%else:
<td>
<img src="${h.url_for('/static')}/june_2007_style/blue/ok_small.png"/>
%if prepare_for_install:
Installed through ${dependency['dependency_type'].title() | h}
%endif
</td>
%endif
</tr>
%endfor
</body>
</table>