Skip to content

Commit

Permalink
Remove existing wrong tool version associations in ToolVersionManager…
Browse files Browse the repository at this point in the history
….handle_tool_versions() . Fix #552.

To fix a tool with a wrong lineage, click on "Set tool versions" on the
"Repository Actions" menu.
  • Loading branch information
nsoranzo committed Aug 12, 2015
1 parent 4b3a34f commit 9c318ac
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/tool_shed/tools/tool_version_manager.py
Expand Up @@ -2,7 +2,7 @@

from galaxy import eggs
eggs.require('SQLAlchemy')
from sqlalchemy import and_
from sqlalchemy import and_, or_

from tool_shed.util import hg_util
from tool_shed.util import shed_util_common as suc
Expand All @@ -23,8 +23,8 @@ def get_tool_version( self, tool_id ):

def get_tool_version_association( self, parent_tool_version, tool_version ):
"""
Return a ToolVersionAssociation if one exists that associates the two received
tool_versions This function is called only from Galaxy.
Return a ToolVersionAssociation if one exists that associates the two
received tool_versions. This function is called only from Galaxy.
"""
context = self.app.install_model.context
return context.query( self.app.install_model.ToolVersionAssociation ) \
Expand Down Expand Up @@ -92,6 +92,16 @@ def handle_tool_versions( self, tool_version_dicts, tool_shed_repository ):
tool_shed_repository=tool_shed_repository )
context.add( tool_version_using_parent_id )
context.flush()
# Remove existing wrong tool version associations having
# tool_version_using_parent_id as parent or
# tool_version_using_tool_guid as child.
context.query( self.app.install_model.ToolVersionAssociation ) \
.filter( or_( and_( self.app.install_model.ToolVersionAssociation.table.c.parent_id == tool_version_using_parent_id.id,
self.app.install_model.ToolVersionAssociation.table.c.tool_id != tool_version_using_tool_guid.id ),
and_( self.app.install_model.ToolVersionAssociation.table.c.parent_id != tool_version_using_parent_id.id,
self.app.install_model.ToolVersionAssociation.table.c.tool_id == tool_version_using_tool_guid.id ) ) ) \
.delete()
context.flush()
tool_version_association = \
self.get_tool_version_association( tool_version_using_parent_id,
tool_version_using_tool_guid )
Expand Down

0 comments on commit 9c318ac

Please sign in to comment.