From d0b06a3b1da09ff3394e9ea036d788676817b58f Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Sun, 13 Aug 2017 23:59:11 +0200 Subject: [PATCH 1/2] Don't cast tool_version to string if tool_version is None-type If a version is not specifically requested a wrong version (`None` cast to `'None'`) of a tool will be loaded in the workflow editor instead of the latest version. That should address @martenson's remark in https://github.com/galaxyproject/galaxy/pull/4373#issuecomment-321896674 (and maybe also https://github.com/galaxyproject/galaxy/issues/557#issuecomment-213498153). --- lib/galaxy/workflow/modules.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/workflow/modules.py b/lib/galaxy/workflow/modules.py index fd6571660f7..abccc74d052 100644 --- a/lib/galaxy/workflow/modules.py +++ b/lib/galaxy/workflow/modules.py @@ -560,7 +560,9 @@ class ToolModule( WorkflowModule ): tool_id = d.get( 'content_id' ) or d.get( 'tool_id' ) if tool_id is None: raise exceptions.RequestParameterInvalidException( "No tool id could be located for step [%s]." % d ) - tool_version = str( d.get( 'tool_version' ) ) + tool_version = d.get( 'tool_version' ) + if tool_version: + tool_version = str(tool_version) module = super( ToolModule, Class ).from_dict( trans, d, tool_id=tool_id, tool_version=tool_version, exact_tools=exact_tools ) module.post_job_actions = d.get( 'post_job_actions', {} ) module.workflow_outputs = d.get( 'workflow_outputs', [] ) From 6ad6fd9252bf5ec44beb00cb434876e170dc9548 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 14 Aug 2017 11:58:48 +0200 Subject: [PATCH 2/2] Rebuild tool_version_cache on DetachedInstanceError --- .../model/tool_shed_install/__init__.py | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/galaxy/model/tool_shed_install/__init__.py b/lib/galaxy/model/tool_shed_install/__init__.py index ba0cc4b6c79..d2e6da208c9 100644 --- a/lib/galaxy/model/tool_shed_install/__init__.py +++ b/lib/galaxy/model/tool_shed_install/__init__.py @@ -1,10 +1,13 @@ import logging import os + +from urlparse import urljoin +from sqlalchemy.orm.exc import DetachedInstanceError + from galaxy.util.dictifiable import Dictifiable from galaxy.util.bunch import Bunch from galaxy.util import asbool from tool_shed.util import common_util -from urlparse import urljoin log = logging.getLogger( __name__ ) @@ -624,10 +627,21 @@ class ToolVersion( object, Dictifiable ): 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 ) + try: + __ancestors( app, self ) + if self not in tool_versions: + tool_versions.append( self ) + __descendants( app, self ) + except DetachedInstanceError: + # This can happen when loading a tool while referencing + # and outdated tool version cache, so we build a new cache + tool_versions = [] + from galaxy.tools.toolbox.lineages.tool_shed import ToolVersionCache + app.tool_version_cache = ToolVersionCache( app ) + __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, reverse=False ):