Add the ability to enter a new tool panel section label when installing repositories with tools from a tool shed in addition to being able to choose an existing tool panel section for containing the tools. Also clean up code related to message displayed when a local Galaxy instance is missing tools required by an imported workflow.

This commit is contained in:
Greg Von Kuster
2011-11-10 10:57:39 -05:00
parent 8c4f54ff77
commit 12e6400183
5 changed files with 67 additions and 31 deletions
+1
View File
@@ -22,6 +22,7 @@ from Cheetah.Template import Template
pkg_resources.require( 'elementtree' )
from elementtree import ElementTree, ElementInclude
from elementtree.ElementTree import Element
log = logging.getLogger( __name__ )
+40 -11
View File
@@ -3,7 +3,7 @@ from galaxy import model
from galaxy.model.orm import *
from galaxy.web.framework.helpers import time_ago, iff, grids
from galaxy.tools.search import ToolBoxSearch
from galaxy.tools import json_fix
from galaxy.tools import ToolSection, json_fix
import logging
log = logging.getLogger( __name__ )
@@ -403,7 +403,7 @@ class RepositoryListGrid( grids.Grid ):
def get_value( self, trans, grid, tool_shed_repository ):
return tool_shed_repository.tool_shed
# Grid definition
title = "Tool shed repositories"
title = "Installed tool shed repositories"
model_class = model.ToolShedRepository
template='/admin/tool_shed_repository/grid.mako'
default_sort_key = "name"
@@ -807,28 +807,45 @@ class AdminGalaxy( BaseUIController, Admin, AdminActions, UsesQuota, QuotaParamP
status = kwd.get( 'status', 'done' )
tool_shed_url = kwd[ 'tool_shed_url' ]
repo_info_dict = kwd[ 'repo_info_dict' ]
new_tool_panel_section = kwd.get( 'new_tool_panel_section', '' )
tool_panel_section = kwd.get( 'tool_panel_section', '' )
if kwd.get( 'select_tool_panel_section_button', False ):
shed_tool_conf = kwd[ 'shed_tool_conf' ]
# Get the tool path.
for k, tool_path in trans.app.toolbox.shed_tool_confs.items():
if k == shed_tool_conf:
break
if 'tool_panel_section' in kwd:
section_key = 'section_%s' % kwd[ 'tool_panel_section' ]
tool_section = trans.app.toolbox.tool_panel[ section_key ]
if new_tool_panel_section or tool_panel_section:
if new_tool_panel_section:
section_id = new_tool_panel_section.lower().replace( ' ', '_' )
new_section_key = 'section_%s' % str( section_id )
if new_section_key in trans.app.toolbox.tool_panel:
# Appending a tool to an existing section in trans.app.toolbox.tool_panel
log.debug( "Appending to tool panel section: %s" % new_tool_panel_section )
tool_section = trans.app.toolbox.tool_panel[ new_section_key ]
else:
# Appending a new section to trans.app.toolbox.tool_panel
log.debug( "Loading new tool panel section: %s" % new_tool_panel_section )
elem = Element( 'section' )
elem.attrib[ 'name' ] = new_tool_panel_section
elem.attrib[ 'id' ] = section_id
tool_section = ToolSection( elem )
trans.app.toolbox.tool_panel[ new_section_key ] = tool_section
else:
section_key = 'section_%s' % tool_panel_section
tool_section = trans.app.toolbox.tool_panel[ section_key ]
# Decode the encoded repo_info_dict param value.
repo_info_dict = tool_shed_decode( repo_info_dict )
# Clone the repository to the configured location.
current_working_dir = os.getcwd()
installed_repository_names = []
for name, repo_info_tuple in repo_info_dict.items():
description, repository_clone_url, changeset_revision = repo_info_tuple
clone_dir = os.path.join( tool_path, self.__generate_tool_path( repository_clone_url, changeset_revision ) )
if os.path.exists( clone_dir ):
# Repository and revision has already been cloned.
# TODO: implement the ability to re-install or revert an existing repository.
message += 'Revision <b>%s</b> of repository <b>%s</b> has already been installed. Updating an existing repository is not yet supported.<br/>' % \
( changeset_revision, name )
status = 'error'
message += 'Revision <b>%s</b> of repository <b>%s</b> was previously installed.<br/>' % ( changeset_revision, name )
else:
os.makedirs( clone_dir )
log.debug( 'Cloning %s...' % repository_clone_url )
@@ -892,9 +909,7 @@ class AdminGalaxy( BaseUIController, Admin, AdminActions, UsesQuota, QuotaParamP
if trans.app.toolbox_search.enabled:
# If search support for tools is enabled, index the new installed tools.
trans.app.toolbox_search = ToolBoxSearch( trans.app.toolbox )
message += 'Revision <b>%s</b> of repository <b>%s</b> has been loaded into tool panel section <b>%s</b>.<br/>' % \
( changeset_revision, name, tool_section.name )
#return trans.show_ok_message( message )
installed_repository_names.append( name )
else:
tmp_stderr = open( tmp_name, 'rb' )
message += '%s<br/>' % tmp_stderr.read()
@@ -905,6 +920,19 @@ class AdminGalaxy( BaseUIController, Admin, AdminActions, UsesQuota, QuotaParamP
message += '%s<br/>' % tmp_stderr.read()
tmp_stderr.close()
status = 'error'
if installed_repository_names:
installed_repository_names.sort()
message += 'These %d repositories were installed and all tools were loaded into tool panel section <b>%s</b>:<br/>' % \
( len( installed_repository_names ), tool_section.name )
for i, repo_name in enumerate( installed_repository_names ):
if i == len( installed_repository_names ) -1:
message += '%s.<br/>' % repo_name
else:
message += '%s, ' % repo_name
return trans.response.send_redirect( web.url_for( controller='admin',
action='browse_tool_shed_repositories',
message=message,
status=status ) )
else:
message = 'Choose the section in your tool panel to contain the installed tools.'
status = 'error'
@@ -921,6 +949,7 @@ class AdminGalaxy( BaseUIController, Admin, AdminActions, UsesQuota, QuotaParamP
shed_tool_conf=shed_tool_conf,
shed_tool_conf_select_field=shed_tool_conf_select_field,
tool_panel_section_select_field=tool_panel_section_select_field,
new_tool_panel_section=new_tool_panel_section,
message=message,
status=status )
@web.expose
+15 -16
View File
@@ -1115,10 +1115,10 @@ class WorkflowController( BaseUIController, Sharable, UsesStoredWorkflow, UsesAn
workflow_name = tool_shed_decode( workflow_name )
# The following parameters will have a value only if the import originated
# from a tool shed repository installed locally.
local_file = kwd.get( 'local_file', '' )
installed_repository_file = kwd.get( 'installed_repository_file', '' )
repository_id = kwd.get( 'repository_id', '' )
if local_file and not import_button:
workflow_file = open( local_file, 'rb' )
if installed_repository_file and not import_button:
workflow_file = open( installed_repository_file, 'rb' )
workflow_text = workflow_file.read()
workflow_file.close()
import_button = True
@@ -1197,27 +1197,26 @@ class WorkflowController( BaseUIController, Sharable, UsesStoredWorkflow, UsesAn
if shed_url.endswith( '/' ):
shed_url = shed_url.rstrip( '/' )
url = '%s/repository/find_tools?galaxy_url=%s&webapp=%s' % ( shed_url, trans.request.host, webapp )
if missing_tool_tups:
url += '&tool_id='
for missing_tool_tup in missing_tool_tups:
missing_tool_id = missing_tool_tup[0]
url += '&tool_id=%s' % missing_tool_id
url += '%s,' % missing_tool_id
message += '<a href="%s">%s</a><br/>' % ( url, shed_name )
status = 'error'
if local_file or tool_shed_url:
if installed_repository_file or tool_shed_url:
# Another Galaxy panels Hack: The request did not originate from the Galaxy
# workflow view, so we don't need to render the Galaxy panels.
return trans.response.send_redirect( web.url_for( controller='admin',
action='center',
webapp='galaxy',
message=message,
status=status ) )
action = 'center'
else:
# Another Galaxy panels hack: The request originated from the Galaxy
# workflow view, so we need to render the Galaxy panels.
return trans.response.send_redirect( web.url_for( controller='admin',
action='index',
webapp='galaxy',
message=message,
status=status ) )
action = 'index'
return trans.response.send_redirect( web.url_for( controller='admin',
action=action,
webapp='galaxy',
message=message,
status=status ) )
else:
# TODO: Figure out what to do here...
pass
@@ -1228,7 +1227,7 @@ class WorkflowController( BaseUIController, Sharable, UsesStoredWorkflow, UsesAn
url = 'http://%s/workflow/view_workflow?repository_metadata_id=%s&workflow_name=%s&webapp=%s&message=%s' % \
( tool_shed_url, repository_metadata_id, tool_shed_encode( workflow_name ), webapp, message )
return trans.response.send_redirect( url )
elif local_file:
elif installed_repository_file:
# The workflow was read from a file included with an installed tool shed repository.
message = "Workflow <b>%s</b> imported successfully." % workflow.name
return trans.response.send_redirect( web.url_for( controller='admin',
+10 -3
View File
@@ -23,7 +23,7 @@
<br/>
<div class="toolForm">
<div class="toolFormTitle">Load tools into tool panel</div>
<div class="toolFormTitle">Choose section to load tools into tool panel</div>
<div class="toolFormBody">
<form name="select_tool_panel_section" id="select_tool_panel_section" action="${h.url_for( controller='admin', action='install_tool_shed_repository', tool_shed_url=tool_shed_url, repo_info_dict=repo_info_dict )}" method="post" >
%if shed_tool_conf_select_field:
@@ -40,10 +40,17 @@
<input type="hidden" name="shed_tool_conf" value="${shed_tool_conf}"/>
%endif
<div class="form-row">
<label>Tool panel section:</label>
<label>Add new tool panel section:</label>
<input name="new_tool_panel_section" type="textfield" value="${new_tool_panel_section}" size="40"/>
<div class="toolParamHelp" style="clear: both;">
Add a new tool panel section or choose an existing section in your tool panel below to contain the installed tools.
</div>
</div>
<div class="form-row">
<label>Select existing tool panel section:</label>
${tool_panel_section_select_field.get_html()}
<div class="toolParamHelp" style="clear: both;">
Choose the section in your tool panel to contain the installed tools.
Choose an existing section in your tool panel to contain the installed tools.
</div>
</div>
<div class="form-row">
@@ -103,7 +103,7 @@
<div class="menubutton" style="float: left;" id="workflow-${index}-popup">
${workflow_name}
<div popupmenu="workflow-${index}-popup">
<a class="action-button" href="${h.url_for( controller='workflow', action='import_workflow', local_file=full_path, repository_id=trans.security.encode_id( repository.id ) )}">Import to Galaxy</a>
<a class="action-button" href="${h.url_for( controller='workflow', action='import_workflow', installed_repository_file=full_path, repository_id=trans.security.encode_id( repository.id ) )}">Import to Galaxy</a>
</div>
</div>
</td>