mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add a new grid to view the tool version lineage by tool id (parent/child ordered) for any tool that was ever used in the local Galaxy instance. Tool ids in this grid that are associated with tools currently loaded in the tool panel are highlighted in green and are click-able, displaying the tool. Eliminate the mappers for determining lineage, and use methods instead as the mappers were problematic.
This commit is contained in:
@@ -2693,31 +2693,49 @@ class ToolVersion( object ):
|
||||
self.create_time = create_time
|
||||
self.tool_id = tool_id
|
||||
self.tool_shed_repository = tool_shed_repository
|
||||
def get_previous_version( self, app ):
|
||||
sa_session = app.model.context.current
|
||||
tva = sa_session.query( app.model.ToolVersionAssociation ) \
|
||||
.filter( app.model.ToolVersionAssociation.table.c.tool_id == self.id ) \
|
||||
.first()
|
||||
if tva:
|
||||
return sa_session.query( app.model.ToolVersion ) \
|
||||
.filter( app.model.ToolVersion.table.c.id == tva.parent_id ) \
|
||||
.first()
|
||||
return None
|
||||
def get_next_version( self, app ):
|
||||
sa_session = app.model.context.current
|
||||
tva = sa_session.query( app.model.ToolVersionAssociation ) \
|
||||
.filter( app.model.ToolVersionAssociation.table.c.parent_id == self.id ) \
|
||||
.first()
|
||||
if tva:
|
||||
return sa_session.query( app.model.ToolVersion ) \
|
||||
.filter( app.model.ToolVersion.table.c.id == tva.tool_id ) \
|
||||
.first()
|
||||
return None
|
||||
def get_versions( self, app ):
|
||||
sa_session = app.model.context.current
|
||||
tool_versions = []
|
||||
# Prepend ancestors.
|
||||
def __ancestors( tool_version ):
|
||||
def __ancestors( app, tool_version ):
|
||||
# Should we handle multiple parents at each level?
|
||||
previous_tva = tool_version.previous_version
|
||||
if previous_tva:
|
||||
parent_version = previous_tva[0].parent_version
|
||||
if parent_version not in tool_versions:
|
||||
tool_versions.insert( 0, parent_version )
|
||||
__ancestors( parent_version )
|
||||
previous_version = tool_version.get_previous_version( app )
|
||||
if previous_version:
|
||||
if previous_version not in tool_versions:
|
||||
tool_versions.insert( 0, previous_version )
|
||||
__ancestors( app, previous_version )
|
||||
# Append descendants.
|
||||
def __descendants( tool_version ):
|
||||
def __descendants( app, tool_version ):
|
||||
# Should we handle multiple child siblings at each level?
|
||||
next_tva = sa_session.query( app.model.ToolVersionAssociation ) \
|
||||
.filter( app.model.ToolVersionAssociation.table.c.parent_id == tool_version.id ) \
|
||||
.first()
|
||||
if next_tva:
|
||||
current_version = next_tva.tool_version
|
||||
if current_version not in tool_versions:
|
||||
tool_versions.append( current_version )
|
||||
__descendants( current_version )
|
||||
__ancestors( self )
|
||||
__descendants( self )
|
||||
next_version = tool_version.get_next_version( app )
|
||||
if next_version:
|
||||
if next_version not in tool_versions:
|
||||
tool_versions.append( next_version )
|
||||
__descendants( app, next_version )
|
||||
__ancestors( app, self )
|
||||
if self not in tool_versions:
|
||||
tool_versions.append( self )
|
||||
__descendants( app, self )
|
||||
return tool_versions
|
||||
def get_version_ids( self, app ):
|
||||
return [ tool_version.tool_id for tool_version in self.get_versions( app ) ]
|
||||
|
||||
@@ -1627,13 +1627,7 @@ assign_mapper( context, ToolShedRepository, ToolShedRepository.table,
|
||||
|
||||
assign_mapper( context, ToolVersion, ToolVersion.table )
|
||||
|
||||
assign_mapper( context, ToolVersionAssociation, ToolVersionAssociation.table,
|
||||
properties=dict( tool_version=relation( ToolVersion,
|
||||
primaryjoin=( ToolVersionAssociation.table.c.tool_id == ToolVersion.table.c.id ),
|
||||
backref='current_version' ),
|
||||
parent_version=relation( ToolVersion,
|
||||
primaryjoin=( ToolVersionAssociation.table.c.parent_id == ToolVersion.table.c.id ),
|
||||
backref='previous_version' ) ) )
|
||||
assign_mapper( context, ToolVersionAssociation, ToolVersionAssociation.table )
|
||||
|
||||
# Set up proxy so that
|
||||
# Page.users_shared_with
|
||||
|
||||
@@ -1311,6 +1311,7 @@ class Admin( object ):
|
||||
group_list_grid = None
|
||||
quota_list_grid = None
|
||||
repository_list_grid = None
|
||||
tool_version_list_grid = None
|
||||
delete_operation = None
|
||||
undelete_operation = None
|
||||
purge_operation = None
|
||||
@@ -1362,6 +1363,12 @@ class Admin( object ):
|
||||
toolbox=toolbox,
|
||||
message=message,
|
||||
status=status )
|
||||
@web.expose
|
||||
@web.require_admin
|
||||
def tool_versions( self, trans, **kwd ):
|
||||
if 'message' not in kwd or not kwd[ 'message' ]:
|
||||
kwd[ 'message' ] = 'Tool ids for tools that are currently loaded into the tool panel are highlighted in green (click to display).'
|
||||
return self.tool_version_list_grid( trans, **kwd )
|
||||
# Galaxy Role Stuff
|
||||
@web.expose
|
||||
@web.require_admin
|
||||
|
||||
@@ -383,12 +383,64 @@ class QuotaListGrid( grids.Grid ):
|
||||
preserve_state = False
|
||||
use_paging = True
|
||||
|
||||
class ToolVersionListGrid( grids.Grid ):
|
||||
class ToolIdColumn( grids.TextColumn ):
|
||||
def get_value( self, trans, grid, tool_version ):
|
||||
if tool_version.tool_id in trans.app.toolbox.tools_by_id:
|
||||
link = url_for( controller='tool_runner', tool_id=tool_version.tool_id )
|
||||
link_str = '<a href="%s">' % link
|
||||
return '<div class="count-box state-color-ok">%s%s</a></div>' % ( link_str, tool_version.tool_id )
|
||||
return tool_version.tool_id
|
||||
class ToolVersionsColumn( grids.TextColumn ):
|
||||
def get_value( self, trans, grid, tool_version ):
|
||||
tool_ids_str = ''
|
||||
for tool_id in tool_version.get_version_ids( trans.app ):
|
||||
if tool_id in trans.app.toolbox.tools_by_id:
|
||||
link = url_for( controller='tool_runner', tool_id=tool_version.tool_id )
|
||||
link_str = '<a href="%s">' % link
|
||||
tool_ids_str += '<div class="count-box state-color-ok">%s%s</a></div><br/>' % ( link_str, tool_id )
|
||||
else:
|
||||
tool_ids_str += '%s<br/>' % tool_id
|
||||
return tool_ids_str
|
||||
class ToolShedRepositoryColumn( grids.TextColumn ):
|
||||
def get_value( self, trans, grid, tool_version ):
|
||||
if tool_version.tool_shed_repository:
|
||||
return tool_version.tool_shed_repository.name
|
||||
return ''
|
||||
# Grid definition
|
||||
title = "Tool versions"
|
||||
model_class = model.ToolVersion
|
||||
template='/admin/tool_version/grid.mako'
|
||||
default_sort_key = "tool_id"
|
||||
columns = [
|
||||
ToolIdColumn( "Tool id",
|
||||
key='tool_id',
|
||||
attach_popup=False ),
|
||||
ToolVersionsColumn( "Version lineage by tool id (parent/child ordered)" ),
|
||||
ToolShedRepositoryColumn( "Tool shed repository" ),
|
||||
]
|
||||
columns.append( grids.MulticolFilterColumn( "Search repository name",
|
||||
cols_to_filter=[ columns[0] ],
|
||||
key="free-text-search",
|
||||
visible=False,
|
||||
filterable="standard" ) )
|
||||
global_actions = []
|
||||
operations = []
|
||||
standard_filters = []
|
||||
default_filter = {}
|
||||
num_rows_per_page = 50
|
||||
preserve_state = False
|
||||
use_paging = True
|
||||
def build_initial_query( self, trans, **kwd ):
|
||||
return trans.sa_session.query( self.model_class )
|
||||
|
||||
class AdminGalaxy( BaseUIController, Admin, AdminActions, UsesQuota, QuotaParamParser ):
|
||||
|
||||
user_list_grid = UserListGrid()
|
||||
role_list_grid = RoleListGrid()
|
||||
group_list_grid = GroupListGrid()
|
||||
quota_list_grid = QuotaListGrid()
|
||||
tool_version_list_grid = ToolVersionListGrid()
|
||||
delete_operation = grids.GridOperation( "Delete", condition=( lambda item: not item.deleted ), allow_multiple=True )
|
||||
undelete_operation = grids.GridOperation( "Undelete", condition=( lambda item: item.deleted and not item.purged ), allow_multiple=True )
|
||||
purge_operation = grids.GridOperation( "Purge", condition=( lambda item: item.deleted and not item.purged ), allow_multiple=True )
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<%inherit file="/grid_base.mako"/>
|
||||
@@ -63,6 +63,7 @@
|
||||
<div class="toolSectionTitle">Server</div>
|
||||
<div class="toolSectionBody">
|
||||
<div class="toolSectionBg">
|
||||
<div class="toolTitle"><a href="${h.url_for( controller='admin', action='tool_versions' )}" target="galaxy_main">Tool versions</a></div>
|
||||
<div class="toolTitle"><a href="${h.url_for( controller='admin', action='reload_tool' )}" target="galaxy_main">Reload a tool's configuration</a></div>
|
||||
<div class="toolTitle"><a href="${h.url_for( controller='admin', action='memdump' )}" target="galaxy_main">Profile memory usage</a></div>
|
||||
<div class="toolTitle"><a href="${h.url_for( controller='admin', action='jobs' )}" target="galaxy_main">Manage jobs</a></div>
|
||||
|
||||
Reference in New Issue
Block a user