Skip to content

Commit

Permalink
Add a simple UI to manage tool dependencies
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mvdbeek committed Mar 8, 2017
1 parent b9c1abd commit aa0af35
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 30 deletions.
12 changes: 12 additions & 0 deletions lib/galaxy/web/base/controllers/admin.py
Expand Up @@ -1123,6 +1123,18 @@ def job_info( self, trans, jobid=None ):
job=job,
message="<a href='jobs'>Back</a>" )

@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=[]):
Expand Down
1 change: 1 addition & 0 deletions templates/webapps/galaxy/admin/index.mako
Expand Up @@ -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>
Expand Down
63 changes: 63 additions & 0 deletions 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:
</tr>
%if ctr % 2 == 1:
<tr class="odd_row">
%else:
<tr class="tr">
%endif
<td></td>
<td></td>
<td></td>
%endif
${render_dependency_status(dependency)}
%endfor
</%def>

%if message:
${render_msg( message, status )}
%endif

<form name="manage_tool_dependencies" action="${h.url_for( controller='admin', action='manage_tool_dependencies' )}">
<div class="toolForm">
<div class="toolFormTitle">Manage dependencies for loaded tools</div>
<div class="toolFormBody">
<table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%">
<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( tool._view.get_requirements_status({tool.id: tool.tool_requirements}, tool.installed_tool_dependencies), ctr=ctr) }
</tr>
<% ctr += 1 %>
%endif
%endfor
</table>
</div>
</div>
<input type="submit" name="install_dependencies" value="Install checked dependencies using Conda"/>
</form>
63 changes: 33 additions & 30 deletions templates/webapps/tool_shed/repository/common.mako
Expand Up @@ -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;">
Expand All @@ -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>
Expand Down

0 comments on commit aa0af35

Please sign in to comment.